Final Platform Layer 1.0.0
Loading...
Searching...
No Matches
Multi-Channel Audio (2.1 up to 7.1)

Default initialization

By default you don't have to setup anything in FPL, if your audio device supports multiple channels you can get the fplAudioChannelLayout and the number of channels from the fplAudioFormat.

fplSettings settings;
// ... your code here
}
fpl_common_api bool fplPlatformInit(const fplInitFlags initFlags, const fplSettings *initSettings)
Initializes the platform layer.
fpl_common_api void fplSetDefaultSettings(fplSettings *settings)
Resets the given settings container to default values for window, video, audio, etc.
@ fplInitFlags_Audio
Use asynchronous audio playback.
Stores settings, such as window, video, etc.

Setting an Audio Channel Layout

By default, FPL uses the native audio channel layout for your default sound device, but you can overwrite it by setting the fplAudioChannelLayout in the fplAudioSettings structure:

fplSettings settings;
fplAudioSettings &audioSettings = settings.audio;
// Forcing to use a 5.1 audio channel layout with 6 channels
audioSettings.layout = fplAudioChannelLayout_5_1;
// Or you can set the number of channels to 6 for 5.1 as well
audioSettings.channels = 6;
// ... your code here
}
@ fplAudioChannelLayout_5_1
5.1 Audio Channel Layout (5.1, 6 Channels: Front/Center/LFE/Side).
Stores audio settings, such as format, device info, callbacks, backend, etc.
fplAudioSettings audio
Audio settings.
Note
You have to call fplGetAudioChannelMap() to get the actual audio channel mapping table, which maps each audio channel to a fplAudioChannelType.

Channel Mapping

A channel map is a table of channel indices to a fplAudioChannelType.

If you have a fplAudioChannelLayout_Stereo or even fplAudioChannelLayout_Mono, you can simply use the default indices (0|1) or just zero for mono.

As soon as you have more than two channels, you have to get the fplAudioChannelMap from the current audio backend and map your source channel indices. You can get the current fplAudioChannelMap by calling fplGetAudioChannelMap().

This must be called, after the audio system has been initialized, either after fplPlatformInit() or after fplAudioInit().

if (fplGetAudioChannelMap(&channelMap)) {
// Do your own channel mapping from your source samples
}
fpl_common_api bool fplGetAudioChannelMap(fplAudioChannelMap *outMapping)
Gets the audio channels mapping table.
#define fplZeroInit
Initializes a struct to zero.
Stores the mapping of all audio channels to an audio speaker.