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 Music module includes the Music Manager and Music objects.
Once the audio system is initialized using ConfigMgr::audioInit() or ConfigMgr::load(), you can use this manager for loading music files from external files or from a CDC file and play them.
There is a dedicated channel for the music playback and only one music can be played at a given time although you can change to play other one at anytime.
Actions that can be done on a music object:
Supported music formats:
Raw streams: WAV and VOC | |
Compressed streams: FLAC, Ogg and MP3 | |
Modules: 669, abc, amf, ams, dbm, dmf, dsm, far, gdm, it, mdl, med, mid, mod, mt2, mtm, okt, pat, psm, ptm, st3m, stm, ult and xm |
This is a sharing manager: it has the ability of sharing a music 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 music id, it will be effectively closed.
Only a single instance of the Music Manager exists which is created once Main is instantiated.
You can get a reference to this manager using Main::IMusicMgr() method.
Classes | |
class | CRM64Pro::Music |
Music Object class. More... | |
class | CRM64Pro::MusicMgr |
Music Manager class. More... | |
Functions | |
Sint32 | CRM64Pro::Music::info (Sint32 iMode=0) |
Request Music object information. | |
Sint32 | CRM64Pro::Music::getName (string &sName) |
Get the name. | |
Uint32 | CRM64Pro::Music::getID () |
Get the ID. | |
Sint32 | CRM64Pro::Music::info (string *sType, AudioInfo *AI) |
Get Music object information. | |
Sint32 | CRM64Pro::Music::play (Sint32 iLoop=0) |
Start playing music. | |
Sint32 | CRM64Pro::Music::fadeIn (Sint32 iTime=1000, Sint32 iLoop=0) |
Start playing music with a fade in effect. | |
Sint32 | CRM64Pro::Music::saveToFile (const string &sFile) |
Export the Music to an external file. | |
Sint32 | CRM64Pro::Music::save (const string &sFileCDC) |
Save the Music in to a CDC file. | |
Sint32 | CRM64Pro::Music::save (Sint32 idCDC) |
Save the Music in to a CDC file. | |
Sint32 | CRM64Pro::MusicMgr::info (Sint32 idMus=0) |
Request Music Manager information. | |
Sint32 | CRM64Pro::MusicMgr::close (Sint32 idMus=0) |
Close and destroy a music. | |
Sint32 | CRM64Pro::MusicMgr::getNum () |
Get number of loaded objects. | |
Sint32 | CRM64Pro::MusicMgr::setName (Sint32 idMus, const string &sName) |
Change the object name. | |
Music * | CRM64Pro::MusicMgr::get (Sint32 idMus=0) |
Get a pointer to the music using its handler. | |
Sint32 | CRM64Pro::MusicMgr::stop () |
Stop music playing. | |
Sint32 | CRM64Pro::MusicMgr::pause () |
Pause music playing. | |
Sint32 | CRM64Pro::MusicMgr::resume () |
Resume music playing. | |
Sint32 | CRM64Pro::MusicMgr::status () |
Get the music status. | |
Sint32 | CRM64Pro::MusicMgr::position (double dPosition) |
Set the current position in the music stream. | |
Sint32 | CRM64Pro::MusicMgr::fadeOut (Sint32 iTime=1000) |
Music fade out effect. | |
Sint32 | CRM64Pro::MusicMgr::loadFromFile (const string &sFile, const string &sName="") |
Load a music from an external file. | |
Sint32 | CRM64Pro::MusicMgr::load (const string &sFileCDC, const string &sName) |
Load a music stored in a CDC file. | |
Sint32 | CRM64Pro::MusicMgr::load (const Sint32 idCDC, const string &sName) |
Load a music stored in a CDC file. | |
Sint32 | CRM64Pro::MusicMgr::remove (const Sint32 idCDC, const string &sName) |
Remove a music stored in a CDC file. | |
Sint32 | CRM64Pro::MusicMgr::exist (Sint32 idCDC, const string &sName) |
Check if a music is stored in a CDC file. | |
Sint32 CRM64Pro::Music::info | ( | Sint32 | iMode = 0 | ) |
Request Music object information.
For displaying the information, it uses the default log.
iMode | unused for the time being. |
Sint32 CRM64Pro::Music::getName | ( | string & | sName | ) |
Get the name.
sName | a string containing the Music object name. |
Uint32 CRM64Pro::Music::getID | ( | ) |
Get the ID.
Sint32 CRM64Pro::Music::info | ( | string * | sType, |
AudioInfo * | AI | ||
) |
Get Music object information.
sType | an string pointer filled in with the input file music extension. 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::Music::play | ( | Sint32 | iLoop = 0 | ) |
Start playing music.
iLoop | number of music playing loops. By default is set to 0. 0 plays the music just once, 1 twice and -1 plays it forever. |
Sint32 CRM64Pro::Music::fadeIn | ( | Sint32 | iTime = 1000 , |
Sint32 | iLoop = 0 |
||
) |
Start playing music with a fade in effect.
iTime | time for fading in the music, in milliseconds. By default is set to 1000ms. |
iLoop | number of music playing loops. By default is set to 0. 0 plays the music just once, 1 twice and -1 plays it forever. |
Sint32 CRM64Pro::Music::saveToFile | ( | const string & | sFile | ) |
Export the Music 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::Music::save | ( | const string & | sFileCDC | ) |
Save the Music in to a CDC file.
If the Music already exists on the CDC, it will be overwritten.
sFileCDC | string containing the [directory]+filename+[extension]. Directory separators '\' and '/' are supported. |
Sint32 CRM64Pro::Music::save | ( | Sint32 | idCDC | ) |
Sint32 CRM64Pro::MusicMgr::info | ( | Sint32 | iMode = 0 | ) |
Request Music 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. idMus for displaying Manager and given Music id information. |
Sint32 CRM64Pro::MusicMgr::close | ( | Sint32 | idMus = 0 | ) |
Close and destroy a music.
idMus | 0 (default value) for closing all music or the Music id. As the Music Manager has the ability of sharing a Music id, if the music is shared, it will not be removed till the last owner call this method. |
Sint32 CRM64Pro::MusicMgr::getNum | ( | ) |
Get number of loaded objects.
Sint32 CRM64Pro::MusicMgr::setName | ( | Sint32 | idMus, |
const string & | sName | ||
) |
Change the object name.
idMus | Music id. |
sName | The name to give to the music e.g. 'myMusic'. The object name must be unique and with a maximum size of 64 characters or will be truncated. |
Music * CRM64Pro::MusicMgr::get | ( | Sint32 | idMus = 0 | ) |
Get a pointer to the music using its handler.
By default it returns the first music loaded.
idMus | Music id. |
Sint32 CRM64Pro::MusicMgr::stop | ( | ) |
Stop music playing.
Sint32 CRM64Pro::MusicMgr::pause | ( | ) |
Pause music playing.
Sint32 CRM64Pro::MusicMgr::resume | ( | ) |
Resume music playing.
Sint32 CRM64Pro::MusicMgr::status | ( | ) |
Get the music status.
C64_STATUS_DISABLED | music is not playing. |
C64_STATUS_ENABLED | music is playing. |
C64_STATUS_PAUSED | music playing is paused. |
Sint32 CRM64Pro::MusicMgr::position | ( | double | dPosition | ) |
Set the current position in the music stream.
dPosition | jump to this time position (in seconds). |
Sint32 CRM64Pro::MusicMgr::fadeOut | ( | Sint32 | iTime = 1000 | ) |
Music fade out effect.
iTime | time for fading out the music, in milliseconds. By default is set to 1000ms. |
Sint32 CRM64Pro::MusicMgr::loadFromFile | ( | const string & | sFile, |
const string & | sName = "" |
||
) |
Load a music from an external file.
The Music 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 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::MusicMgr::load | ( | const string & | sFileCDC, |
const string & | sName | ||
) |
Load a music stored in a CDC file.
The Music 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 music name (maximum size of 64 characters). |
Sint32 CRM64Pro::MusicMgr::load | ( | const Sint32 | idCDC, |
const string & | sName | ||
) |
Load a music stored in a CDC file.
The Music 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 music name (maximum size of 64 characters). |
Sint32 CRM64Pro::MusicMgr::remove | ( | const Sint32 | idCDC, |
const string & | sName | ||
) |
Remove a music stored in a CDC file.
idCDC | CDC id. |
sName | string with the music name (maximum size of 64 characters). |
Sint32 CRM64Pro::MusicMgr::exist | ( | Sint32 | idCDC, |
const string & | sName | ||
) |
Check if a music is stored in a CDC file.
idCDC | CDC id. |
sName | string with the music name (maximum size of 64 characters). |