Color legend plain property method event
Owns the output device, the mix, the reverb bus and every emitter.
A class. The quick start guide shows it in context, with code.
Names are colored by what they are: a property, a method or an event; values and fields keep the plain color.
Properties
AirSoundAbsorptionCoefficient →
float · Static. How much the air absorbs, in dB per meter. 0.005 by default. Distance effects use it when their LoudnessDb is set.
EmittersVersion →
int · Read-only. Changes whenever emitters are added, removed or cleared, so cached emitter references can be looked up again.
HearingMinimumDb →
float · Static. The level below which nothing is heard, in dB. 0 by default. Distance effects use it when their LoudnessDb is set.
IsHrtfDataLoaded →
bool · Read-only. Whether an HRTF data set is loaded. Without one, spatial effects pass sound through.
IsInitialized →
bool · Read-only. Whether an output device is open and playing the mix. false while the manager picks a new device, and when no device could be opened.
ListenerForward →
Vector3 · The direction the listener faces, normalized.
ListenerPosition →
Vector3 · The position of the listener in the world. Setting one listener property at a time updates every emitter each time, so prefer SetListenerData.
ListenerRight →
Vector3 · The listener’s right direction, normalized.
ListenerUp →
Vector3 · The listener’s up direction, normalized.
MasterVolume →
float · The gain of the whole mix, from 0 to 1. Set by the constructor, 1 by default.
MhrFilePath →
string · Read-only. The file the loaded data set came from, null when it is the embedded set or none is loaded.
MmDeviceName →
string · Read-only. The name of the output device, as Windows shows it. null while there is none.
ReverbBusCutoffHz →
float · How bright the reverb tail is, from 20 to 20 000 Hz. Reads 0 until set.
ReverbBusRoomSize →
float · The reverb time of the bus: seconds for the tail to fade by 60 dB, from 0.05 to 6. Reads 0 until set.
ReverbBusWet →
float · How much of the final mix is reverb, from 0 to 1; the rest is the dry mix. 0 by default.
WaveFormat →
WaveFormat · Read-only. The format of the mix: 32-bit float, two channels, 48 kHz. Every clip is converted to it.
Methods
AudioManager() →
AudioManager(string mhrFilePath = null, float initialMasterVolume = 1.0f) · Creates the mix, opens the default output device and loads an HRTF data set: the file at the path, or the embedded set when the path is null or can’t be read.
| Parameter | Type | Description |
|---|---|---|
mhrFilePath |
string |
The HRTF data set file (.mhr) to load, as TryLoadMhrFile loads it; null loads the embedded set. Default: null. |
initialMasterVolume |
float |
The MasterVolume to start with, from 0 to 1; a value outside is clamped. Default: 1.0f. |
ClearAudioCache() →
ClearAudioCache() · Static. Empties the cache of decoded clips. Emitters keep the clips they hold; the next TryAddAudio of a file decodes it again.
ClearEmitters() →
ClearEmitters() · Removes and disposes every emitter.
Dispose() →
Dispose() · Stops the output and disposes every emitter. Later calls do nothing.
PauseAll() →
PauseAll() · Pause on every emitter, for a pause menu.
PlayAll() →
PlayAll() · Play on every emitter.
SetListenerData() →
SetListenerData(Vector3 position, Vector3 forward, Vector3 up, Vector3 right) · Sets the whole listener pose at once, so each spatial effect works out its new direction once instead of once per vector. Call it every frame the listener moves.
| Parameter | Type | Description |
|---|---|---|
position |
Vector3 |
The position of the listener in the world, usually the camera’s. |
forward |
Vector3 |
The direction the listener faces, normalized. |
up |
Vector3 |
The listener’s up direction, normalized. |
right |
Vector3 |
The listener’s right direction, normalized. |
StopAll() →
StopAll() · Stop on every emitter.
TryAddAudioToEmitter() →
TryAddAudioToEmitter(string emitterName, string pathToAudio) · TryAddAudio on the emitter of that name.
| Parameter | Type | Description |
|---|---|---|
emitterName |
string |
The Name of the emitter. |
pathToAudio |
string |
The WAV or Ogg Vorbis file to add. |
TryAddEffectToEmitter() →
TryAddEffectToEmitter(string emitterName, AudioEffectTypes type, out BaseAudioEffect effect) · TryAddAudioEffect on the emitter of that name.
| Parameter | Type | Description |
|---|---|---|
emitterName |
string |
The Name of the emitter. |
type |
AudioEffectTypes |
The kind of effect to create. |
effect |
out BaseAudioEffect |
The new effect, or null when the method returns false. |
TryAddEmitter() →
TryAddEmitter(string name, AudioEmitterTypes type, out IAudioEmitter emitter) · Creates an emitter under a name, starting from the current listener pose. false for an empty name or one that is taken.
| Parameter | Type | Description |
|---|---|---|
name |
string |
The emitter’s Name, which the manager’s other methods find it by. It must not be empty or taken. |
type |
AudioEmitterTypes |
Whether the emitter decodes its clips into memory once (Cached) or from disk while they play (Streaming). |
emitter |
out IAudioEmitter |
The new emitter, or null when the method returns false. |
TryClearEmitterAudios() →
TryClearEmitterAudios(string emitterName) · ClearAudios on the emitter of that name.
| Parameter | Type | Description |
|---|---|---|
emitterName |
string |
The Name of the emitter. |
TryClearEmitterEffects() →
TryClearEmitterEffects(string emitterName) · ClearAudioEffects on the emitter of that name.
| Parameter | Type | Description |
|---|---|---|
emitterName |
string |
The Name of the emitter. |
TryGetEffectById() →
TryGetEffectById(string emitterName, Guid effectId, out BaseAudioEffect effect) · TryGetAudioEffect on the emitter of that name.
| Parameter | Type | Description |
|---|---|---|
emitterName |
string |
The Name of the emitter. |
effectId |
Guid |
The Id of the effect. |
effect |
out BaseAudioEffect |
The effect, or null when there is no emitter of that name or it has no effect with that Id. |
TryGetEmitterByName() →
TryGetEmitterByName(string name, out IAudioEmitter audioEmitter) · Finds an emitter by its name.
| Parameter | Type | Description |
|---|---|---|
name |
string |
The Name to look for. |
audioEmitter |
out IAudioEmitter |
The emitter, or null when there is none of that name. |
TryLoadMhrFile() →
TryLoadMhrFile(string path) · Loads an HRTF data set for every spatial effect: the file at the path, or the embedded set when the path is null or can’t be opened. false when the file isn’t a valid data set; no set is loaded then.
| Parameter | Type | Description |
|---|---|---|
path |
string |
The HRTF data set file (.mhr) to load; null loads the embedded set. |
TryPauseEmitter() →
TryPauseEmitter(string name) · Pause on the emitter of that name.
| Parameter | Type | Description |
|---|---|---|
name |
string |
The Name of the emitter. |
TryPlayEmitter() →
TryPlayEmitter(string name) · Play on the emitter of that name.
| Parameter | Type | Description |
|---|---|---|
name |
string |
The Name of the emitter. |
TryRemoveAudioFromEmitter() →
TryRemoveAudioFromEmitter(string emitterName, string pathToAudio) · TryRemoveAudio on the emitter of that name.
| Parameter | Type | Description |
|---|---|---|
emitterName |
string |
The Name of the emitter. |
pathToAudio |
string |
The path the clip was added with. |
TryRemoveEffectFromEmitter() →
TryRemoveEffectFromEmitter(string emitterName, BaseAudioEffect effect) · TryRemoveAudioEffect on the emitter of that name.
| Parameter | Type | Description |
|---|---|---|
emitterName |
string |
The Name of the emitter. |
effect |
BaseAudioEffect |
The effect to remove, one of that emitter’s. |
TryRemoveEffectFromEmitter(string emitterName, Guid effectId) · The same, by the effect’s Id.
| Parameter | Type | Description |
|---|---|---|
emitterName |
string |
The Name of the emitter. |
effectId |
Guid |
The Id of the effect to remove. |
TryRemoveEmitter() →
TryRemoveEmitter(string name) · Takes an emitter out of the mix and disposes it.
| Parameter | Type | Description |
|---|---|---|
name |
string |
The Name of the emitter. |
TryStopEmitter() →
TryStopEmitter(string name) · Stop on the emitter of that name.
| Parameter | Type | Description |
|---|---|---|
name |
string |
The Name of the emitter. |
Update() →
Update(float elapsedSeconds) · Advances every emitter: refreshes its State, runs its loop pause and measures its Doppler speeds. Also picks a new output device after a device change. Call it once per frame.
| Parameter | Type | Description |
|---|---|---|
elapsedSeconds |
float |
The time since the last call, in seconds, which times the emitters’ loop pauses and Doppler speeds. |
Events
OnMmDeviceChanged →
() · The manager has picked the output device again after a change, whether or not it found one. Raised on a thread-pool thread, or through the synchronization context of the thread that called Update when it has one, as in a WinForms or WPF tool.