Torque2D Reference

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

- Namespace List
- Namespace Members

Classes | Typedefs | Enumerations | Functions
SoundEngine Namespace Reference

## Classes
class | BackgroundTrackMgr
class | OpenALThread
class | SoundEngineEffect

## Typedefs
typedef ALvoid AL_APIENTRY(* | alBufferDataStaticProcPtr) (const ALint bid, ALenum format, ALvoid *data, ALsizei size, ALsizei freq)
typedef ALvoid AL_APIENTRY(* | alcMacOSXMixerOutputRateProcPtr) (const ALdouble value)

## Enumerations
enum | { kSoundEngineErrUnitialized = 1, kSoundEngineErrInvalidID = 2, kSoundEngineErrFileNotFound = 3, kSoundEngineErrInvalidFileFormat = 4, kSoundEngineErrDeviceNotFound = 5 }

## Functions
OSStatus | SoundEngine_Initialize (Float32 inMixerOutputRate)
OSStatus | SoundEngine_Teardown ()
OSStatus | SoundEngine_SetMasterVolume (Float32 inValue)
OSStatus | SoundEngine_SetListenerPosition (Float32 inX, Float32 inY, Float32 inZ)
OSStatus | SoundEngine_SetListenerGain (Float32 inValue)
OSStatus | SoundEngine_LoadBackgroundMusicTrack (const char *inPath, Boolean inAddToQueue, Boolean inLoadAtOnce)
OSStatus | SoundEngine_UnloadBackgroundMusicTrack ()
OSStatus | SoundEngine_StartBackgroundMusic ()
OSStatus | SoundEngine_StopBackgroundMusic (Boolean inStopAtEnd)
OSStatus | SoundEngine_SetBackgroundMusicVolume (Float32 inValue)
bool | LoadSoundFile (const char *inFilePath, UInt32 *outEffectID)
ALvoid | alBufferDataStaticProc (const ALint bid, ALenum format, ALvoid *data, ALsizei size, ALsizei freq)
ALvoid | alcMacOSXMixerOutputRateProc (const ALdouble value)
OSStatus | OpenFile (const char *inFilePath, AudioFileID &outAFID)
OSStatus | LoadFileDataInfo (const char *inFilePath, AudioFileID &outAFID, AudioStreamBasicDescription &outFormat, UInt64 &outDataSize)
void | CalculateBytesForTime (AudioStreamBasicDescription &inDesc, UInt32 inMaxPacketSize, Float64 inSeconds, UInt32 *outBufferSize, UInt32 *outNumPackets)
Boolean | FormatIsEqual (AudioStreamBasicDescription x, AudioStreamBasicDescription y)

## Typedef Documentation

typedef ALvoid AL_APIENTRY(* alBufferDataStaticProcPtr) (const ALint bid, ALenum format, ALvoid *data, ALsizei size, ALsizei freq)

typedef ALvoid AL_APIENTRY(* alcMacOSXMixerOutputRateProcPtr) (const ALdouble value)

## Enumeration Type Documentation

anonymous enum

Enumerator
kSoundEngineErrUnitialized |
kSoundEngineErrInvalidID |
kSoundEngineErrFileNotFound |
kSoundEngineErrInvalidFileFormat |
kSoundEngineErrDeviceNotFound |

## Function Documentation

ALvoid SoundEngine::alBufferDataStaticProc | ( | const ALint | bid,
|  | ALenum | format,
|  | ALvoid * | data,
|  | ALsizei | size,
|  | ALsizei | freq
| ) |  |

ALvoid SoundEngine::alcMacOSXMixerOutputRateProc | ( | const ALdouble | value | ) |

void SoundEngine::CalculateBytesForTime | ( | AudioStreamBasicDescription & | inDesc,
|  | UInt32 | inMaxPacketSize,
|  | Float64 | inSeconds,
|  | UInt32 * | outBufferSize,
|  | UInt32 * | outNumPackets
| ) |  |

Boolean SoundEngine::FormatIsEqual | ( | AudioStreamBasicDescription | x,
|  | AudioStreamBasicDescription | y
| ) |  |

OSStatus SoundEngine::LoadFileDataInfo | ( | const char * | inFilePath,
|  | AudioFileID & | outAFID,
|  | AudioStreamBasicDescription & | outFormat,
|  | UInt64 & | outDataSize
| ) |  |

bool SoundEngine::LoadSoundFile | ( | const char * | inFilePath,
|  | UInt32 * | outEffectID
| ) |  |

OSStatus SoundEngine::OpenFile | ( | const char * | inFilePath,
|  | AudioFileID & | outAFID
| ) |  |

OSStatus SoundEngine::SoundEngine_Initialize | ( | Float32 | inMixerOutputRate | ) |

SoundEngine_Initialize Initializes and sets up the sound engine. Calling after a previous initialize will reset the state of the SoundEngine, with all previous effects and music tracks erased. Note: This is not required, loading an effect or background track will initialize as necessary.

Parameters

  inMixerOutputRate | & nbsp; A Float32 that represents the output sample rate of the mixer unit. Setting this to 0 will use the default rate (the sample rate of the device)

Returns
  A OSStatus indicating success or failure.

OSStatus SoundEngine::SoundEngine_LoadBackgroundMusicTrack | ( | const char * | inPath,
|  | Boolean | inAddToQueue,
|  | Boolean | inLoadAtOnce
| ) |  |

SoundEngine_LoadBackgroundMusicTrack Tells the background music player which file to play

Parameters

  inPath | & nbsp; The absolute path to the file to play.
  inAddToQueue | & nbsp; If true, file will be added to the current background music queue. If false, queue will be cleared and only loop the specified file.
  inLoadAtOnce | & nbsp; If true, file will be loaded completely into memory. If false, data will be streamed from the file as needed. For games without large memory pressure and/or small background music files, this can save memory access and improve power efficiency

Returns
  A OSStatus indicating success or failure.

OSStatus SoundEngine::SoundEngine_SetBackgroundMusicVolume | ( | Float32 | inValue | ) |

SoundEngine_SetBackgroundMusicVolume Sets the volume for the background music player

Parameters

  inValue | & nbsp; A Float32 that represents the level. The range is between 0.0 and 1.0 (inclusive).

Returns
  A OSStatus indicating success or failure.

OSStatus SoundEngine::SoundEngine_SetListenerGain | ( | Float32 | inValue | ) |

SoundEngine_SetListenerGain Sets the gain of the listener. Must be >= 0.0

Parameters

  inValue | & nbsp; A Float32 that represents the listener's gain

Returns
  A OSStatus indicating success or failure.

OSStatus SoundEngine::SoundEngine_SetListenerPosition | ( | Float32 | inX,
|  | Float32 | inY,
|  | Float32 | inZ
| ) |  |

SoundEngine_SetListenerPosition Sets the position of the listener in the 3D space

Parameters

  inX | & nbsp; A Float32 that represents the listener's position along the X axis.
  inY | & nbsp; A Float32 that represents the listener's position along the Y axis.
  inZ | & nbsp; A Float32 that represents the listener's position along the Z axis.

Returns
  A OSStatus indicating success or failure.

OSStatus SoundEngine::SoundEngine_SetMasterVolume | ( | Float32 | inValue | ) |

SoundEngine_SetMasterVolume Sets the overall volume of all sounds coming from the process

Parameters

  inValue | & nbsp; A Float32 that represents the level. The range is between 0.0 and 1.0 (inclusive).

Returns
  A OSStatus indicating success or failure.

OSStatus SoundEngine::SoundEngine_StartBackgroundMusic | ( |  | ) |

SoundEngine_StartBackgroundMusic Tells the background music player to start playing.

Returns
  A OSStatus indicating success or failure.

OSStatus SoundEngine::SoundEngine_StopBackgroundMusic | ( | Boolean | inStopAtEnd | ) |

SoundEngine_StopBackgroundMusic Tells the background music player to stop playing.

Parameters

  inAddToQueue | & nbsp; If true, playback will stop when all tracks have completed. If false, playback will stop immediately.

Returns
  A OSStatus indicating success or failure.

OSStatus SoundEngine::SoundEngine_Teardown | ( |  | ) |

SoundEngine_Teardown Tearsdown the sound engine.

Returns
  A OSStatus indicating success or failure.

OSStatus SoundEngine::SoundEngine_UnloadBackgroundMusicTrack | ( |  | ) |

SoundEngine_UnloadBackgroundMusicTrack Tells the background music player to release all resources and stop playing.

Returns
  A OSStatus indicating success or failure.