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

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_trackget_current_track ()
 
std::shared_ptr< music_trackget_previous_music_track ()
 
void set_previous_track (std::shared_ptr< music_track > 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)
 
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
 

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.

Enumeration Type Documentation

◆ channel_group

Enumerator
NULL_CHANNEL 
SOUND_SOURCES 
SOUND_BELL 
SOUND_TIMER 
SOUND_UI 
SOUND_FX 

Definition at line 28 of file sound.hpp.

Function Documentation

◆ channel_finished_hook()

static void sound::channel_finished_hook ( int  channel)
static

Definition at line 407 of file sound.cpp.

References channel_chunks, and channel_ids.

Referenced by init_sound().

◆ close_sound()

void sound::close_sound ( )

◆ commit_music_changes()

void sound::commit_music_changes ( )

◆ current_driver()

std::string sound::current_driver ( )

Definition at line 413 of file sound.cpp.

◆ empty_playlist()

void sound::empty_playlist ( )

◆ enumerate_drivers()

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

Definition at line 419 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 209 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 202 of file sound.cpp.

Referenced by impl_music_get().

◆ get_music_volume()

int sound::get_music_volume ( )

Definition at line 1085 of file sound.cpp.

Referenced by impl_music_get().

◆ get_num_tracks()

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().

◆ get_previous_music_track()

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

Definition at line 213 of file sound.cpp.

Referenced by impl_music_get().

◆ get_sound_volume()

int sound::get_sound_volume ( )

Definition at line 1105 of file sound.cpp.

Referenced by impl_audio_get().

◆ get_track()

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

Definition at line 227 of file sound.cpp.

References i.

◆ 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 ( )

◆ 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_music_repeatedly()

void sound::play_music_repeatedly ( const std::string &  id)

Definition at line 694 of file sound.cpp.

References play_music().

◆ play_new_music()

static void sound::play_new_music ( )
static

◆ play_sound()

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

◆ play_sound_positioned()

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

◆ 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 1070 of file sound.cpp.

References prefs::get(), gui2::dialogs::sound(), and SOUND_TIMER.

Referenced by countdown_clock::maybe_play_sound().

◆ play_track()

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().

◆ play_UI_sound()

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

◆ remove_track()

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().

◆ reposition_sound()

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().

◆ reset_sound()

void sound::reset_sound ( )

◆ set_bell_volume()

void sound::set_bell_volume ( int  vol)

Definition at line 1134 of file sound.cpp.

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

◆ set_music_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().

◆ set_previous_track()

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

◆ set_sound_volume()

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().

◆ set_track()

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

Definition at line 240 of file sound.cpp.

References i.

Referenced by impl_music_set().

◆ set_UI_volume()

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().

◆ stop_bell()

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().

◆ stop_music()

void sound::stop_music ( )

Definition at line 558 of file sound.cpp.

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

◆ stop_sound() [1/2]

void sound::stop_sound ( )

◆ stop_sound() [2/2]

void sound::stop_sound ( int  id)

Definition at line 904 of file sound.cpp.

References DISTANCE_SILENT, and reposition_sound().

Referenced by close_sound().

◆ stop_UI_sound()

void sound::stop_UI_sound ( )

Definition at line 593 of file sound.cpp.

References c, and SOUND_UI.

Referenced by close_sound(), reset_sound(), and prefs::set_ui_sound().

◆ write_music_play_list()

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().

Variable Documentation

◆ channel_chunks

std::vector<Mix_Chunk*> sound::channel_chunks
static

Definition at line 44 of file sound.cpp.

Referenced by channel_finished_hook(), and init_sound().

◆ channel_ids

std::vector<int> sound::channel_ids
static

Definition at line 48 of file sound.cpp.

Referenced by channel_finished_hook(), init_sound(), is_sound_playing(), and reposition_sound().