![]() |
CRM64Pro GDK v0.13.0
A free cross-platform game development kit built on top of SDL 3.0
|
Audio Track Manager and AudioTrack objects for sound effects and music playback [v25.12.0].
The Audio Track module provides a unified audio system for loading and playing both short sound effects and long music tracks. Once the audio system is initialized using ConfigMgr::audioInit() or ConfigMgr::load(), you can load audio from external files, memory buffers, or CDC archives.
There are no longer fixed "channels". Tracks are allocated dynamically as needed, allowing for virtually unlimited polyphony (limited only by CPU/RAM).
| Playback | Play (supports multiple overlapping instances), stop, pause and resume |
|---|---|
| Transitions | Fade out and fade in on a given time |
| Playback control | Pitch/speed, looping, seeking (for streams) |
| Effects | Volume, panning, 3D distance and angular position |
Choose the appropriate loading strategy based on your audio content type and performance requirements:
| Preload (RAM) | Best for SFX. Decodes entire file to memory for zero-latency playback |
|---|---|
| Stream (Disk) | Best for Music. Decodes chunks on-demand to save memory |
| Raw streams | AIFF, WAV and VOC |
|---|---|
| Compressed | FLAC, OGG and MP3 |
| Modules (52) | 669, abk, amf, arch, asylum, chip, coco, dbm, digi, dt, emod, far, flt, fnk, gal4, gal5, gdm, hmn, ice, imf, ims, it, liq, masi, masi16, mdl, med2, med3, med4, mfp, mgt, mmd1, mmd3, mod, mtm, muse, no, okt, pt3, ptm, rtm, s3m, sfx, st, stim, stm, stx, sym, ult, umx, xm, xmf |
This is a sharing manager: it has the ability of sharing an audio ID to a group of owners when they request to open an already opened object based on the name as the key.
| Default behavior | Returns a shared ID. Control methods (stop/volume) affect all instances sharing this ID |
|---|---|
| Unique instance | Request via load(..., iUnique=1). Creates a standalone object with independent control while efficiently sharing the underlying raw audio data in memory |
Classes | |
| struct | CRM64Pro::AudioInfo |
| Audio metadata information. More... | |
| class | CRM64Pro::AudioTrack |
| Audio Track object class. More... | |
| class | CRM64Pro::AudioTrackMgr |
| Audio Track Manager class. More... | |
Enumerations | |
| enum | CRM64Pro::eAudioTrackTag { CRM64Pro::ATT_MUSIC = 0x01 , CRM64Pro::ATT_SFX = 0x02 , CRM64Pro::ATT_VOICE = 0x04 , CRM64Pro::ATT_CUSTOM = 0x08 } |
| Audio track category tags for grouping and batch operations. More... | |
| enum | CRM64Pro::eAudioType { CRM64Pro::AT_NONE = 0 , CRM64Pro::AT_WAV = 1 , CRM64Pro::AT_MOD = 2 , CRM64Pro::AT_OGG = 3 , CRM64Pro::AT_MP3 = 4 , CRM64Pro::AT_FLAC = 5 , CRM64Pro::AT_UNKNOWN = 6 } |
| Audio codec/format type. More... | |
| enum | CRM64Pro::eAudioLoadMode { CRM64Pro::ALM_AUTO = 0 , CRM64Pro::ALM_PRELOAD = 1 , CRM64Pro::ALM_STREAM = 2 } |
| Audio loading strategy. More... | |
Functions | |
| Sint32 | CRM64Pro::AudioTrack::info (Sint32 iMode=0) |
| Request AudioTrack information. | |
| Sint32 | CRM64Pro::AudioTrack::getName (string &sName) |
| Get the name. | |
| Uint32 | CRM64Pro::AudioTrack::getID () |
| Get the ID. | |
| Sint32 | CRM64Pro::AudioTrack::getInfo (string *sType, AudioInfo *pAI) const |
| Get AudioTrack detailed information. | |
| Sint32 | CRM64Pro::AudioTrack::play (Sint32 iLoop=0) |
| Play the track. | |
| Sint32 | CRM64Pro::AudioTrack::fadeIn (Sint32 iTimeMS=1000, Sint32 iLoop=0) |
| Play the track with a fade-in effect. | |
| Sint32 | CRM64Pro::AudioTrack::fadeOut (Sint32 iTimeMS=1000) |
| Fade out all instances of this track to silence, then stop. | |
| Sint32 | CRM64Pro::AudioTrack::stop () |
| Immediately stop all instances of this track. | |
| Sint32 | CRM64Pro::AudioTrack::pause () |
| Pause all instances of this track. | |
| Sint32 | CRM64Pro::AudioTrack::resume () |
| Resume all instances of this track. | |
| Sint32 | CRM64Pro::AudioTrack::getPosition () |
| Get the current playback position. | |
| Sint32 | CRM64Pro::AudioTrack::setPosition (Sint32 iTimeMS) |
| Set the playback position (Seek). | |
| Sint32 | CRM64Pro::AudioTrack::setPitch (float fPitch) |
| Set Pitch (Frequency Ratio). | |
| float | CRM64Pro::AudioTrack::getPitch () const |
| Get current pitch property. | |
| Sint32 | CRM64Pro::AudioTrack::setPanning (Uint8 iLeft, Uint8 iRight) |
| Set Stereo Panning. | |
| Sint32 | CRM64Pro::AudioTrack::setLoopPoints (double dStartSec, double dEndSec) |
| Set Loop Points. | |
| Sint32 | CRM64Pro::AudioTrack::setDistance (Uint8 iDistance) |
| Set 3D Distance Attenuation. | |
| Sint32 | CRM64Pro::AudioTrack::setPosition3D (Sint16 iAngle, Uint8 iDistance) |
| Set 3D Angular Position. | |
| Sint32 | CRM64Pro::AudioTrack::setTag (eAudioTrackTag eTag) |
| Set Track Tag category. | |
| eAudioTrackTag | CRM64Pro::AudioTrack::getTag () const |
| Get Track Tag category. | |
| Sint32 | CRM64Pro::AudioTrack::saveToFile (const string &sFile) |
| Export the AudioTrack to an external file. | |
| Sint32 | CRM64Pro::AudioTrack::save (const string &sFileCDC) |
| Save the AudioTrack into a CDC file. | |
| Sint32 | CRM64Pro::AudioTrack::save (Sint32 idCDC) |
| Save the AudioTrack into a CDC file. | |
| Sint32 | CRM64Pro::AudioTrackMgr::info (Sint32 iMode=0) |
| Request AudioTrack Manager information. | |
| Sint32 | CRM64Pro::AudioTrackMgr::close (Sint32 idAudio=0) |
| Close and destroy an AudioTrack. | |
| Sint32 | CRM64Pro::AudioTrackMgr::getNum () const |
| Get number of loaded objects. | |
| Sint32 | CRM64Pro::AudioTrackMgr::setName (Sint32 idAudio, const string &sName) |
| Change the object name. | |
| AudioTrack * | CRM64Pro::AudioTrackMgr::get (Sint32 idAudio=0) |
| Get a pointer to the AudioTrack using its handler. | |
| Sint32 | CRM64Pro::AudioTrackMgr::stopAll () |
| Immediately stop all active audio tracks. | |
| Sint32 | CRM64Pro::AudioTrackMgr::fadeOutAll (Sint32 iTimeMS=1000) |
| Fade out all active audio tracks to silence, then stop. | |
| Sint32 | CRM64Pro::AudioTrackMgr::pauseAll () |
| Pause all active audio tracks. | |
| Sint32 | CRM64Pro::AudioTrackMgr::resumeAll () |
| Resume all paused audio tracks. | |
| Sint32 | CRM64Pro::AudioTrackMgr::stopTag (eAudioTrackTag eTag) |
| Stop all tracks of a specific audio track tag category. | |
| Sint32 | CRM64Pro::AudioTrackMgr::fadeOutTag (eAudioTrackTag eTag, Sint32 iTimeMS=1000) |
| Fade out all tracks of a specific audio track tag category. | |
| Sint32 | CRM64Pro::AudioTrackMgr::pauseTag (eAudioTrackTag eTag) |
| Pause all tracks of a specific audio track tag category. | |
| Sint32 | CRM64Pro::AudioTrackMgr::resumeTag (eAudioTrackTag eTag) |
| Resume all tracks of a specific audio track tag category. | |
| void | CRM64Pro::AudioTrackMgr::setKeepSourceData (Sint32 iKeep) |
| Set the global policy for keeping raw source data in memory. | |
| Sint32 | CRM64Pro::AudioTrackMgr::getKeepSourceData () const |
| Get the current policy for keeping raw source data. | |
| Sint32 | CRM64Pro::AudioTrackMgr::loadFromFile (const string &sFile, const string &sName="", eAudioTrackTag eTag=ATT_SFX, eAudioLoadMode eMode=ALM_AUTO, Sint32 iUnique=0) |
| Load an AudioTrack from an external file. | |
| Sint32 | CRM64Pro::AudioTrackMgr::load (const string &sFileCDC, const string &sName, Sint32 iUnique=0) |
| Load an AudioTrack from a CDC file (by file name). | |
| Sint32 | CRM64Pro::AudioTrackMgr::load (Sint32 idCDC, const string &sName, Sint32 iUnique=0) |
| Load an AudioTrack from a CDC file (by ID). | |
| Sint32 | CRM64Pro::AudioTrackMgr::load (void *pBuffer, Sint32 iSize, const string &sName, const string &sFormat, eAudioTrackTag eTag=ATT_SFX) |
| Load an AudioTrack from a raw memory buffer. | |
| Sint32 | CRM64Pro::AudioTrackMgr::remove (Sint32 idCDC, const string &sName) |
| Remove an AudioTrack stored in a CDC file. | |
| Sint32 | CRM64Pro::AudioTrackMgr::exist (Sint32 idCDC, const string &sName) |
| Check if an AudioTrack is stored in a CDC file. | |
| enum CRM64Pro::eAudioType |
| Sint32 CRM64Pro::AudioTrack::info | ( | Sint32 | iMode = 0 | ) |
Request AudioTrack information.
Writes information to the default log.
| iMode | unused for the time being. |
| Sint32 CRM64Pro::AudioTrack::getName | ( | string & | sName | ) |
Get the name.
| sName | a string containing the Audio Track object name. |
| Uint32 CRM64Pro::AudioTrack::getID | ( | ) |
Get the ID.
| Sint32 CRM64Pro::AudioTrack::getInfo | ( | string * | sType, |
| AudioInfo * | pAI ) const |
Get AudioTrack detailed information.
| sType | a string pointer filled with the input file music extension. If nullptr, this value is not retrieved. |
| pAI | a pointer to an AudioInfo struct. If nullptr, this struct is not retrieved. |
| Sint32 CRM64Pro::AudioTrack::play | ( | Sint32 | iLoop = 0 | ) |
Play the track.
| iLoop | 0 = play once, -1 = infinite, >0 = specific number of loops. |
| Sint32 CRM64Pro::AudioTrack::fadeIn | ( | Sint32 | iTimeMS = 1000, |
| Sint32 | iLoop = 0 ) |
Play the track with a fade-in effect.
Creates a new hardware track, assigns the audio data, applies current properties (Gain, Pitch, Pan), and starts playback.
| iTimeMS | Time in milliseconds for the fade-in effect. 0 for instant playback. |
| iLoop | Number of loops. 0 = play once, -1 = infinite, >0 = specific number of additional loops. |
| Sint32 CRM64Pro::AudioTrack::fadeOut | ( | Sint32 | iTimeMS = 1000 | ) |
Fade out all instances of this track to silence, then stop.
| iTimeMS | Time in milliseconds for the fade-out effect. |
| Sint32 CRM64Pro::AudioTrack::stop | ( | ) |
Immediately stop all instances of this track.
| Sint32 CRM64Pro::AudioTrack::pause | ( | ) |
Pause all instances of this track.
| Sint32 CRM64Pro::AudioTrack::resume | ( | ) |
Resume all instances of this track.
| Sint32 CRM64Pro::AudioTrack::getPosition | ( | ) |
Get the current playback position.
Retrieves the current time position of the active track instance.
| Sint32 CRM64Pro::AudioTrack::setPosition | ( | Sint32 | iTimeMS | ) |
Set the playback position (Seek).
Jumps to a specific time in the audio track. If the track is currently playing, it seeks immediately.
| iTimeMS | The position in milliseconds to seek to. |
| Sint32 CRM64Pro::AudioTrack::setPitch | ( | float | fPitch | ) |
Set Pitch (Frequency Ratio).
Sets the pitch for future playbacks. If the track is currently playing, it updates the sound immediately.
| fPitch | 1.0f = Normal, 0.5f = Half speed, 2.0f = Double speed. |
| float CRM64Pro::AudioTrack::getPitch | ( | ) | const |
Get current pitch property.
| Sint32 CRM64Pro::AudioTrack::setPanning | ( | Uint8 | iLeft, |
| Uint8 | iRight ) |
Set Stereo Panning.
Sets panning for future playbacks. If the track is currently playing, it updates the sound immediately.
| iLeft | 0-255. |
| iRight | 0-255. |
| Sint32 CRM64Pro::AudioTrack::setLoopPoints | ( | double | dStartSec, |
| double | dEndSec ) |
Set Loop Points.
Sets loop region for future playbacks.
| dStartSec | Start of loop in seconds. |
| dEndSec | End of loop in seconds (or -1 for end of file). |
| Sint32 CRM64Pro::AudioTrack::setDistance | ( | Uint8 | iDistance | ) |
Set 3D Distance Attenuation.
Sets the distance simulation for future playbacks. If the track is currently playing, it updates the sound immediately. SDL_mixer's distance effect attenuates volume as distance increases.
| iDistance | 0 (closest/loudest) to 255 (farthest/quietest). |
| Sint32 CRM64Pro::AudioTrack::setPosition3D | ( | Sint16 | iAngle, |
| Uint8 | iDistance ) |
Set 3D Angular Position.
Sets the 3D position for future playbacks. If the track is currently playing, it updates the sound immediately. Simulates sound source direction relative to listener (at center).
| iAngle | Angle in degrees (0 = front, 90 = right, 180 = back, 270 = left). |
| iDistance | Distance attenuation (0-255). |
| Sint32 CRM64Pro::AudioTrack::setTag | ( | eAudioTrackTag | eTag | ) |
Set Track Tag category.
Updates the tag category (Music, SFX, Voice) and immediately re-calculates gain for active instance. This allows changing a track from "SFX" to "Music" and having it instantly adopt the Music volume level.
| eTag | The new track type. |
| eAudioTrackTag CRM64Pro::AudioTrack::getTag | ( | ) | const |
Get Track Tag category.
| Sint32 CRM64Pro::AudioTrack::saveToFile | ( | const string & | sFile | ) |
Export the AudioTrack to an external file.
| sFile | string containing the [directory]+filename. Extension is automatically corrected. |
| Sint32 CRM64Pro::AudioTrack::save | ( | const string & | sFileCDC | ) |
Save the AudioTrack into a CDC file.
| sFileCDC | Path to the CDC archive. |
| Sint32 CRM64Pro::AudioTrack::save | ( | Sint32 | idCDC | ) |
Save the AudioTrack into a CDC file.
| idCDC | CDC id. |
| Sint32 CRM64Pro::AudioTrackMgr::info | ( | Sint32 | iMode = 0 | ) |
Request AudioTrack Manager information.
Writes information to the default log.
| iMode | -1 for displaying only Manager information. 0 (default) for displaying Manager and all Objects information. |
| Sint32 CRM64Pro::AudioTrackMgr::close | ( | Sint32 | idAudio = 0 | ) |
Close and destroy an AudioTrack.
| idAudio | 0 (default) for closing all tracks, or a specific AudioTrack id. If playing, it will be stopped immediately. |
| Sint32 CRM64Pro::AudioTrackMgr::getNum | ( | ) | const |
Get number of loaded objects.
| Sint32 CRM64Pro::AudioTrackMgr::setName | ( | Sint32 | idAudio, |
| const string & | sName ) |
Change the object name.
| idAudio | AudioTrack id. |
| sName | The new name. Must be unique. |
| AudioTrack * CRM64Pro::AudioTrackMgr::get | ( | Sint32 | idAudio = 0 | ) |
Get a pointer to the AudioTrack using its handler.
| idAudio | AudioTrack id. |
| Sint32 CRM64Pro::AudioTrackMgr::stopAll | ( | ) |
Immediately stop all active audio tracks.
Stops all playback on the mixer device.
| Sint32 CRM64Pro::AudioTrackMgr::fadeOutAll | ( | Sint32 | iTimeMS = 1000 | ) |
Fade out all active audio tracks to silence, then stop.
| iTimeMS | Time in milliseconds for the fade-out effect. Default 1000ms. |
| Sint32 CRM64Pro::AudioTrackMgr::pauseAll | ( | ) |
Pause all active audio tracks.
| Sint32 CRM64Pro::AudioTrackMgr::resumeAll | ( | ) |
Resume all paused audio tracks.
| Sint32 CRM64Pro::AudioTrackMgr::stopTag | ( | eAudioTrackTag | eTag | ) |
Stop all tracks of a specific audio track tag category.
Iterates through all managed AudioTrack objects of the given tag category and stops them.
| eTag | The tag category to stop (Music, SFX, etc). |
| Sint32 CRM64Pro::AudioTrackMgr::fadeOutTag | ( | eAudioTrackTag | eTag, |
| Sint32 | iTimeMS = 1000 ) |
Fade out all tracks of a specific audio track tag category.
Iterates through all managed AudioTrack objects of the given tag category and fades them out.
| eTag | The tag category to fade out (Music, SFX, etc). |
| iTimeMS | Time in milliseconds for the fade-out effect. Default 1000ms. |
| Sint32 CRM64Pro::AudioTrackMgr::pauseTag | ( | eAudioTrackTag | eTag | ) |
Pause all tracks of a specific audio track tag category.
Iterates through all managed AudioTrack objects of the given tag category and pauses them.
| eTag | The tag category to pause. |
| Sint32 CRM64Pro::AudioTrackMgr::resumeTag | ( | eAudioTrackTag | eTag | ) |
Resume all tracks of a specific audio track tag category.
Iterates through all managed AudioTrack objects of the given tag category and resumes them.
| eTag | The tag category to resume. |
| void CRM64Pro::AudioTrackMgr::setKeepSourceData | ( | Sint32 | iKeep | ) |
Set the global policy for keeping raw source data in memory.
If enabled, subsequent load operations will cache the original raw bytes in RAM. This allows the use of AudioTrack::save() and AudioTrack::saveToFile().
| iKeep | 1 to cache raw data, 0 to discard it. Values <= 0 force disabled, values >= 1 force enabled. |
| Sint32 CRM64Pro::AudioTrackMgr::getKeepSourceData | ( | ) | const |
Get the current policy for keeping raw source data.
| Sint32 CRM64Pro::AudioTrackMgr::loadFromFile | ( | const string & | sFile, |
| const string & | sName = "", | ||
| eAudioTrackTag | eTag = ATT_SFX, | ||
| eAudioLoadMode | eMode = ALM_AUTO, | ||
| Sint32 | iUnique = 0 ) |
Load an AudioTrack from an external file.
| sFile | string containing [directory]+filename+[extension]. Directory separators '\' and '/' are supported. |
| sName | Object name. If empty, filename is used (without extension). Max 64 characters. |
| eTag | The tag category (SFX, Music, etc). |
| eMode | Loading strategy (Preload to RAM or Stream from disk). |
| iUnique | 1 forces a new object creation even if an object with this name exists. |
| Sint32 CRM64Pro::AudioTrackMgr::load | ( | const string & | sFileCDC, |
| const string & | sName, | ||
| Sint32 | iUnique = 0 ) |
Load an AudioTrack from a CDC file (by file name).
| sFileCDC | Path to the CDC archive file. |
| sName | Object name. |
| iUnique | 1 forces a new object creation even if an object with this name exists. |
| Sint32 CRM64Pro::AudioTrackMgr::load | ( | Sint32 | idCDC, |
| const string & | sName, | ||
| Sint32 | iUnique = 0 ) |
Load an AudioTrack from a CDC file (by ID).
| idCDC | CDC archive ID. |
| sName | Object name stored in the archive. |
| iUnique | 1 forces a new object creation. |
| Sint32 CRM64Pro::AudioTrackMgr::load | ( | void * | pBuffer, |
| Sint32 | iSize, | ||
| const string & | sName, | ||
| const string & | sFormat, | ||
| eAudioTrackTag | eTag = ATT_SFX ) |
Load an AudioTrack from a raw memory buffer.
| pBuffer | Pointer to the raw audio data (WAV, OGG, etc). |
| iSize | Size of the buffer in bytes. |
| sName | Object name. It will be used as source file name together with format. |
| sFormat | Audio format of the buffer (AIFF, WAV, VOC, OGG, FLAC, MP3, MOD, XM, S3M, etc). |
| eTag | The category tag (SFX, Music, etc). |
| Sint32 CRM64Pro::AudioTrackMgr::remove | ( | Sint32 | idCDC, |
| const string & | sName ) |
Remove an AudioTrack stored in a CDC file.
| idCDC | CDC id. |
| sName | string with the AudioTrack name (maximum size of 64 characters). |
| Sint32 CRM64Pro::AudioTrackMgr::exist | ( | Sint32 | idCDC, |
| const string & | sName ) |
Check if an AudioTrack is stored in a CDC file.
| idCDC | CDC id. |
| sName | string with the AudioTrack name (maximum size of 64 characters). |