|
Libprimis
Imprimis' 3D destroyable world engine
|
The wrapper around SDL_Mixer that plays sounds ingame. More...
#include <sound.h>
Public Member Functions | |
| void | clear_sound () |
| Shuts down sound system. | |
| void | preloadsound (int n) |
| Loads the approriate sound file at the given index. | |
| void | preloadmapsounds () |
| Loads the sounds for every element in the map sounds vector. | |
| int | playsound (int n, const vec *loc=nullptr, extentity *ent=nullptr, int flags=0, int loops=0, int fade=0, int chanid=-1, int radius=0, int expire=-1) |
| Plays a sound with the given attributes. | |
| bool | stopsound (int n, int chanid, int fade) |
| Stops playing a sound of index n in the specificied channel. | |
| void | stopsounds () |
| Immediately kills all active sounds. | |
| void | updatesounds () |
| Restarts and updates all sound indices. | |
| int | playsoundname (const char *s, const vec *loc, int vol, int flags, int loops, int fade, int chanid, int radius, int expire) |
| Plays a sound with the given attributes. | |
| void | initsound () |
| Starts SDL_Mixer and initializes startup sound channels. | |
| void | startmusic (const char *name, const char *cmd) |
| Starts a nonpositional music track. | |
| void | resetsound () |
| Resets the sound subsystem. | |
| void | setstereo (const int *const on) |
| Sets whether stereo audio is enabled. | |
| int | getstereo () |
| Returns whether stereo or mono is enabled. | |
| void | setmaxradius (const int *const dist) |
| Sets the maximum radius to play sounds from. | |
| int | getmaxradius () |
| Returns the maximum sound play radius. | |
| void | setsoundchans (const int *const val) |
| Sets the number of sound channels to use. | |
| int | getsoundchans () |
| Returns the number of sound channels in use. | |
| void | setsoundvol (const int *vol) |
| Sets the map sound volume. | |
| int | getsoundvol () |
| Returns the current sound volume. | |
| void | setmusicvol (const int *musicvol) |
| Sets the music sound volume. | |
| int | getmusicvol () |
| Returns the current music volume. | |
| void | setaudiodriver (const char *f) |
| Sends a list of audio subsystems for SDL to bind to. | |
| void | setsound (const int *on) |
| Sets whether the sound engine is enabled. | |
| int | getsound () |
| Returns whether sound is on. | |
| void | registersound (const char *name, const int *vol) |
| Adds a sound to the sound list at a given volume. | |
| void | mapsound (const char *name, const int *vol, const int *maxuses) |
| Adds a sound to the list of map sounds. | |
| void | altsound (const char *name, const int *vol) |
| Adds an alternative game sound. | |
| void | altmapsound (const char *name, const int *vol) |
| Adds an alternative map sound. | |
| void | numsounds () |
| Returns to the console the number of game sounds loaded. | |
| void | nummapsounds () |
| Returns to the console the number of map sounds loaded. | |
| void | soundreset () |
| Resets the loaded game sounds. | |
| void | mapsoundreset () |
| Resets the loaded map sounds. | |
The wrapper around SDL_Mixer that plays sounds ingame.
This class stores and plays sounds on command into either positionally (as a point in the world) or nonpositionally (such as background music).
| void SoundEngine::altmapsound | ( | const char * | name, |
| const int * | vol ) |
Adds an alternative map sound.
| the | name of the sound to add |
| vol | the volume of the sound (0..255) |
| void SoundEngine::altsound | ( | const char * | name, |
| const int * | vol ) |
Adds an alternative game sound.
| the | name of the sound to add |
| vol | the volume of the sound (0..255) |
| void SoundEngine::clear_sound | ( | ) |
Shuts down sound system.
Stops playing any active music, cleans up game and map sound vectors, and shuts down SDL_Mixer.
| int SoundEngine::getmaxradius | ( | ) |
Returns the maximum sound play radius.
The distance is in cube units ( =12.5cm).
| int SoundEngine::getmusicvol | ( | ) |
Returns the current music volume.
| int SoundEngine::getsound | ( | ) |
Returns whether sound is on.
| int SoundEngine::getsoundchans | ( | ) |
Returns the number of sound channels in use.
| int SoundEngine::getsoundvol | ( | ) |
Returns the current sound volume.
| int SoundEngine::getstereo | ( | ) |
Returns whether stereo or mono is enabled.
The return is in CubeScript friendly int form.
| void SoundEngine::initsound | ( | ) |
Starts SDL_Mixer and initializes startup sound channels.
Fails and disables sound output if SDL is v2.0.6.
| void SoundEngine::mapsound | ( | const char * | name, |
| const int * | vol, | ||
| const int * | maxuses ) |
Adds a sound to the list of map sounds.
| name | the path to the sound |
| vol | the volume of the sound (0..255) |
| maxuses | the number of uses before the sound won't play |
| void SoundEngine::mapsoundreset | ( | ) |
Resets the loaded map sounds.
This clears the list of map environment sounds loaded into the sound engine.
| void SoundEngine::nummapsounds | ( | ) |
Returns to the console the number of map sounds loaded.
| void SoundEngine::numsounds | ( | ) |
Returns to the console the number of game sounds loaded.
| int SoundEngine::playsound | ( | int | n, |
| const vec * | loc = nullptr, | ||
| extentity * | ent = nullptr, | ||
| int | flags = 0, | ||
| int | loops = 0, | ||
| int | fade = 0, | ||
| int | chanid = -1, | ||
| int | radius = 0, | ||
| int | expire = -1 ) |
Plays a sound with the given attributes.
| n | index of the sound to play |
| loc | world location to play at |
| ent | entity to associate with (overwrites location) |
| flags | music option flags |
| loops | number of times to loop |
| fade | ms to fade in over |
| chanid | music channel index to use |
| radius | distance over which sound is audible (in size 0 cubes) |
| expire | maximum time before the sound stops playing |
| int SoundEngine::playsoundname | ( | const char * | s, |
| const vec * | loc, | ||
| int | vol, | ||
| int | flags, | ||
| int | loops, | ||
| int | fade, | ||
| int | chanid, | ||
| int | radius, | ||
| int | expire ) |
Plays a sound with the given attributes.
| s | name of the sound to play |
| loc | world location to play at |
| ent | entity to associate with (overwrites location) |
| flags | music option flags |
| loops | number of times to loop |
| fade | ms to fade in over |
| chanid | music channel index to use |
| radius | distance over which sound is audible (in size 0 cubes) |
| expire | maximum time before the sound stops playing |
| void SoundEngine::preloadmapsounds | ( | ) |
Loads the sounds for every element in the map sounds vector.
Loads the related sound file for every valid map sound index (map entity sounds).
| void SoundEngine::preloadsound | ( | int | n | ) |
Loads the approriate sound file at the given index.
Fails silently if index is invalid.
| n | the sound index to use |
| void SoundEngine::registersound | ( | const char * | name, |
| const int * | vol ) |
Adds a sound to the sound list at a given volume.
| name | the path to the sound |
| vol | the volume of the sound (0..255) |
| void SoundEngine::setaudiodriver | ( | const char * | f | ) |
Sends a list of audio subsystems for SDL to bind to.
By default, the standard Linux and Windows audio systems are set.
| f | a list of space-separated names for SDL to attempt to bind |
| void SoundEngine::setmaxradius | ( | const int *const | dist | ) |
Sets the maximum radius to play sounds from.
The distance is in cube units ( =12.5cm).
| dist | the distance to render from |
| void SoundEngine::setmusicvol | ( | const int * | musicvol | ) |
Sets the music sound volume.
Bounds limited to 0..255.
| vol | the volume level for music tracks |
| void SoundEngine::setsound | ( | const int * | on | ) |
Sets whether the sound engine is enabled.
| on | whether sound is enabled or not |
| void SoundEngine::setsoundchans | ( | const int *const | val | ) |
Sets the number of sound channels to use.
Default value is 32; bounds limited to 1..128.
| val | the number of channels to use |
| void SoundEngine::setsoundvol | ( | const int * | vol | ) |
Sets the map sound volume.
Bounds limited to 0..255.
| vol | the volume level for map sounds |
| void SoundEngine::setstereo | ( | const int *const | on | ) |
Sets whether stereo audio is enabled.
| on | if true, enables stereo; if false, disables it |
| void SoundEngine::soundreset | ( | ) |
Resets the loaded game sounds.
This clears the list of game (e.g. hud weapon) sounds loaded into the sound engine.
| void SoundEngine::startmusic | ( | const char * | name, |
| const char * | cmd ) |
Starts a nonpositional music track.
| name | (inc. path) of the track to play |
| cmd | the command to run (in CubeScript) at the end of the track |
| bool SoundEngine::stopsound | ( | int | n, |
| int | chanid, | ||
| int | fade ) |
Stops playing a sound of index n in the specificied channel.
| n | the sound index to stop playing |
| chanid | the channel id to use |
| fade | milliseconds to spend fading out the sound |
| void SoundEngine::stopsounds | ( | ) |
Immediately kills all active sounds.
Halts all sound channels in use and frees them.
| void SoundEngine::updatesounds | ( | ) |
Restarts and updates all sound indices.
Pauses, reloads, and resumes playback of all active sounds. Does not play sounds if on the main menu.