Membrane.AudioMixer.ClipPreventingAdder (Membrane Audio Mix plugin v0.3.0) View Source
Module responsible for mixing audio tracks (all in the same format, with the same number of channels and sample rate). The result is a single path in the format mixed paths are encoded in. If overflow happens during mixing, a wave will be scaled down to the max sample value.
Description of the algorithm:
- Start with an empty queue
- Put merged values while the sign of the values remains the same
- If the sign of values changes or adder is flushed:
- If none of the values overflows limits of the format, convert the queued values to binary samples and return them
- Otherwise, scale down the queued values, so the peak of the wave will become maximal (minimal) allowed value, then convert it to binary samples and return them.
Link to this section Summary
Link to this section Types
Specs
t() :: %Membrane.AudioMixer.ClipPreventingAdder{ caps: Membrane.Caps.Audio.Raw.t(), is_wave_positive: boolean(), queue: [integer()], sample_size: integer() }