Final Platform Layer 0.9.8-beta
|
To initialize audio playback with default settings (Interleaved, 48 kHz, 2 Channels, signed 16-bit integer format), you have to set the fplInitFlags_Audio flag in the fplPlatformInit() call and ensure that audio is not disabled by a preprocessor directive FPL_NO_AUDIO.
Next is to specify the client user callback which gets invoked regularly when the audio device requires new samples to play.
This client callback can be set up in the fplAudioSettings::clientReadCallback field from the fplSettings::audio or changed by calling fplSetAudioClientReadCallback() :
You can change several audio settings (Sample rate, Number of Channels, Format, etc.) before initializing the audio playback like this:
By default, FPL uses the first available audio backend which is supported on your platform.
If you want to force FPL to use a certain audio backend, you can do this by changing the fplAudioSettings::backend field in the fplAudioSettings structure:
It is recommended to use the default fplAudioBackendType_Auto which uses the first supported audio backend.
By default, FPL starts the playback of audio samples automatically, but only when fplAudioSettings::clientReadCallback was set!
Also audio playback will be stopped when fplPlatformRelease() is called as well.
You can disable this behavior by changing the fields fplAudioSettings::startAuto and fplAudioSettings.stopAuto in the fplAudioSettings configuration respectively.
For manual control of start/stop playback of audio samples use the following functions:
There is no guarantee that you get the desired audio format you specified back!
You should always check the nativeAudioFormat in your client callback and convert/write the correct samples the audio device expects!
For more details see the page: Writing audio samples
If needed you can use fplSetDefaultAudioSettings() to fill in just the default video settings inside the fplAudioSettings structure.