FMExAudio Class
This class is a simple container for audio data. FMExAudio instances are passed to FMExAudioPlayer or FMExAudioPlayer3D objects which play and manipulate the sound.
Important: Use the FolderItem.OpenAsFMExAudio class extension or the FMEx.CreateAudio method to create a new FMExAudio instance. This class cannot be constructed using the New keyword.
Important: You must successfully initialize FMOD Ex via the FMEx.StartUp method before creating FMExAudio objects. Also note that all existing FMExAudio instances become invalidated after calling FMEx.ShutDown. Please see the Restarting FMOD Ex section for details on how to properly restart FMOD Ex should the need arise.
Note: The FMExAudio class is ideal for short audio samples which may playback multiple times simultaneously (game sound effects for example). The FMExStream class is better suited for long-format compressed audio such music or narration.
Properties
-
ByteLength As Integer
Returns the total number of bytes in the audio data. -
Channels As Integer
Returns the number of channels in the audio data. E.g. a mono sound will return 1 channel, a stereo sound will return 2, etc. -
Depth As Integer
Returns the bit depth of the audio data. Depth is bits per sample, per channel. Typical values are 8, 16, 24, or 32. -
Duration As Integer
Returns the total duration of the audio in milliseconds when played back at its default frequency. -
Format As Integer
Returns the audio data's format, which describes the bit layout.
Possible return values: -
Frequency As Integer
Returns the audio's native sample frequency in Hz. E.g. CD audio runs in realtime at 44100 Hz. -
Handle As Integer
Mostly for internal use. Returns the FMOD_SOUND handle which can be used in custom declare statements. -
SampleLength As Integer
Methods
-
LockData ( offset As Integer, length As Integer, ByRef dataPtr1 As Ptr, ByRef dataPtr2 As Ptr, ByRef len1 As Integer, ByRef len2 As Integer )
Used to read or write the raw PCM audio data. This fills dataPtr1 with the pointer to the start of the data from the given offset, and fills len1 with the number of bytes dataPtr1 contains. dataPtr2 and len2 are similarly filled in if the requested length (in bytes) wraps past the end of the sound file. Note that this function cannot be used to resize the audio data.
Important: You must call UnlockData when you are finished with the data to relinquish control back to FMOD Ex. -
SetLoopPoints ( loopstart As Integer, loopend As Integer, usems As Boolean = False )
Sets loop points which FMOD Ex will use when looping the audio rather simply looping the entire waveform. If the optional usems parameter is True, loopstart and loopend are positions in milliseconds, otherwise they are sample offsets.
Note: Loop markers saved in WAV files are automatically recognized and used as loop points by FMOD Ex. -
UnlockData
This must be called after any calls to the LockData function to relinquish control of the audio data back to FMOD Ex.