CRM64Pro GDK v0.11.0
A free cross-platform game development kit built on top of SDL 3.0
|
v2.00 (28 June 2023)
The Audio Sound module includes the Sound Manager and Sound objects.
Once the audio system is initialized using ConfigMgr::audioInit() or ConfigMgr::load(), using this manager you can load sound files from external files or from a CDC file and play them.
By default as a minimum value, there are 8 mixing channels, each of one can play a sound at the same time. It can be dinamically modified up to 128 mixing channels so 128 different sound can be played at the same time.
Actions that can be done on a sound object:
Supported sound formats:
Raw streams: WAV and VOC | |
Compressed streams: FLAC, Ogg and MP3 |
This is a sharing manager: it has the ability of sharing a sound id to a group of owners when they request to open an already opened object based on the name as the key. When the last one of them closes the sound id, it will be effectively closed.
Only a single instance of the Sound Manager exists which is created once Main is instantiated.
You can get a reference to this manager using Main::ISoundMgr() method.
Classes | |
class | CRM64Pro::Sound |
Sound Object class. More... | |
class | CRM64Pro::SoundMgr |
Sound Manager class. More... | |
Functions | |
Sint32 | CRM64Pro::Sound::info (Sint32 iMode=0) |
Request Sound object information. | |
Sint32 | CRM64Pro::Sound::getName (string &sName) |
Get the name. | |
Uint32 | CRM64Pro::Sound::getID () |
Get the ID. | |
Sint32 | CRM64Pro::Sound::info (string *sType, AudioInfo *AI) |
Get Sound object information. | |
Sint32 | CRM64Pro::Sound::play (Sint32 iChannel=-1, Sint32 iLoop=0) |
Play a sound. | |
Sint32 | CRM64Pro::Sound::fadeIn (Sint32 iTime=1000, Sint32 iChannel=-1, Sint32 iLoop=0) |
Play a sound with a fade in effect. | |
Sint32 | CRM64Pro::Sound::saveToFile (const string &sFile) |
Export the Sound to an external file. | |
Sint32 | CRM64Pro::Sound::save (const string &sFileCDC) |
Save the Sound in to a CDC file. | |
Sint32 | CRM64Pro::Sound::save (Sint32 idCDC) |
Save the Sound in to a CDC file. | |
Sint32 | CRM64Pro::SoundMgr::info (Sint32 idSnd=0) |
Request Sound Manager information. | |
Sint32 | CRM64Pro::SoundMgr::close (Sint32 idSnd=0) |
Close and destroy a sound. | |
Sint32 | CRM64Pro::SoundMgr::getNum () |
Get number of loaded objects. | |
Sint32 | CRM64Pro::SoundMgr::setName (Sint32 idSnd, const string &sName) |
Change the object name. | |
Sound * | CRM64Pro::SoundMgr::get (Sint32 idSnd=0) |
Get a pointer to the sound using its handler. | |
Sint32 | CRM64Pro::SoundMgr::stop (Sint32 iChannel) |
Stop sound playing in a channel. | |
Sint32 | CRM64Pro::SoundMgr::pause (Sint32 iChannel) |
Pause sound playing in a channel. | |
Sint32 | CRM64Pro::SoundMgr::resume (Sint32 iChannel) |
Resume sound playing in a channel. | |
Sint32 | CRM64Pro::SoundMgr::status (Sint32 iChannel) |
Get the sound status on a given channel. | |
Sint32 | CRM64Pro::SoundMgr::fadeOut (Sint32 iChannel, Sint32 iTime=1000) |
Sound fade out effect in a channel. | |
Sint32 | CRM64Pro::SoundMgr::panning (Sint32 iChannel=-1, Uint8 iLeft=255, Uint8 iRight=255) |
Set the panning of a channel. | |
Sint32 | CRM64Pro::SoundMgr::distance (Sint32 iChannel=-1, Uint8 iDistance=0) |
Set the distance of a channel. | |
Sint32 | CRM64Pro::SoundMgr::position (Sint32 iChannel=-1, Sint16 iAngle=0, Uint8 iDistance=0) |
Set the position of a channel. | |
Sint32 | CRM64Pro::SoundMgr::loadFromFile (const string &sFile, const string &sName="") |
Load a sound from an external file. | |
Sint32 | CRM64Pro::SoundMgr::load (const string &sFileCDC, const string &sName) |
Load a sound stored in a CDC file. | |
Sint32 | CRM64Pro::SoundMgr::load (const Sint32 idCDC, const string &sName) |
Load a sound stored in a CDC file. | |
Sint32 | CRM64Pro::SoundMgr::remove (const Sint32 idCDC, const string &sName) |
Remove a sound stored in a CDC file. | |
Sint32 | CRM64Pro::SoundMgr::exist (Sint32 idCDC, const string &sName) |
Check if a sound is stored in a CDC file. | |
Sint32 CRM64Pro::Sound::info | ( | Sint32 | iMode = 0 | ) |
Request Sound object information.
For displaying the information, it uses the default log.
iMode | unused for the time being. |
Sint32 CRM64Pro::Sound::getName | ( | string & | sName | ) |
Get the name.
sName | a string containing the Sound object name. |
Uint32 CRM64Pro::Sound::getID | ( | ) |
Get the ID.
Sint32 CRM64Pro::Sound::info | ( | string * | sType, |
AudioInfo * | AI | ||
) |
Get Sound object information.
sType | an string pointer filled in with sound type. If nullptr is passed, the method ignores the retrieving of this value. |
AI | a pointer to an AudioInfo struct. If nullptr is passed, the method ignores the retrieving of this struct. |
Sint32 CRM64Pro::Sound::play | ( | Sint32 | iChannel = -1 , |
Sint32 | iLoop = 0 |
||
) |
Play a sound.
iChannel | Mixing channel used for the sound play. -1 will use the first free channel and it is set by default. |
iLoop | number of sound playing loops. By default is set to 0. 0 plays the sound just once, 1 twice and -1 plays it forever. |
Sint32 CRM64Pro::Sound::fadeIn | ( | Sint32 | iTime = 1000 , |
Sint32 | iChannel = -1 , |
||
Sint32 | iLoop = 0 |
||
) |
Play a sound with a fade in effect.
iTime | time for fading in the sound, in milliseconds. By default is set to 1000ms. |
iChannel | Mixing channel used for the sound play. -1 will use the first free channel and it is set by default. |
iLoop | number of sound playing loops. By default is set to 0. 0 plays the sound just once, 1 twice and -1 plays it forever. |
Sint32 CRM64Pro::Sound::saveToFile | ( | const string & | sFile | ) |
Export the Sound to an external file.
sFile | string containing the [directory]+filename. The extension, if present, is removed and the right extension is automatically added. If the file already exists, it will be overwritten. Directory separators '\' and '/' are supported. |
Sint32 CRM64Pro::Sound::save | ( | const string & | sFileCDC | ) |
Save the Sound in to a CDC file.
If the Sound already exists on the CDC, it will be overwritten.
sFileCDC | string containing the [directory]+filename+[extension]. Directory separators '\' and '/' are supported. |
Sint32 CRM64Pro::Sound::save | ( | Sint32 | idCDC | ) |
Sint32 CRM64Pro::SoundMgr::info | ( | Sint32 | iMode = 0 | ) |
Request Sound Manager information.
For displaying the information, it uses the default log.
iMode | -1 for displaying only Manager information. 0 for displaying Manager and all Objects information. This is the default value. idSnd for displaying Manager and given Sound id information. |
Sint32 CRM64Pro::SoundMgr::close | ( | Sint32 | idSnd = 0 | ) |
Close and destroy a sound.
idSnd | 0 (default value) for closing all sound or the Sound id. As the Sound Manager has the ability of sharing a Sound id, if the sound is shared, it will not be removed till the last owner call this method. |
Sint32 CRM64Pro::SoundMgr::getNum | ( | ) |
Get number of loaded objects.
Sint32 CRM64Pro::SoundMgr::setName | ( | Sint32 | idSnd, |
const string & | sName | ||
) |
Change the object name.
idSnd | Sound id. |
sName | The name to give to the sound e.g. 'mySound'. The object name must be unique and with a maximum size of 64 characters or will be truncated. |
Sound * CRM64Pro::SoundMgr::get | ( | Sint32 | idSnd = 0 | ) |
Get a pointer to the sound using its handler.
By default it returns the first sound loaded.
idSnd | Sound id. |
Sint32 CRM64Pro::SoundMgr::stop | ( | Sint32 | iChannel | ) |
Stop sound playing in a channel.
iChannel | Mixing channel where the sound is being played. -1 will affect all channels. |
Sint32 CRM64Pro::SoundMgr::pause | ( | Sint32 | iChannel | ) |
Pause sound playing in a channel.
iChannel | Mixing channel where the sound is being played. -1 will affect all channels. |
Sint32 CRM64Pro::SoundMgr::resume | ( | Sint32 | iChannel | ) |
Resume sound playing in a channel.
iChannel | Mixing channel where the sound is being played. -1 will affect all channels. |
Sint32 CRM64Pro::SoundMgr::status | ( | Sint32 | iChannel | ) |
Get the sound status on a given channel.
iChannel | Mixing channel where the sound is being played. -1 will affect all channels. |
C64_STATUS_DISABLED | channel is not playing any sound. |
C64_STATUS_ENABLED | channel is playing a sound. |
C64_STATUS_PAUSED | channel playing is paused. |
Sint32 CRM64Pro::SoundMgr::fadeOut | ( | Sint32 | iChannel, |
Sint32 | iTime = 1000 |
||
) |
Sound fade out effect in a channel.
iChannel | Mixing channel where the sound is being played. -1 will affect all channels. |
iTime | time for fading out the sound, in milliseconds. By default is set to 1000ms. |
Sint32 CRM64Pro::SoundMgr::panning | ( | Sint32 | iChannel = -1 , |
Uint8 | iLeft = 255 , |
||
Uint8 | iRight = 255 |
||
) |
Set the panning of a channel.
iChannel | Mixing channel where the sound is being played. -1 will affect all channels, even the reserved for music playback. By default, it is set to -1. |
iLeft | left channel value ranging from 0 (quietest) to 255 (loudest). By default, it is set to 255. |
iRight | right channel value ranging from 0 (quietest) to 255 (loudest). By default, it is set to 255. |
Sint32 CRM64Pro::SoundMgr::distance | ( | Sint32 | iChannel = -1 , |
Uint8 | iDistance = 0 |
||
) |
Set the distance of a channel.
iChannel | Mixing channel where the sound is being played. -1 will affect all channels, even the reserved for music playback. By default, it is set to -1. |
iDistance | an integer from 0 to 255 that specifies the location of the sound in relation to the listener. 0 is overlapping the listener and 255 is as far away as possible. A good step value is 8. By default, it is set to 0. |
Sint32 CRM64Pro::SoundMgr::position | ( | Sint32 | iChannel = -1 , |
Sint16 | iAngle = 0 , |
||
Uint8 | iDistance = 0 |
||
) |
Set the position of a channel.
iChannel | Mixing channel where the sound is being played. -1 will affect all channels, even the reserved for music playback. By default, it is set to -1. |
iAngle | an integer from 0 to 360 that specifies the location of the sound in relation to the listener. 0 is due north and rotates clockwise as the value increases. By default, it is set to -1. |
iDistance | an integer from 0 to 255 that specifies the location of the sound in relation to the listener. 0 is overlapping the listener and 255 is as far away as possible. A good step value is 8. By default, it is set to 0. |
Sint32 CRM64Pro::SoundMgr::loadFromFile | ( | const string & | sFile, |
const string & | sName = "" |
||
) |
Load a sound from an external file.
The Sound Manager has the ability of sharing ids based on the name as the key, so before trying to load a new one, it checks if it is already loaded for sharing it.
sFile | string containing the [directory]+filename+[extension]. Directory separators '\' and '/' are supported. |
sName | the image object name. By default, it is set to empty to use the filename (without extension) for setting the object name. The object name must be unique and with a maximum size of 64 characters or will be truncated. |
Sint32 CRM64Pro::SoundMgr::load | ( | const string & | sFileCDC, |
const string & | sName | ||
) |
Load a sound stored in a CDC file.
The Sound Manager has the ability of sharing ids based on the name as the key, so before trying to load a new one, it checks if it is already loaded for sharing it.
sFileCDC | string containing the [directory]+filename. Directory separators '\' and '/' are supported. |
sName | string with the sound name (maximum size of 64 characters). |
Sint32 CRM64Pro::SoundMgr::load | ( | const Sint32 | idCDC, |
const string & | sName | ||
) |
Load a sound stored in a CDC file.
The Sound Manager has the ability of sharing ids based on the name as the key, so before trying to load a new one, it checks if it is already loaded for sharing it.
idCDC | CDC id. |
sName | string with the sound name (maximum size of 64 characters). |
Sint32 CRM64Pro::SoundMgr::remove | ( | const Sint32 | idCDC, |
const string & | sName | ||
) |
Remove a sound stored in a CDC file.
idCDC | CDC id. |
sName | string with the sound name (maximum size of 64 characters). |
Sint32 CRM64Pro::SoundMgr::exist | ( | Sint32 | idCDC, |
const string & | sName | ||
) |
Check if a sound is stored in a CDC file.
idCDC | CDC id. |
sName | string with the sound name (maximum size of 64 characters). |