Gorilla.Audio.FMOD Unit Reference

Overview

The Gorilla.Audio.FMOD unit implements the Gorilla3D audio manager on top of the FMOD Core API. It provides TGorillaFMODAudioManager, the sound and channel group collections used at design-time, and the update thread that keeps the FMOD system alive.

Class Hierarchy

TGorillaAudioManager
  └── TGorillaFMODAudioManager

TGorillaSoundItem
  └── TGorillaFMODSoundItem

TCollectionItem
  └── TGorillaFMODChannelGroupItem

TOwnedCollection
  ├── TGorillaFMODSoundCollection
  ├── TGorillaFMODChannelGroupCollection
  └── TGorillaFMODEffectCollection

TThread
  └── FMOD auto update thread

Companion Units

Unit Content
Gorilla.Audio.FMOD.System FMOD system initialization, IGorillaFMODSystem
Gorilla.Audio.FMOD.Sound IGorillaFMODSound handles
Gorilla.Audio.FMOD.Channel IGorillaFMODChannel handles
Gorilla.Audio.FMOD.ChannelGroup IGorillaFMODChannelGroup handles
Gorilla.Audio.FMOD.SoundGroup Sound groups
Gorilla.Audio.FMOD.DSP DSP effect units
Gorilla.Audio.FMOD.Reverb3D 3D reverb zones
Gorilla.Audio.FMOD.Geometry Geometry based occlusion
Gorilla.Audio.FMOD.Custom Hooks for custom extensions
Android.JNI.FMOD JNI bridge used on Android

Enumerations

TGorillaFMODSoundMode

Value Description
Mode2D Non-positional sound
Mode3D Positional sound — evaluated while the sound is created

TGorillaFMODAudioManager

Class Variables

Member Description
UseProductiveLibrary Switches between the fmodL (logging, default) and fmod (productive) library. Set it in the .dpr before the first manager is created

Public Properties

Property Type Description
SystemObject IGorillaFMODSystem The raw FMOD system handle, for everything the component does not wrap
SoundRefs[Index] IGorillaFMODSound Sound handle by index
ChannelGroupRefs[Name] IGorillaFMODChannelGroup Channel group by name
IsPlaying LongBool True while any channel is playing

Published Properties

Property Type Default Description
AutoUpdate Boolean True Runs an internal thread calling Update()
AutoUpdateInterval Integer 33 Interval of that thread in ms
Sounds TGorillaFMODSoundCollection — Design-time collection of sounds
ChannelGroups TGorillaFMODChannelGroupCollection — Design-time collection of channel groups
ListenerPosition TPosition3D — Listener position
ListenerVelocity TPosition3D — Listener velocity, drives the Doppler effect
ListenerForward TPosition3D — Listener forward direction
ListenerUp TPosition3D — Listener up direction
ListenerTarget TControl3D — Control the listener follows automatically
ListenerUpdateInterval Integer — Interval the target is polled with
AutoUpdateListenerForward Boolean — Whether the forward vector follows the target too

Public Methods

Method Description
Update() Updates the FMOD system — every frame, or leave AutoUpdate on
Set3DListener(AAttr, ...) Sets the complete listener attribute set at once
ClearSounds() Removes all sound handles
LoadSoundFromFile(AFilename) Loads a sound handle from file
LoadSoundIntfFromFile(AFilename) Same, returns the IGorillaFMODSound
LoadSoundFromStream(AStream) Loads from a stream, completely into memory
LoadSoundFromStream(AMemStream) Loads from a memory stream, supports streaming
LoadSoundIntfFromStream(...) Stream variants returning the FMOD interface
CreateSoundItem(AName) Creates an empty item for the two step creation
LoadSoundItemFromFile(AFilename) Loads and returns a TGorillaFMODSoundItem
LoadSoundItemFromStream(...) Stream variants
GetSoundItem(AHandle) Item by backend handle or by IGorillaFMODSound
GetSoundItemByFilename(AFilename) Item by file name
PlaySound(AIndex) Plays by index, returns an FMOD channel handle
PlaySound(ASound) Plays a specific sound handle
StopAllChannels() Stops every channel
ClearAllChannels() Stops and releases every channel

TGorillaFMODSoundItem

Derives from TGorillaSoundItem and exposes the FMOD channel feature set.

Public Properties

Property Type Description
Reference IGorillaFMODSound The FMOD sound handle
ChannelGroupRef IGorillaFMODChannelGroup The group this sound plays in
Channel IGorillaFMODChannel The channel currently used
AudioManager TGorillaFMODAudioManager Owning manager
PlaybackPosition / PlaybackLength UInt32 Position and length in ms

Published Properties

Property Type Description
FileName TFileName Audio file
Mode TGorillaFMODSoundMode 2D or 3D — read while the sound is created
ChannelGroup String Name of the channel group
Loop Boolean Looped playback
LoopCount Int32 Number of loops, -1 = endless
AutoStart Boolean Starts automatically once the manager is loaded
Volume Single Channel volume
Pitch Single Playback pitch
Mute Boolean Mutes this sound
Frequency Single Playback rate in Hz; negative values play non-streamed sounds backwards
Priority Int32 0 (most important) … 256, default 128
PositionInMilliseconds UInt32 Seek position
VolumeRamp Boolean Smooths abrupt volume changes
LowPassGain Single Gain of the low pass applied by occlusion and reverb
FadeIn / FadeOut Single Fade durations
AntiFatigue Boolean Tiny random volume variation, so a repeated sample stops sounding identical
AntiFatigueLevel Integer Strength of that variation, 0..100
FadeInMinVol, FadeInMaxVol, FadeOutMinVol, FadeOutMaxVol Single Range the anti-fatigue variation works in
Delay TGorillaFMODDelay Scheduling
DelayDSPClockStart, DelayDSPClockEnd UInt64 Sample accurate start and end
DelayStopChannels Boolean Whether the delayed end stops the channel
Position3D TPosition3D 3D position
Velocity3D TPosition3D 3D velocity
MinMax3DDistance TPosition Minimum and maximum attenuation distance
Cone3DSettings TPosition3D Inner angle, outer angle, outer volume
Effects TGorillaFMODEffectCollection DSP effects attached to this sound
OnPlay, OnPause, OnStop TNotifyEvent Playback events

Public Methods

Method Description
IsAvailable() True when the FMOD handle exists
IsPlaying(), Play(), Pause(), Resume(), Stop() Playback control
LoadFromStream(AStream) Loads audio data into an item created by CreateSoundItem()
AttachEffects() / DetachEffects() Switches the whole effect chain on and off
Supports3DAudio() True
Set3DAudio(AEnabled) Switches Mode — before the data is loaded
Set3DDistance(AMin, AMax) Sets MinMax3DDistance

TGorillaFMODChannelGroupItem

Member Type Description
Reference IGorillaFMODChannelGroup The FMOD channel group handle
DisplayName String Name the group is addressed by

Channel groups are the FMOD buses: assign a sound to a group by name and control volume, muting and effects for everything in it at once.

Update Thread

The auto update thread keeps the FMOD system updated so 3D positions, streaming and virtual voices stay correct.

Property Default Description
AudioManager — The manager to update
Interval 33 Update interval in ms

Enable it through TGorillaFMODAudioManager.AutoUpdate. Switch it off when your render loop calls Update() itself.

Deployment

The FMOD binaries ship under <installation>\lib\fmod\. The logging build (fmodL / fmodL64) is the default and has to be copied into the IDE binary folder for design-time support. Set UseProductiveLibrary := true for release builds. FMOD is a commercial product of Firelight Technologies — https://www.fmod.com/licensing.

See Also