Audio output for sound and music. More...
Classes | |
struct | driver_status |
class | music_thinker |
class | music_muter |
class | music_track |
Internal representation of music tracks. More... | |
Enumerations | |
enum | channel_group { NULL_CHANNEL = -1 , SOUND_SOURCES = 0 , SOUND_BELL , SOUND_TIMER , SOUND_UI , SOUND_FX } |
Functions | |
void | flush_cache () |
utils::optional< unsigned int > | get_current_track_index () |
std::shared_ptr< music_track > | get_current_track () |
std::shared_ptr< music_track > | get_previous_music_track () |
void | set_previous_track (std::shared_ptr< music_track > track) |
unsigned int | get_num_tracks () |
std::shared_ptr< music_track > | get_track (unsigned int i) |
void | set_track (unsigned int i, const std::shared_ptr< music_track > &to) |
void | remove_track (unsigned int i) |
static void | channel_finished_hook (int channel) |
std::string | current_driver () |
std::vector< std::string > | enumerate_drivers () |
bool | init_sound () |
void | close_sound () |
void | reset_sound () |
void | stop_music () |
void | stop_sound () |
void | stop_bell () |
void | stop_UI_sound () |
void | play_music_once (const std::string &file) |
void | empty_playlist () |
void | play_music () |
void | play_track (unsigned int i) |
static void | play_new_music () |
void | play_music_repeatedly (const std::string &id) |
void | play_music_config (const config &music_node, bool allow_interrupt_current_track, int i) |
void | commit_music_changes () |
void | write_music_play_list (config &snapshot) |
void | reposition_sound (int id, unsigned int distance) |
bool | is_sound_playing (int id) |
void | stop_sound (int id) |
void | play_sound (const std::string &files, channel_group group, unsigned int repeats) |
void | play_sound_positioned (const std::string &files, int id, int repeats, unsigned int distance) |
void | play_bell (const std::string &files) |
void | play_timer (const std::string &files, const std::chrono::milliseconds &loop_ticks, const std::chrono::milliseconds &fadein_ticks) |
void | play_UI_sound (const std::string &files) |
int | get_music_volume () |
void | set_music_volume (int vol) |
int | get_sound_volume () |
void | set_sound_volume (int vol) |
void | set_bell_volume (int vol) |
void | set_UI_volume (int vol) |
Variables | |
static std::vector< Mix_Chunk * > | channel_chunks |
static std::vector< int > | channel_ids |
Audio output for sound and music.
This module provides the ability to play music and sounds. Setting music volume to 0 will stop the music.
enum sound::channel_group |
|
static |
Definition at line 407 of file sound.cpp.
References channel_chunks, and channel_ids.
Referenced by init_sound().
void sound::close_sound | ( | ) |
Definition at line 496 of file sound.cpp.
References ERR_AUDIO, LOG_AUDIO, stop_bell(), stop_music(), stop_sound(), and stop_UI_sound().
Referenced by reset_sound(), prefs::set_music(), prefs::set_sound(), prefs::set_turn_bell(), prefs::set_ui_sound(), and game_launcher::~game_launcher().
void sound::commit_music_changes | ( | ) |
Definition at line 843 of file sound.cpp.
References choose_track(), play_music(), and set_previous_track().
Referenced by game_events::event_handler::handle_event(), intf_music_commit(), playsingle_controller::play_scenario(), and actions::undo_event::undo().
void sound::empty_playlist | ( | ) |
Definition at line 613 of file sound.cpp.
Referenced by playsingle_controller::do_end_level(), do_gameloop(), intf_music_clear(), and campaign_controller::play_game().
std::vector< std::string > sound::enumerate_drivers | ( | ) |
void sound::flush_cache | ( | ) |
Definition at line 196 of file sound.cpp.
Referenced by game_launcher::change_language(), events::console_handler::do_refresh(), and game_config_manager::reload_changed_game_config().
std::shared_ptr< sound::music_track > sound::get_current_track | ( | ) |
Definition at line 209 of file sound.cpp.
Referenced by impl_music_get().
utils::optional< unsigned int > sound::get_current_track_index | ( | ) |
Definition at line 202 of file sound.cpp.
Referenced by impl_music_get().
int sound::get_music_volume | ( | ) |
Definition at line 1085 of file sound.cpp.
Referenced by impl_music_get().
unsigned int sound::get_num_tracks | ( | ) |
Definition at line 222 of file sound.cpp.
Referenced by impl_music_len(), impl_music_set(), and intf_music_next().
std::shared_ptr< sound::music_track > sound::get_previous_music_track | ( | ) |
Definition at line 213 of file sound.cpp.
Referenced by impl_music_get().
int sound::get_sound_volume | ( | ) |
Definition at line 1105 of file sound.cpp.
Referenced by impl_audio_get().
std::shared_ptr< music_track > sound::get_track | ( | unsigned int | i | ) |
bool sound::init_sound | ( | ) |
Definition at line 444 of file sound.cpp.
References gui2::dialogs::bell_volume(), channel_chunks, channel_finished_hook(), channel_ids, DBG_AUDIO, ERR_AUDIO, prefs::get(), LOG_AUDIO, gui2::dialogs::music_volume(), play_music(), set_bell_volume(), set_music_volume(), set_sound_volume(), set_UI_volume(), SOUND_BELL, SOUND_FX, SOUND_SOURCES, SOUND_TIMER, SOUND_UI, gui2::dialogs::sound_volume(), and gui2::dialogs::ui_volume().
Referenced by game_launcher::game_launcher(), reset_sound(), prefs::set_music(), prefs::set_sound(), prefs::set_turn_bell(), and prefs::set_ui_sound().
bool sound::is_sound_playing | ( | int | id | ) |
Definition at line 898 of file sound.cpp.
References channel_ids, and utils::find().
Referenced by soundsource::positional_source::update(), and soundsource::positional_source::update_positions().
void sound::play_bell | ( | const std::string & | files | ) |
Definition at line 1062 of file sound.cpp.
References prefs::get(), SOUND_BELL, and game_config::sounds::turn_bell.
Referenced by playsingle_controller::before_human_turn(), and mp::ui_alerts::ready_for_start().
void sound::play_music | ( | ) |
Definition at line 618 of file sound.cpp.
Referenced by commit_music_changes(), init_sound(), play_music_config(), play_music_once(), play_music_repeatedly(), play_track(), and prefs::set_music().
void sound::play_music_config | ( | const config & | music_node, |
bool | allow_interrupt_current_track, | ||
int | i | ||
) |
Definition at line 716 of file sound.cpp.
References sound::music_track::append(), ERR_AUDIO, sound::music_track::file_path(), i, sound::music_track::id(), sound::music_track::immediate(), play_music(), sound::music_track::play_once(), set_previous_track(), and sound::music_track::valid().
Referenced by gui2::dialogs::story_viewer::display_part(), do_gameloop(), impl_music_set(), intf_music_add(), and playsingle_controller::play_scenario().
void sound::play_music_once | ( | const std::string & | file | ) |
Definition at line 604 of file sound.cpp.
References play_music(), and set_previous_track().
Referenced by playsingle_controller::do_end_level(), editor::editor_controller::do_execute_command(), and intf_music_play().
void sound::play_music_repeatedly | ( | const std::string & | id | ) |
Definition at line 694 of file sound.cpp.
References play_music().
|
static |
Definition at line 642 of file sound.cpp.
References ERR_AUDIO, filename, prefs::get(), filesystem::get_localized_path(), LOG_AUDIO, filesystem::make_read_RWops(), and gui2::dialogs::music_on().
Referenced by sound::music_thinker::process().
void sound::play_sound | ( | const std::string & | files, |
channel_group | group, | ||
unsigned int | repeats | ||
) |
Definition at line 1047 of file sound.cpp.
References prefs::get(), and gui2::dialogs::sound().
Referenced by gui2::dialogs::story_viewer::display_part(), play_controller::init_side_end(), game_lua_kernel::intf_play_sound(), game_lua_kernel::intf_set_achievement(), gui2::dialogs::custom_tod::play_sound(), unit_frame::redraw(), and unit_display::unit_attack().
void sound::play_sound_positioned | ( | const std::string & | files, |
int | id, | ||
int | repeats, | ||
unsigned int | distance | ||
) |
Definition at line 1054 of file sound.cpp.
References prefs::get(), gui2::dialogs::sound(), and SOUND_SOURCES.
Referenced by gui2::dialogs::story_viewer::display_part(), and soundsource::positional_source::update().
void sound::play_timer | ( | const std::string & | files, |
const std::chrono::milliseconds & | loop_ticks, | ||
const std::chrono::milliseconds & | fadein_ticks | ||
) |
Definition at line 1070 of file sound.cpp.
References prefs::get(), gui2::dialogs::sound(), and SOUND_TIMER.
Referenced by countdown_clock::maybe_play_sound().
void sound::play_track | ( | unsigned int | i | ) |
Definition at line 630 of file sound.cpp.
References choose_track(), i, play_music(), and set_previous_track().
Referenced by impl_music_set(), and intf_music_next().
void sound::play_UI_sound | ( | const std::string & | files | ) |
Definition at line 1078 of file sound.cpp.
References prefs::get(), SOUND_UI, and gui2::dialogs::ui_sound_on().
Referenced by gui2::slider::child_callback_positioner_moved(), mp::ui_alerts::friend_message(), mp::ui_alerts::game_created(), mp::ui_alerts::game_has_begun(), gui::button::mouse_down(), gui::tristate_button::mouse_up(), gui::button::mouse_up(), mp::ui_alerts::player_joins(), mp::ui_alerts::player_leaves(), mp::ui_alerts::private_message(), mp::ui_alerts::public_message(), events::mouse_handler::select_hex(), mp::ui_alerts::server_message(), gui2::rich_label::signal_handler_left_button_click(), gui2::button::signal_handler_left_button_click(), gui2::menu_button::signal_handler_left_button_click(), gui2::multimenu_button::signal_handler_left_button_click(), gui2::toggle_button::signal_handler_left_button_click(), gui2::toggle_panel::signal_handler_left_button_click(), and gui2::repeating_button::signal_handler_left_button_down().
void sound::remove_track | ( | unsigned int | i | ) |
Definition at line 247 of file sound.cpp.
References i.
Referenced by impl_music_set(), and intf_music_remove().
void sound::reposition_sound | ( | int | id, |
unsigned int | distance | ||
) |
Definition at line 882 of file sound.cpp.
References channel_ids, and DISTANCE_SILENT.
Referenced by stop_sound(), and soundsource::positional_source::update_positions().
void sound::reset_sound | ( | ) |
Definition at line 527 of file sound.cpp.
References close_sound(), ERR_AUDIO, prefs::get(), init_sound(), prefs::music_on(), prefs::sound(), stop_bell(), stop_music(), stop_sound(), stop_UI_sound(), prefs::turn_bell(), and prefs::ui_sound_on().
Referenced by prefs::save_sample_rate(), and prefs::save_sound_buffer_size().
void sound::set_bell_volume | ( | int | vol | ) |
Definition at line 1134 of file sound.cpp.
Referenced by init_sound(), and prefs::set_bell_volume().
void sound::set_music_volume | ( | int | vol | ) |
Definition at line 1094 of file sound.cpp.
Referenced by impl_music_set(), init_sound(), and prefs::set_music_volume().
void sound::set_previous_track | ( | std::shared_ptr< music_track > | track | ) |
Definition at line 217 of file sound.cpp.
Referenced by commit_music_changes(), play_music_config(), play_music_once(), play_track(), and sound::music_thinker::process().
void sound::set_sound_volume | ( | int | vol | ) |
Definition at line 1114 of file sound.cpp.
References i.
Referenced by impl_audio_set(), init_sound(), and prefs::set_sound_volume().
void sound::set_track | ( | unsigned int | i, |
const std::shared_ptr< music_track > & | to | ||
) |
void sound::set_UI_volume | ( | int | vol | ) |
Definition at line 1146 of file sound.cpp.
References i.
Referenced by init_sound(), and prefs::set_ui_volume().
void sound::stop_bell | ( | ) |
Definition at line 581 of file sound.cpp.
References c, SOUND_BELL, and SOUND_TIMER.
Referenced by close_sound(), reset_sound(), prefs::set_turn_bell(), and countdown_clock::~countdown_clock().
void sound::stop_music | ( | ) |
Definition at line 558 of file sound.cpp.
Referenced by close_sound(), do_gameloop(), reset_sound(), and prefs::set_music().
void sound::stop_sound | ( | ) |
Definition at line 566 of file sound.cpp.
References c, SOUND_FX, and SOUND_SOURCES.
Referenced by gui2::dialogs::story_viewer::display_part(), reset_sound(), prefs::set_sound(), and soundsource::positional_source::~positional_source().
void sound::stop_sound | ( | int | id | ) |
Definition at line 904 of file sound.cpp.
References DISTANCE_SILENT, and reposition_sound().
Referenced by close_sound().
void sound::stop_UI_sound | ( | ) |
Definition at line 593 of file sound.cpp.
Referenced by close_sound(), reset_sound(), and prefs::set_ui_sound().
void sound::write_music_play_list | ( | config & | snapshot | ) |
Definition at line 872 of file sound.cpp.
Referenced by impl_music_get(), and play_controller::to_config().
|
static |
Definition at line 44 of file sound.cpp.
Referenced by channel_finished_hook(), and init_sound().
|
static |
Definition at line 48 of file sound.cpp.
Referenced by channel_finished_hook(), init_sound(), is_sound_playing(), and reposition_sound().