Skip to content

AAudioMixer#

Manages audio players and mixes them into one sound stream.

Header:#include <AUI/Audio/AAudioMixer.h>
CMake:aui_link(my_target PUBLIC aui::audio)

Detailed Description#

Experimental Feature

This API is experimental. Experimental APIs are likely to contain bugs, might be changed or removed in the future.

The mixer sums the output of all IAudioPlayers which are currently playing and clamps the result. It is driven by the platform audio backend: IAudioPlayer::play adds the player to the mixer, pause and stop remove it. Applications normally don't use the mixer directly.

Players that reach the end of their stream (and are not looping) or throw while being read are removed and notified with IAudioPlayer::finished.

Public Methods#

addSoundSource#


void AAudioMixer::addSoundSource(aui::non_null<_<IAudioPlayer> > s)

Add new sound source for mixing

Arguments
s
New sound source

readSoundData#


std::size_t AAudioMixer::readSoundData(std::span<std::byte> destination)

Write mixed audio data into buffer.

Arguments
destination
Pre-allocated buffer to write into
Returns
Number of bytes written

removeSoundSource#


void AAudioMixer::removeSoundSource(aui::non_null<_<IAudioPlayer> > s)

Remove sound source if it is represented in list of added sound sources, otherwise do nothing

Arguments
s
Sound source to remove