| CRM64Pro GDK v0.18.0 A free cross-platform game development kit built on top of SDL 3.0

Loading...
Searching...
No Matches
Audio Track
Audio modules

## Description

Audio Track Manager and AudioTrack objects for sound effects and music playback [v26.06.1].

### Overview

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 high polyphony (limited by CPU/RAM and the mixer/device capacity).

### Key features

- Unified audio object: Handles both short SFX and long music streams transparently
- Tag categorization: Tracks are assigned a category tag (Music, SFX, Voice, Custom) allowing group operations like "Stop all SFX" or "Fade out Music"
- Hierarchical volume: Final Output Volume = Master Gain * Category Gain
- Editor support: Optional raw data persistence for saving/exporting audio assets

### AudioTrack actions

Playback | Play (supports multiple overlapping instances), stop, pause and resume
Transitions | Fade out and fade in on a given time
Playback control | Pitch/speed, repeat playback, loop points and seeking active playback
Effects | Volume, panning, spatial distance and angular position

### Loading strategies

Choose the appropriate loading strategy based on your audio content type and performance requirements:

Preload (RAM) | Best for SFX. Decodes the entire source to memory for low-latency playback. Limited to INT32_MAX source bytes (2 GiB)
Stream (Disk) | Best for Music and very large files. Decodes chunks from external files on-demand to save memory

CDC AudioTrack resources and memory buffers use preload/RAM loading logic. CDC streaming is not supported.

### Supported audio formats

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

### Manager type

This is a sharing manager: it can share an AudioTrack ID with 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 AudioTrack ID. Control methods (stop/volume) affect all instances sharing this ID
Unique instance | Request via `load(..., bForceNew = true)`. Creates a standalone object with independent control while efficiently sharing the underlying decoded/preloaded audio resource when the source key matches

### Naming security

Resource names are restricted to prevent collisions with system assets. The characters '#' and '@' are reserved for internal engine use. Any attempt to create or rename a resource starting with these characters will be rejected (returning a negative error code).

### Best practices

- Always initialize the audio system via ConfigMgr::audioInit() or ConfigMgr::load() before using the Audio Track Manager
- Leverage category tags (Music, SFX, Voice, Custom) for efficient group control operations
- Consider the hierarchical volume model when setting levels: category and master gains are multiplied
- Request unique instances when you need independent playback control over the same audio asset
- Access the manager exclusively through Main::audioTrackMgr()

Note
  The Audio Track Manager is a singleton, automatically created once Main is instantiated. You can get a reference to this manager using Main::audioTrackMgr() method.
  The Audio Track Manager is automatically released when Main::terminate() is called. At this time, any resource still loaded will be released, avoiding resource leaks.
  AudioTrack objects are created through AudioTrackMgr::loadFromFile(), AudioTrackMgr::load(), or AudioTrackMgr::loadFromBuffer(); AudioTrackMgr::create() is intentionally unavailable because an empty AudioTrack has no playable source.

## 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 : Sint32 { CRM64Pro::ATT_MUSIC = 1 , CRM64Pro::ATT_SFX , CRM64Pro::ATT_VOICE , CRM64Pro::ATT_CUSTOM }
| Audio track category tag for grouping and batch operations. One value must be selected; values are not bitmask flags. More...
enum | CRM64Pro::eAudioType : Sint32 { 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 : Sint32 { CRM64Pro::ALM_AUTO = 0 , CRM64Pro::ALM_PRELOAD = 1 , CRM64Pro::ALM_STREAM = 2 }
| Audio loading strategy. More...

## Functions
bool | CRM64Pro::AudioTrack::info (Sint32 iMode=0) override
| Request AudioTrack information.
const string & | CRM64Pro::AudioTrack::getName () const override
| Get the name.
Sint32 | CRM64Pro::AudioTrack::getID () const override
| Get the ID.
bool | CRM64Pro::AudioTrack::getInfo (string *sType, AudioInfo *pAI) const
| Get AudioTrack detailed information.
Sint32 | CRM64Pro::AudioTrack::play (Sint32 iRepeats=0)
| Play the track.
Sint32 | CRM64Pro::AudioTrack::fadeIn (Sint32 iTimeMS=1000, Sint32 iRepeats=0)
| Play the track with a fade-in effect.
bool | CRM64Pro::AudioTrack::fadeOut (Sint32 iTimeMS=1000)
| Fade out all instances of this track to silence, then stop.
bool | CRM64Pro::AudioTrack::stop ()
| Immediately stop all instances of this track.
bool | CRM64Pro::AudioTrack::pause ()
| Pause all instances of this track.
bool | CRM64Pro::AudioTrack::resume ()
| Resume all instances of this track.
ePlaybackStatus | CRM64Pro::AudioTrack::status () const
| Get the playback status.
Sint32 | CRM64Pro::AudioTrack::getPlaybackPosition () const
| Get the current playback position.
bool | CRM64Pro::AudioTrack::seek (Sint32 iTimeMS)
| Seek the active playback instance.
bool | CRM64Pro::AudioTrack::setPitch (float fPitch)
| Set Pitch (Frequency Ratio).
float | CRM64Pro::AudioTrack::getPitch () const
| Get current pitch property.
bool | CRM64Pro::AudioTrack::setPanning (Uint8 iLeft, Uint8 iRight)
| Set Stereo Panning.
bool | CRM64Pro::AudioTrack::getPanning (Uint8 *iLeft, Uint8 *iRight) const
| Get stereo panning.
bool | CRM64Pro::AudioTrack::setLoopPoints (double dStartSec, double dEndSec)
| Set Loop Points.
bool | CRM64Pro::AudioTrack::getLoopPoints (double *dStartSec, double *dEndSec) const
| Get loop points.
bool | CRM64Pro::AudioTrack::setSpatialDistance (Uint8 iDistance)
| Set spatial distance attenuation.
Uint8 | CRM64Pro::AudioTrack::getSpatialDistance () const
| Get spatial distance attenuation.
bool | CRM64Pro::AudioTrack::setSpatialPosition (Sint16 iAngle, Uint8 iDistance)
| Set spatial position.
bool | CRM64Pro::AudioTrack::getSpatialPosition (Sint16 *iAngle, Uint8 *iDistance) const
| Get spatial position.
bool | CRM64Pro::AudioTrack::setTag (eAudioTrackTag eTag)
| Set audio tag category.
eAudioTrackTag | CRM64Pro::AudioTrack::getTag () const
| Get audio tag category.
Sint32 | CRM64Pro::AudioTrack::saveToFile (const string &sFile)
| Export the AudioTrack to an external file.
Sint32 | CRM64Pro::AudioTrack::save (const string &sCDCFile, const string &sResourceName="")
| Save the AudioTrack into a CDC file.
Sint32 | CRM64Pro::AudioTrack::save (Sint32 idCDC, const string &sResourceName="")
| Save the AudioTrack into a CDC file.
bool | CRM64Pro::AudioTrackMgr::info (Sint32 iMode=0) override
| Request AudioTrack Manager information.
Sint32 | CRM64Pro::AudioTrackMgr::close (Sint32 idAudio=0) override
| Close and destroy an AudioTrack.
Sint32 | CRM64Pro::AudioTrackMgr::getCount () const override
| Get number of loaded objects.
Sint32 | CRM64Pro::AudioTrackMgr::setName (Sint32 idAudio, const string &sName) override
| Change the object name.
AudioTrack * | CRM64Pro::AudioTrackMgr::get (Sint32 idAudio)
| Get a pointer to the AudioTrack using its handle.
bool | CRM64Pro::AudioTrackMgr::stopAll ()
| Immediately stop all active audio tracks.
bool | CRM64Pro::AudioTrackMgr::fadeOutAll (Sint32 iTimeMS=1000)
| Fade out all active audio tracks to silence, then stop.
bool | CRM64Pro::AudioTrackMgr::pauseAll ()
| Pause all active audio tracks.
bool | CRM64Pro::AudioTrackMgr::resumeAll ()
| Resume all paused audio tracks.
bool | CRM64Pro::AudioTrackMgr::stopTag (eAudioTrackTag eTag)
| Stop all tracks with the given audio track tag.
bool | CRM64Pro::AudioTrackMgr::fadeOutTag (eAudioTrackTag eTag, Sint32 iTimeMS=1000)
| Fade out all tracks with the given audio track tag.
bool | CRM64Pro::AudioTrackMgr::pauseTag (eAudioTrackTag eTag)
| Pause all tracks with the given audio track tag.
bool | CRM64Pro::AudioTrackMgr::resumeTag (eAudioTrackTag eTag)
| Resume all tracks with the given audio track tag.
bool | CRM64Pro::AudioTrackMgr::setKeepSourceData (bool bKeep)
| Set the global policy for keeping raw source data in memory.
bool | 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, bool bForceNew=false)
| Load an AudioTrack from an external file.
Sint32 | CRM64Pro::AudioTrackMgr::load (const string &sCDCFile, const string &sName, bool bForceNew=false)
| Load an AudioTrack from a CDC file (by file name).
Sint32 | CRM64Pro::AudioTrackMgr::load (Sint32 idCDC, const string &sName, bool bForceNew=false)
| Load an AudioTrack from a CDC file (by ID).
Sint32 | CRM64Pro::AudioTrackMgr::loadFromBuffer (const 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.
bool | CRM64Pro::AudioTrackMgr::exists (Sint32 idCDC, const string &sName) const
| Check if an AudioTrack is stored in a CDC file.
bool | CRM64Pro::AudioTrackMgr::exists (const string &sCDCFile, const string &sName) const
| Check if an AudioTrack is stored in a CDC file.

## Enumeration Type Documentation

## ◆ eAudioTrackTag

enum CRM64Pro::eAudioTrackTag : Sint32

Audio track category tag for grouping and batch operations. One value must be selected; values are not bitmask flags.

Enumerator
ATT_MUSIC | Background music track.
ATT_SFX | Sound effect track.
ATT_VOICE | Voice/dialogue track.
ATT_CUSTOM | Custom user-defined track type.

## ◆ eAudioType

enum CRM64Pro::eAudioType : Sint32

Audio codec/format type.

Enumerator
AT_NONE | No type or uninitialized.
AT_WAV | WAV, RIFF, AIFF, or VOC audio type.
AT_MOD | Module audio type (MOD, XM, IT, etc.).
AT_OGG | OGG Vorbis audio type.
AT_MP3 | MP3 audio type.
AT_FLAC | FLAC audio type.
AT_UNKNOWN | Unknown or unsupported type.

## ◆ eAudioLoadMode

enum CRM64Pro::eAudioLoadMode : Sint32

Audio loading strategy.

Enumerator
ALM_AUTO | Automatically select based on audio type.
ALM_PRELOAD | Preload entire audio into memory (best for SFX).
ALM_STREAM | Stream audio from file on-demand (best for music).

## Function Documentation

## ◆ info() [1/2]

bool CRM64Pro::AudioTrack::info | ( | Sint32 | iMode = 0 | ) |
| override

Request AudioTrack information.

Writes information to the default log.

Parameters

  iMode | Reserved for future use. Pass 0.

Returns
  true on success, or false on failure.

## ◆ getName()

const string & CRM64Pro::AudioTrack::getName | ( |  | ) | const
| override

Get the name.

Returns
  The object name.

## ◆ getID()

Sint32 CRM64Pro::AudioTrack::getID | ( |  | ) | const
| override

Get the ID.

Returns
  Object ID.

## ◆ getInfo()

bool CRM64Pro::AudioTrack::getInfo | ( | string * | sType,
|  | AudioInfo * | pAI ) const

Get AudioTrack detailed information.

Parameters

  sType | a string pointer filled with the input file extension. If nullptr, this value is not retrieved.
  pAI | a pointer to an AudioInfo struct. If nullptr, this struct is not retrieved.

Returns
  true on success, or false on failure.

## ◆ play()

Sint32 CRM64Pro::AudioTrack::play | ( | Sint32 | iRepeats = 0 | ) |

Play the track.

Parameters

  iRepeats | Number of extra repeats after the first play. 0 plays once, -1 repeats forever.

Returns
  0 on success, or a negative error code on failure.

## ◆ fadeIn()

Sint32 CRM64Pro::AudioTrack::fadeIn | ( | Sint32 | iTimeMS = 1000,
|  | Sint32 | iRepeats = 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.

Parameters

  iTimeMS | Time in milliseconds for the fade-in effect. 0 for instant playback.
  iRepeats | Number of extra repeats after the first play. 0 plays once, -1 repeats forever.

Returns
  0 on success, or a negative error code on failure.

## ◆ fadeOut()

bool CRM64Pro::AudioTrack::fadeOut | ( | Sint32 | iTimeMS = 1000 | ) |

Fade out all instances of this track to silence, then stop.

Parameters

  iTimeMS | Time in milliseconds for the fade-out effect.

Returns
  true on success, or false on failure.

## ◆ stop()

bool CRM64Pro::AudioTrack::stop | ( |  | ) |

Immediately stop all instances of this track.

Returns
  true on success, or false on failure.

## ◆ pause()

bool CRM64Pro::AudioTrack::pause | ( |  | ) |

Pause all instances of this track.

Returns
  true on success, or false on failure.

## ◆ resume()

bool CRM64Pro::AudioTrack::resume | ( |  | ) |

Resume all instances of this track.

Returns
  true on success, or false on failure.

## ◆ status()

ePlaybackStatus CRM64Pro::AudioTrack::status | ( |  | ) | const

Get the playback status.

Returns
  ::PS_STOPPED when no playback instance is active, ::PS_PLAYING when playback is active, or ::PS_PAUSED when playback is paused.

## ◆ getPlaybackPosition()

Sint32 CRM64Pro::AudioTrack::getPlaybackPosition | ( |  | ) | const

Get the current playback position.

Retrieves the current time position of the active primary playback instance.

Returns
  The position in milliseconds, or -1 if the track is not playing or invalid.

## ◆ seek()

bool CRM64Pro::AudioTrack::seek | ( | Sint32 | iTimeMS | ) |

Seek the active playback instance.

Seeks the active primary playback instance to a specific time in the audio track.

Parameters

  iTimeMS | The position in milliseconds to seek to.

Returns
  true on success, or false if no active primary playback instance exists or seeking fails.

## ◆ setPitch()

bool 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.

Parameters

  fPitch | 1.0f = Normal, 0.5f = Half speed, 2.0f = Double speed.

Returns
  true on success, or false on failure.

## ◆ getPitch()

float CRM64Pro::AudioTrack::getPitch | ( |  | ) | const

Get current pitch property.

Returns
  The current pitch value.

## ◆ setPanning()

bool 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.

Parameters

  iLeft | 0-255.
  iRight | 0-255.

Returns
  true on success, or false on failure.

## ◆ getPanning()

bool CRM64Pro::AudioTrack::getPanning | ( | Uint8 * | iLeft,
|  | Uint8 * | iRight ) const

Get stereo panning.

Retrieves the stored panning values used for future playback. Spatial positioning takes precedence during playback when spatial distance is greater than 0.

Parameters

  iLeft | pointer to receive the left panning value [0,255].
  iRight | pointer to receive the right panning value [0,255].

Returns
  true on success, or false on failure.

## ◆ setLoopPoints()

bool CRM64Pro::AudioTrack::setLoopPoints | ( | double | dStartSec,
|  | double | dEndSec )

Set Loop Points.

Sets the loop region for future playbacks. Set both values below 0 to disable loop points. Otherwise the end value must be greater than the start value.

Note
  Loop point changes are applied when playback starts. Tracks already playing are not modified.

Parameters

  dStartSec | Start of loop in seconds.
  dEndSec | End of loop in seconds.

Returns
  true on success, or false on failure.

## ◆ getLoopPoints()

bool CRM64Pro::AudioTrack::getLoopPoints | ( | double * | dStartSec,
|  | double * | dEndSec ) const

Get loop points.

Retrieves the loop region used for future playbacks.

Parameters

  dStartSec | pointer to receive the loop start in seconds, or -1.0 when disabled.
  dEndSec | pointer to receive the loop end in seconds, or -1.0 when disabled.

Returns
  true on success, or false on failure.

## ◆ setSpatialDistance()

bool CRM64Pro::AudioTrack::setSpatialDistance | ( | Uint8 | iDistance | ) |

Set spatial 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.

Parameters

  iDistance | 0 (closest/loudest) to 255 (farthest/quietest).

Returns
  true on success, or false on failure.

## ◆ getSpatialDistance()

Uint8 CRM64Pro::AudioTrack::getSpatialDistance | ( |  | ) | const

Get spatial distance attenuation.

Returns
  The stored distance attenuation value [0,255].

## ◆ setSpatialPosition()

bool CRM64Pro::AudioTrack::setSpatialPosition | ( | Sint16 | iAngle,
|  | Uint8 | iDistance )

Set spatial position.

Sets the spatial audio position for future playbacks. If the track is currently playing, it updates the sound immediately. Simulates sound source direction relative to listener (at center).

Parameters

  iAngle | Angle in degrees. Values are normalized to [0,359] (0 = front, 90 = right, 180 = back, 270 = left).
  iDistance | Distance attenuation (0-255).

Returns
  true on success, or false on failure.

## ◆ getSpatialPosition()

bool CRM64Pro::AudioTrack::getSpatialPosition | ( | Sint16 * | iAngle,
|  | Uint8 * | iDistance ) const

Get spatial position.

Retrieves the stored spatial audio position. Spatial positioning takes precedence over panning during playback when distance is greater than 0.

Parameters

  iAngle | pointer to receive the normalized angle in degrees [0,359].
  iDistance | pointer to receive the distance attenuation [0,255].

Returns
  true on success, or false on failure.

## ◆ setTag()

bool CRM64Pro::AudioTrack::setTag | ( | eAudioTrackTag | eTag | ) |

Set audio tag category.

Updates the audio tag category (Music, SFX, Voice, Custom) and immediately re-calculates gain for active instances. This allows changing a track from "SFX" to "Music" and having it adopt the Music volume level.

Parameters

  eTag | The new tag category.

Returns
  true on success, or false on failure.

## ◆ getTag()

eAudioTrackTag CRM64Pro::AudioTrack::getTag | ( |  | ) | const

Get audio tag category.

Returns
  The current eAudioTrackTag.

## ◆ saveToFile()

Sint32 CRM64Pro::AudioTrack::saveToFile | ( | const string & | sFile | ) |

Export the AudioTrack to an external file.

Parameters

  sFile | string containing the [directory]+filename. Extension is automatically corrected.

Returns
  0 on success, or a negative error code on failure.

Note
  Only works if 'Keep Source Data' was enabled during load.

## ◆ save() [1/2]

Sint32 CRM64Pro::AudioTrack::save | ( | const string & | sCDCFile,
|  | const string & | sResourceName = "" )

Save the AudioTrack into a CDC file.

Parameters

  sCDCFile | Path to the CDC archive.
  sResourceName | Optional resource name to use in the CDC. If empty (default), uses the AudioTrack object's internal name.

Returns
  0 on success, or a negative error code on failure.

## ◆ save() [2/2]

Sint32 CRM64Pro::AudioTrack::save | ( | Sint32 | idCDC,
|  | const string & | sResourceName = "" )

Save the AudioTrack into a CDC file.

Parameters

  idCDC | CDC id.
  sResourceName | Optional resource name to use in the CDC. If empty (default), uses the AudioTrack object's internal name.

Returns
  0 on success, or a negative error code on failure.

Note
  Only works if 'Keep Source Data' was enabled during load.

## ◆ info() [2/2]

bool CRM64Pro::AudioTrackMgr::info | ( | Sint32 | iMode = 0 | ) |
| override

Request AudioTrack Manager information.

Writes manager information to the default log.

Parameters

  iMode | -1 to display only manager information. 0 (default) to display manager and all objects. A specific object ID displays manager information and only that object.

Returns
  true on success, or false on failure.

## ◆ close()

Sint32 CRM64Pro::AudioTrackMgr::close | ( | Sint32 | idAudio = 0 | ) |
| override

Close and destroy an AudioTrack.

Parameters

  idAudio | 0 (default) for closing all tracks, or a specific AudioTrack id. If playing, it will be stopped immediately.

Returns
  0 on success, or a negative error code on failure.

Note
  AudioTrackMgr object ownership methods, including load and close, are owner-thread only. Do not call them concurrently with get() or playback/control calls on the same objects.

## ◆ getCount()

Sint32 CRM64Pro::AudioTrackMgr::getCount | ( |  | ) | const
| override

Get number of loaded objects.

Returns
  the number of AudioTrack objects.

## ◆ setName()

Sint32 CRM64Pro::AudioTrackMgr::setName | ( | Sint32 | idAudio,
|  | const string & | sName )
| override

Change the object name.

Parameters

  idAudio | AudioTrack id.
  sName | The new name. Must be unique.

Returns
  0 on success, or a negative error code on failure.

## ◆ get()

AudioTrack * CRM64Pro::AudioTrackMgr::get | ( | Sint32 | idAudio | ) |

Get a pointer to the AudioTrack using its handle.

Parameters

  idAudio | AudioTrack id.

Returns
  Borrowed pointer to the AudioTrack object, or nullptr if not found.

Note
  The returned pointer must not be deleted. It remains valid until the AudioTrack is closed or AudioTrackMgr is reset or terminated.

## ◆ stopAll()

bool CRM64Pro::AudioTrackMgr::stopAll | ( |  | ) |

Immediately stop all active audio tracks.

Stops all playback on the mixer device.

Returns
  true on success, or false on failure.

## ◆ fadeOutAll()

bool CRM64Pro::AudioTrackMgr::fadeOutAll | ( | Sint32 | iTimeMS = 1000 | ) |

Fade out all active audio tracks to silence, then stop.

Parameters

  iTimeMS | Time in milliseconds for the fade-out effect. Default 1000ms.

Returns
  true on success, or false on failure.

## ◆ pauseAll()

bool CRM64Pro::AudioTrackMgr::pauseAll | ( |  | ) |

Pause all active audio tracks.

Returns
  true on success, or false on failure.

## ◆ resumeAll()

bool CRM64Pro::AudioTrackMgr::resumeAll | ( |  | ) |

Resume all paused audio tracks.

Returns
  true on success, or false on failure.

## ◆ stopTag()

bool CRM64Pro::AudioTrackMgr::stopTag | ( | eAudioTrackTag | eTag | ) |

Stop all tracks with the given audio track tag.

Iterates through all managed AudioTrack objects with exactly the given tag and stops them.

Parameters

  eTag | Single tag category to stop. Combined tag values are invalid.

Returns
  true if at least one matching track was stopped and all stop operations succeeded, or false otherwise.

## ◆ fadeOutTag()

bool CRM64Pro::AudioTrackMgr::fadeOutTag | ( | eAudioTrackTag | eTag,
|  | Sint32 | iTimeMS = 1000 )

Fade out all tracks with the given audio track tag.

Iterates through all managed AudioTrack objects with exactly the given tag and fades them out.

Parameters

  eTag | Single tag category to fade out. Combined tag values are invalid.
  iTimeMS | Time in milliseconds for the fade-out effect. Default 1000ms.

Returns
  true if at least one matching track was faded out and all fade-out operations succeeded, or false otherwise.

## ◆ pauseTag()

bool CRM64Pro::AudioTrackMgr::pauseTag | ( | eAudioTrackTag | eTag | ) |

Pause all tracks with the given audio track tag.

Iterates through all managed AudioTrack objects with exactly the given tag and pauses them.

Parameters

  eTag | Single tag category to pause. Combined tag values are invalid.

Returns
  true if at least one matching track was paused and all pause operations succeeded, or false otherwise.

## ◆ resumeTag()

bool CRM64Pro::AudioTrackMgr::resumeTag | ( | eAudioTrackTag | eTag | ) |

Resume all tracks with the given audio track tag.

Iterates through all managed AudioTrack objects with exactly the given tag and resumes them.

Parameters

  eTag | Single tag category to resume. Combined tag values are invalid.

Returns
  true if at least one matching track was resumed and all resume operations succeeded, or false otherwise.

## ◆ setKeepSourceData()

bool CRM64Pro::AudioTrackMgr::setKeepSourceData | ( | bool | bKeep | ) |

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().

Warning
  Enabling this increases memory usage significantly (original raw bytes + decoded/preloaded audio). It is recommended to enable this only for Editors/Tools, and keep it disabled (default) for Games.

Parameters

  bKeep | true to cache raw data, false to discard it.

Returns
  true on success, or false on failure.

## ◆ getKeepSourceData()

bool CRM64Pro::AudioTrackMgr::getKeepSourceData | ( |  | ) | const

Get the current policy for keeping raw source data.

Returns
  true if raw data is being cached, false otherwise.

## ◆ loadFromFile()

Sint32 CRM64Pro::AudioTrackMgr::loadFromFile | ( | const string & | sFile,
|  | const string & | sName = "",
|  | eAudioTrackTag | eTag = ATT_SFX,
|  | eAudioLoadMode | eMode = ALM_AUTO,
|  | bool | bForceNew = false )

Load an AudioTrack from an external file.

Parameters

  sFile | string containing [directory]+filename+[extension]. Directory separators '\' and '/' are supported.
  sName | Object name. If empty, filename is used (without extension). Must be shorter than 64 characters.
  eTag | The tag category (SFX, Music, etc).
  eMode | Loading strategy (Preload to RAM or Stream from disk).
  bForceNew | true to force a new object creation with a unique generated name, false to return the existing object ID when the name already exists.

Note
  ALM_AUTO streams compressed music formats (MP3, OGG, FLAC) and preloads other supported types. Preload mode keeps decoded audio in RAM and is limited to INT32_MAX source bytes (2 GiB).

Returns
  Greater than 0 on success (the AudioTrack id), or a negative error code on failure.

## ◆ load() [1/2]

Sint32 CRM64Pro::AudioTrackMgr::load | ( | const string & | sCDCFile,
|  | const string & | sName,
|  | bool | bForceNew = false )

Load an AudioTrack from a CDC file (by file name).

Parameters

  sCDCFile | Path to the CDC archive file.
  sName | Object name.
  bForceNew | true to force a new object creation with a unique generated name, false to return the existing object ID when the name already exists.

Returns
  Greater than 0 on success (the AudioTrack id), or a negative error code on failure.

Note
  Always uses ALM_PRELOAD (RAM) logic as streaming from a CDC archive is not supported. CDC audio resources are limited to INT32_MAX source bytes (2 GiB).

## ◆ load() [2/2]

Sint32 CRM64Pro::AudioTrackMgr::load | ( | Sint32 | idCDC,
|  | const string & | sName,
|  | bool | bForceNew = false )

Load an AudioTrack from a CDC file (by ID).

Parameters

  idCDC | CDC archive ID.
  sName | Object name stored in the archive.
  bForceNew | true to force a new object creation with a unique generated name, false to return the existing object ID when the name already exists.

Returns
  Greater than 0 on success (the AudioTrack id), or a negative error code on failure.

Note
  Always uses ALM_PRELOAD (RAM) logic as streaming from a CDC archive is not supported. CDC audio resources are limited to INT32_MAX source bytes (2 GiB).

## ◆ loadFromBuffer()

Sint32 CRM64Pro::AudioTrackMgr::loadFromBuffer | ( | const void * | pBuffer,
|  | Sint32 | iSize,
|  | const string & | sName,
|  | const string & | sFormat,
|  | eAudioTrackTag | eTag = ATT_SFX )

Load an AudioTrack from a raw memory buffer.

Parameters

  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).

Returns
  Greater than 0 on success (the AudioTrack id), or a negative error code on failure.

Note
  The buffer is copied internally. The user is responsible for the original buffer. Memory buffer audio uses preload/RAM logic and is limited to INT32_MAX source bytes (2 GiB).

## ◆ remove()

Sint32 CRM64Pro::AudioTrackMgr::remove | ( | Sint32 | idCDC,
|  | const string & | sName )

Remove an AudioTrack stored in a CDC file.

Parameters

  idCDC | CDC id.
  sName | string with the AudioTrack name (shorter than 64 characters).

Returns
  0 on success, or a negative error code on failure.

## ◆ exists() [1/2]

bool CRM64Pro::AudioTrackMgr::exists | ( | Sint32 | idCDC,
|  | const string & | sName ) const

Check if an AudioTrack is stored in a CDC file.

Parameters

  idCDC | CDC id.
  sName | string with the AudioTrack name (shorter than 64 characters).

Returns
  true if the resource is stored in the CDC file, or false otherwise. No error is reported.

Note
  It is normally used for checking if an audio track is present without throwing any error.

## ◆ exists() [2/2]

bool CRM64Pro::AudioTrackMgr::exists | ( | const string & | sCDCFile,
|  | const string & | sName ) const

Check if an AudioTrack is stored in a CDC file.

Parameters

  sCDCFile | Path to the CDC archive file.
  sName | string with the AudioTrack name (shorter than 64 characters).

Returns
  true if the resource is stored in the CDC file, or false otherwise. No error is reported.

Note
  It is normally used for checking if an audio track is present without throwing any error.