The Battle for Wesnoth  1.13.10+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Enumerations | Functions | Variables
sound Namespace Reference

Audio output for sound and music. More...

Classes

struct  chunk_load_exception
 
class  music_muter
 
class  music_thinker
 
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

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)
 
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, 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)
 
static Mix_Chunk * load_chunk (const std::string &file, channel_group group)
 
static void play_sound_internal (const std::string &files, channel_group group, unsigned int repeats=0, unsigned int distance=0, int id=-1, int loop_ticks=0, int fadein_ticks=0)
 
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, int loop_ticks, int 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

Enumerator
NULL_CHANNEL 
SOUND_SOURCES 
SOUND_BELL 
SOUND_TIMER 
SOUND_UI 
SOUND_FX 

Definition at line 26 of file sound.hpp.

Function Documentation

static void sound::channel_finished_hook ( int  channel)
static

Definition at line 389 of file sound.cpp.

References channel_chunks, and channel_ids.

Referenced by init_sound().

void sound::close_sound ( )
void sound::commit_music_changes ( )
void sound::empty_playlist ( )
std::shared_ptr< sound::music_track > sound::get_current_track ( )

Definition at line 197 of file sound.cpp.

Referenced by impl_music_get().

unsigned int sound::get_current_track_index ( )

Definition at line 193 of file sound.cpp.

Referenced by impl_music_get().

int sound::get_music_volume ( )

Definition at line 1015 of file sound.cpp.

Referenced by impl_music_get().

unsigned int sound::get_num_tracks ( )

Definition at line 210 of file sound.cpp.

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

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

Definition at line 201 of file sound.cpp.

Referenced by impl_music_get().

int sound::get_sound_volume ( )

Definition at line 1035 of file sound.cpp.

Referenced by intf_sound_volume().

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

Definition at line 215 of file sound.cpp.

References i.

bool sound::init_sound ( )
bool sound::is_sound_playing ( int  id)
static Mix_Chunk* sound::load_chunk ( const std::string &  file,
channel_group  group 
)
static
void sound::play_bell ( const std::string &  files)
void sound::play_music ( )
void sound::play_music_config ( const config music_node,
int  i 
)
void sound::play_music_once ( const std::string &  file)
void sound::play_music_repeatedly ( const std::string &  id)

Definition at line 634 of file sound.cpp.

References play_music().

Referenced by do_gameloop().

static void sound::play_new_music ( )
static
void sound::play_sound ( const std::string &  files,
channel_group  group,
unsigned int  repeats 
)
static void sound::play_sound_internal ( const std::string &  files,
channel_group  group,
unsigned int  repeats = 0,
unsigned int  distance = 0,
int  id = -1,
int  loop_ticks = 0,
int  fadein_ticks = 0 
)
static
void sound::play_sound_positioned ( const std::string &  files,
int  id,
int  repeats,
unsigned int  distance 
)
void sound::play_timer ( const std::string &  files,
int  loop_ticks,
int  fadein_ticks 
)
void sound::play_track ( unsigned int  i)

Definition at line 581 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)
void sound::remove_track ( unsigned int  i)

Definition at line 235 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 810 of file sound.cpp.

References channel_ids, and DISTANCE_SILENT.

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

void sound::reset_sound ( )
void sound::set_bell_volume ( int  vol)

Definition at line 1064 of file sound.cpp.

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

void sound::set_music_volume ( int  vol)

Definition at line 1024 of file sound.cpp.

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

void sound::set_previous_track ( std::shared_ptr< music_track >  track)
void sound::set_sound_volume ( int  vol)

Definition at line 1044 of file sound.cpp.

References i.

Referenced by init_sound(), intf_sound_volume(), and preferences::set_sound_volume().

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

Definition at line 228 of file sound.cpp.

References i.

Referenced by impl_music_set().

void sound::set_UI_volume ( int  vol)

Definition at line 1076 of file sound.cpp.

References i.

Referenced by init_sound(), and preferences::set_UI_volume().

void sound::stop_bell ( )
void sound::stop_music ( )
void sound::stop_sound ( )
void sound::stop_sound ( int  id)

Definition at line 842 of file sound.cpp.

References DISTANCE_SILENT, and reposition_sound().

void sound::stop_UI_sound ( )

Definition at line 544 of file sound.cpp.

References c, and SOUND_UI.

Referenced by close_sound(), reset_sound(), and preferences::set_UI_sound().

void sound::write_music_play_list ( config snapshot)

Definition at line 800 of file sound.cpp.

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

Variable Documentation

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

Definition at line 42 of file sound.cpp.

Referenced by channel_finished_hook(), init_sound(), load_chunk(), and play_sound_internal().

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