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... | |
Functions | |
| 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) |
| 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_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 (unsigned id, unsigned int distance) |
| bool | is_sound_playing (int id) |
| void | stop_sound (unsigned id) |
| static void | play_sound_internal (const std::string &files, sound_tracks::type group, unsigned int repeats=0, unsigned int distance=0, unsigned int soundsource_id=UINT_MAX, const std::chrono::milliseconds &loop_ticks=0ms, const std::chrono::milliseconds &fadein_ticks=0ms) |
| void | play_sound (const std::string &files, sound_tracks::type group, unsigned int repeats) |
| void | play_sound_positioned (const std::string &files, int repeats, unsigned int distance, unsigned int id) |
| 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) |
| void | flush_cache () |
Variables | |
| std::mutex | soundsource_map_mutex |
| std::map< unsigned int, int > | soundsource_map |
| std::vector< std::shared_ptr< MIX_Track > > | tracks |
| std::map< int, sound_tracks::type > | track_map |
| std::map< std::string, std::shared_ptr< MIX_Audio > > | music_cache |
| std::vector< std::string > | music_cache_insertion_order |
| std::map< std::string, std::shared_ptr< MIX_Audio > > | sound_cache |
| std::vector< std::string > | sound_cache_insertion_order |
| MIX_Mixer * | mixer |
| std::size_t | mixer_init_counter = 0 |
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.
| void sound::close_sound | ( | ) |
Definition at line 427 of file sound.cpp.
References i, LOG_AUDIO, mixer, mixer_init_counter, stop_bell(), stop_music(), stop_sound(), stop_UI_sound(), and tracks.
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 735 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 531 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 1028 of file sound.cpp.
References music_cache, music_cache_insertion_order, sound_cache, and sound_cache_insertion_order.
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 124 of file sound.cpp.
Referenced by impl_music_get().
| utils::optional< unsigned int > sound::get_current_track_index | ( | ) |
Definition at line 117 of file sound.cpp.
Referenced by impl_music_get().
| int sound::get_music_volume | ( | ) |
Definition at line 955 of file sound.cpp.
References cursor::get(), and tracks.
Referenced by impl_music_get().
| unsigned int sound::get_num_tracks | ( | ) |
Definition at line 137 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 128 of file sound.cpp.
Referenced by impl_music_get().
| int sound::get_sound_volume | ( | ) |
Definition at line 975 of file sound.cpp.
References cursor::get(), and tracks.
Referenced by impl_audio_get().
| std::shared_ptr< music_track > sound::get_track | ( | unsigned int | i | ) |
| bool sound::init_sound | ( | ) |
Definition at line 340 of file sound.cpp.
References gui2::dialogs::bell_volume(), DBG_AUDIO, ERR_AUDIO, prefs::get(), i, LOG_AUDIO, mixer, mixer_init_counter, gui2::dialogs::music_volume(), play_music(), prefs::sample_rate(), set_bell_volume(), set_music_volume(), set_sound_volume(), set_UI_volume(), gui2::dialogs::sound_volume(), track_map, tracks, 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 793 of file sound.cpp.
References cursor::get(), and tracks.
Referenced by soundsource::positional_source::update(), and soundsource::positional_source::update_positions().
| void sound::play_bell | ( | const std::string & | files | ) |
Definition at line 932 of file sound.cpp.
References prefs::get(), play_sound_internal(), 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 536 of file sound.cpp.
Referenced by commit_music_changes(), init_sound(), play_music_config(), play_music_once(), 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 619 of file sound.cpp.
References sound::music_track::append(), sound::music_track::create(), ERR_AUDIO, sound::music_track::file_path(), i, sound::music_track::immediate(), play_music(), sound::music_track::play_once(), and set_previous_track().
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 520 of file sound.cpp.
References sound::music_track::create(), play_music(), and set_previous_track().
Referenced by playsingle_controller::do_end_level(), editor::editor_controller::do_execute_command(), and intf_music_play().
|
static |
Definition at line 560 of file sound.cpp.
References DBG_AUDIO, ERR_AUDIO, filename, cursor::get(), prefs::get(), filesystem::get_localized_path(), LOG_AUDIO, mixer, music_cache, music_cache_insertion_order, gui2::dialogs::music_on(), and tracks.
Referenced by sound::music_thinker::process().
| void sound::play_sound | ( | const std::string & | files, |
| sound_tracks::type | group, | ||
| unsigned int | repeats | ||
| ) |
Definition at line 917 of file sound.cpp.
References prefs::get(), play_sound_internal(), 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().
|
static |
Definition at line 805 of file sound.cpp.
References DBG_AUDIO, ERR_AUDIO, filename, cursor::get(), filesystem::get_binary_file_location(), filesystem::get_localized_path(), string_enums::enum_base< Definition >::get_string(), sdl3_properties::id(), LOG_AUDIO, mixer, pick_one(), gui2::dialogs::sound(), sound_cache, sound_cache_insertion_order, soundsource_map, soundsource_map_mutex, track_map, and tracks.
Referenced by play_bell(), play_sound(), play_sound_positioned(), play_timer(), and play_UI_sound().
| void sound::play_sound_positioned | ( | const std::string & | files, |
| int | repeats, | ||
| unsigned int | distance, | ||
| unsigned int | id | ||
| ) |
Definition at line 924 of file sound.cpp.
References prefs::get(), play_sound_internal(), and gui2::dialogs::sound().
Referenced by 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 940 of file sound.cpp.
References DISTANCE_NONE, prefs::get(), play_sound_internal(), and gui2::dialogs::sound().
Referenced by countdown_clock::maybe_play_sound().
| void sound::play_track | ( | unsigned int | i | ) |
Definition at line 548 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 948 of file sound.cpp.
References prefs::get(), play_sound_internal(), 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 162 of file sound.cpp.
References i.
Referenced by impl_music_set(), and intf_music_remove().
| void sound::reposition_sound | ( | unsigned | id, |
| unsigned int | distance | ||
| ) |
Definition at line 774 of file sound.cpp.
References DISTANCE_SILENT, cursor::get(), and tracks.
Referenced by stop_sound(), and soundsource::positional_source::update_positions().
| void sound::reset_sound | ( | ) |
Definition at line 458 of file sound.cpp.
References close_sound(), 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 1003 of file sound.cpp.
References cursor::get(), and tracks.
Referenced by init_sound(), and prefs::set_bell_volume().
| void sound::set_music_volume | ( | int | vol | ) |
Definition at line 964 of file sound.cpp.
References cursor::get(), and tracks.
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 132 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 984 of file sound.cpp.
References cursor::get(), i, and tracks.
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 1015 of file sound.cpp.
References cursor::get(), i, and tracks.
Referenced by init_sound(), and prefs::set_ui_volume().
| void sound::stop_bell | ( | ) |
Definition at line 505 of file sound.cpp.
References mixer.
Referenced by close_sound(), reset_sound(), prefs::set_turn_bell(), and countdown_clock::~countdown_clock().
| void sound::stop_music | ( | ) |
Definition at line 487 of file sound.cpp.
References cursor::get(), and tracks.
Referenced by close_sound(), do_gameloop(), reset_sound(), and prefs::set_music().
| void sound::stop_sound | ( | ) |
Definition at line 494 of file sound.cpp.
References mixer.
Referenced by gui2::dialogs::story_viewer::display_part(), reset_sound(), prefs::set_sound(), and soundsource::positional_source::~positional_source().
| void sound::stop_sound | ( | unsigned | id | ) |
Definition at line 798 of file sound.cpp.
References DISTANCE_SILENT, and reposition_sound().
Referenced by close_sound().
| void sound::stop_UI_sound | ( | ) |
Definition at line 513 of file sound.cpp.
References mixer.
Referenced by close_sound(), reset_sound(), and prefs::set_ui_sound().
| void sound::write_music_play_list | ( | config & | snapshot | ) |
Definition at line 764 of file sound.cpp.
Referenced by impl_music_get(), and play_controller::to_config().
| MIX_Mixer* sound::mixer |
Definition at line 53 of file sound.cpp.
Referenced by close_sound(), init_sound(), main(), play_new_music(), play_sound_internal(), sound::driver_status::query(), stop_bell(), stop_sound(), and stop_UI_sound().
| std::size_t sound::mixer_init_counter = 0 |
Definition at line 54 of file sound.cpp.
Referenced by close_sound(), and init_sound().
| std::map<std::string, std::shared_ptr<MIX_Audio> > sound::music_cache |
Definition at line 47 of file sound.cpp.
Referenced by flush_cache(), and play_new_music().
| std::vector<std::string> sound::music_cache_insertion_order |
Definition at line 48 of file sound.cpp.
Referenced by flush_cache(), and play_new_music().
| std::map<std::string, std::shared_ptr<MIX_Audio> > sound::sound_cache |
Definition at line 50 of file sound.cpp.
Referenced by flush_cache(), and play_sound_internal().
| std::vector<std::string> sound::sound_cache_insertion_order |
Definition at line 51 of file sound.cpp.
Referenced by flush_cache(), and play_sound_internal().
| std::map<unsigned int, int> sound::soundsource_map |
Definition at line 42 of file sound.cpp.
Referenced by play_sound_internal().
| std::mutex sound::soundsource_map_mutex |
Definition at line 41 of file sound.cpp.
Referenced by play_sound_internal().
| std::map<int, sound_tracks::type> sound::track_map |
Definition at line 45 of file sound.cpp.
Referenced by init_sound(), and play_sound_internal().
| std::vector<std::shared_ptr<MIX_Track> > sound::tracks |
Definition at line 44 of file sound.cpp.
Referenced by close_sound(), get_music_volume(), get_sound_volume(), sound::music_muter::handle_window_event(), impl_music_get(), init_sound(), is_sound_playing(), play_new_music(), play_sound_internal(), sound::music_thinker::process(), reposition_sound(), set_bell_volume(), set_music_volume(), set_sound_volume(), set_UI_volume(), and stop_music().