The Battle for Wesnoth  1.19.27+dev
Classes | Functions | Variables
sound Namespace Reference

Audio output for sound and music. More...

Classes

struct  driver_status
 
class  music_thinker
 
class  music_muter
 
class  volume
 
class  music_track
 Internal representation of music tracks. More...
 

Functions

utils::optional< unsigned int > get_current_track_index ()
 
std::shared_ptr< music_trackget_current_track ()
 
void set_current_track (std::shared_ptr< music_track > track)
 
std::shared_ptr< music_trackget_previous_music_track ()
 
unsigned int get_num_tracks ()
 
std::shared_ptr< music_trackget_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 stop_music ()
 
void stop_sound ()
 
void stop_bell ()
 
void stop_UI_sound ()
 
void restart_music ()
 
void restart_sound ()
 
void restart_bell ()
 
void restart_UI_sound ()
 
void play_music_once (const std::string &file)
 
void empty_playlist ()
 
void play_music ()
 
void play_track (unsigned int i)
 
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)
 
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)
 
volume get_music_volume ()
 
void set_music_volume (volume vol)
 
volume get_sound_volume ()
 
void set_sound_volume (volume vol)
 
void set_bell_volume (volume vol)
 
void set_UI_volume (volume vol)
 
void flush_cache ()
 

Variables

constexpr int distance_silent = 255
 
constexpr int distance_none = 0
 
constexpr volume silence {0.f}
 
constexpr volume full_volume {1.f}
 
constexpr volume max_volume {1.28f}
 

Detailed Description

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.

Function Documentation

◆ close_sound()

void sound::close_sound ( )

Definition at line 485 of file sound.cpp.

References flush_cache(), and LOG_AUDIO.

Referenced by game_launcher::~game_launcher().

◆ commit_music_changes()

void sound::commit_music_changes ( )

◆ current_driver()

std::string sound::current_driver ( )

Definition at line 386 of file sound.cpp.

◆ empty_playlist()

void sound::empty_playlist ( )

◆ enumerate_drivers()

std::vector< std::string > sound::enumerate_drivers ( )

Definition at line 392 of file sound.cpp.

References n.

◆ flush_cache()

void sound::flush_cache ( )

◆ get_current_track()

std::shared_ptr< sound::music_track > sound::get_current_track ( )

Definition at line 206 of file sound.cpp.

Referenced by impl_music_get().

◆ get_current_track_index()

utils::optional< unsigned int > sound::get_current_track_index ( )

Definition at line 199 of file sound.cpp.

Referenced by impl_music_get().

◆ get_music_volume()

volume sound::get_music_volume ( )

Definition at line 1004 of file sound.cpp.

References silence.

Referenced by impl_music_get().

◆ get_num_tracks()

unsigned int sound::get_num_tracks ( )

Definition at line 219 of file sound.cpp.

Referenced by impl_music_len(), impl_music_set(), and intf_music_next().

◆ get_previous_music_track()

std::shared_ptr< sound::music_track > sound::get_previous_music_track ( )

Definition at line 214 of file sound.cpp.

Referenced by impl_music_get().

◆ get_sound_volume()

volume sound::get_sound_volume ( )

Definition at line 1020 of file sound.cpp.

References silence.

Referenced by impl_audio_get().

◆ get_track()

std::shared_ptr< music_track > sound::get_track ( unsigned int  i)

Definition at line 224 of file sound.cpp.

References i.

Referenced by impl_music_get().

◆ init_sound()

bool sound::init_sound ( )

◆ is_sound_playing()

bool sound::is_sound_playing ( int  id)

◆ play_bell()

void sound::play_bell ( const std::string &  files)

◆ play_music()

void sound::play_music ( )

Definition at line 589 of file sound.cpp.

Referenced by commit_music_changes(), play_music_config(), play_music_once(), and play_track().

◆ play_music_config()

void sound::play_music_config ( const config music_node,
bool  allow_interrupt_current_track,
int  i 
)

◆ play_music_once()

void sound::play_music_once ( const std::string &  file)

◆ play_sound()

void sound::play_sound ( const std::string &  files,
sound_tracks::type  group,
unsigned int  repeats 
)

◆ play_sound_positioned()

void sound::play_sound_positioned ( const std::string &  files,
int  repeats,
unsigned int  distance,
unsigned int  id 
)

Definition at line 973 of file sound.cpp.

References prefs::get().

Referenced by soundsource::positional_source::update().

◆ play_timer()

void sound::play_timer ( const std::string &  files,
const std::chrono::milliseconds &  loop_ticks,
const std::chrono::milliseconds &  fadein_ticks 
)

Definition at line 989 of file sound.cpp.

References distance_none, and prefs::get().

Referenced by countdown_clock::maybe_play_sound().

◆ play_track()

void sound::play_track ( unsigned int  i)

Definition at line 601 of file sound.cpp.

References i, play_music(), and set_current_track().

Referenced by impl_music_set(), and intf_music_next().

◆ play_UI_sound()

void sound::play_UI_sound ( const std::string &  files)

◆ remove_track()

void sound::remove_track ( unsigned int  i)

Definition at line 244 of file sound.cpp.

References i.

Referenced by impl_music_set(), and intf_music_remove().

◆ reposition_sound()

void sound::reposition_sound ( unsigned  id,
unsigned int  distance 
)

Definition at line 820 of file sound.cpp.

References distance_silent.

Referenced by stop_sound(), and soundsource::positional_source::update_positions().

◆ restart_bell()

void sound::restart_bell ( )

Definition at line 559 of file sound.cpp.

Referenced by prefs::set_turn_bell().

◆ restart_music()

void sound::restart_music ( )

Definition at line 544 of file sound.cpp.

Referenced by prefs::set_music().

◆ restart_sound()

void sound::restart_sound ( )

Definition at line 551 of file sound.cpp.

Referenced by prefs::set_sound().

◆ restart_UI_sound()

void sound::restart_UI_sound ( )

Definition at line 567 of file sound.cpp.

Referenced by prefs::set_ui_sound().

◆ set_bell_volume()

void sound::set_bell_volume ( volume  vol)

Definition at line 1043 of file sound.cpp.

Referenced by init_sound(), and prefs::set_bell_volume().

◆ set_current_track()

void sound::set_current_track ( std::shared_ptr< music_track track)

◆ set_music_volume()

void sound::set_music_volume ( volume  vol)

Definition at line 1013 of file sound.cpp.

Referenced by impl_music_set(), init_sound(), and prefs::set_music_volume().

◆ set_sound_volume()

void sound::set_sound_volume ( volume  vol)

Definition at line 1030 of file sound.cpp.

Referenced by impl_audio_set(), init_sound(), and prefs::set_sound_volume().

◆ set_track()

void sound::set_track ( unsigned int  i,
const std::shared_ptr< music_track > &  to 
)

Definition at line 237 of file sound.cpp.

References i.

Referenced by impl_music_set().

◆ set_UI_volume()

void sound::set_UI_volume ( volume  vol)

Definition at line 1053 of file sound.cpp.

Referenced by init_sound(), and prefs::set_ui_volume().

◆ stop_bell()

void sound::stop_bell ( )

Definition at line 529 of file sound.cpp.

Referenced by prefs::set_turn_bell(), and countdown_clock::~countdown_clock().

◆ stop_music()

void sound::stop_music ( )

Definition at line 511 of file sound.cpp.

Referenced by do_gameloop(), and prefs::set_music().

◆ stop_sound() [1/2]

void sound::stop_sound ( )

◆ stop_sound() [2/2]

void sound::stop_sound ( unsigned  id)

Definition at line 841 of file sound.cpp.

References distance_silent, and reposition_sound().

◆ stop_UI_sound()

void sound::stop_UI_sound ( )

Definition at line 537 of file sound.cpp.

Referenced by prefs::set_ui_sound().

◆ write_music_play_list()

void sound::write_music_play_list ( config snapshot)

Definition at line 810 of file sound.cpp.

Referenced by impl_music_get(), and play_controller::to_config().

Variable Documentation

◆ distance_none

constexpr int sound::distance_none = 0
inlineconstexpr

Definition at line 73 of file sound.hpp.

Referenced by play_timer().

◆ distance_silent

constexpr int sound::distance_silent = 255
inlineconstexpr

◆ full_volume

constexpr volume sound::full_volume {1.f}
inlineconstexpr

Definition at line 148 of file sound.hpp.

◆ max_volume

constexpr volume sound::max_volume {1.28f}
inlineconstexpr

Definition at line 149 of file sound.hpp.

◆ silence

constexpr volume sound::silence {0.f}
inlineconstexpr

Definition at line 147 of file sound.hpp.

Referenced by get_music_volume(), and get_sound_volume().