View Source Membrane.LiveAudioMixer (Membrane Audio Mix plugin v0.16.0)

This element performs audio mixing for live streams.

Live Audio Mixer starts to mix audio after the first input pad is added or, if latency option is set to nil, when start_mixing notification is send. From this point, the mixer will produce an audio until :schedule_eos notification and :end_of_stream are received on all input pads.

Mixer mixes only raw audio (PCM), so some parser may be needed to precede it in pipeline.



  • :schedule_eos - mixer will send end_of_stream when it processes all input streams. After sending :schedule_eos mixer will raise if it gets a new input pad.

  • {:start_mixing, latency} - mixer will start mixing audio after latency (non_neg_integer()). Audio that will come before the notification will be buffered.

Input pads can have offset - it tells how much timestamps differ from mixer time.


Element options

Passed via struct Membrane.LiveAudioMixer.t/0

  • prevent_clipping


    Default value: false
    Defines how the mixer should act in the case when an overflow happens.

  • native_mixer


    Default value: false
    The value determines if mixer should use NIFs for mixing audio. Only clip preventing version of native mixer is available. See Membrane.AudioMixer.NativeAdder.

  • latency

    non_neg_integer() | nil

    Default value: 200 |> Membrane.Time.milliseconds()
    The value determines after what time the clock will start interval that mixes audio in real time. Latency is crucial to quality of output audio, the smaller the value, the more packets will be lost. But the bigger the value, the bigger the latency of stream.

    Audio Mixer allows starting mixing earlier with parent_notification :start_mixing. In this case, stream_format has to be passed through options.

    If notification :start_mixing is sent after mixing has started, the message will be discarded

    Start mixing manually:

    • set latency to nil
    • mixing has to be started manually by sending:start_mixing notification.
  • stream_format

    RawAudio.t() | nil

    Default value: nil
    The value defines a raw audio format of pads connected to the element. It should be the same for all the pads. It is necessary if latency is set to nil.





Accepted formats:

%RawAudio{sample_format: sample_format}
when sample_format in [:s8, :s16le, :s16be, :s24le, :s24be, :s32le, :s32be]
Flow control::auto

Pad options:

  • offset


    Default value: 0
    Offset of the input audio at the pad.



Accepted formats:

Flow control::auto

Link to this section Summary


Options for pad :input


Struct containing options for Membrane.LiveAudioMixer


Returns description of options available for this module

Link to this section Types

@type input_pad_opts() :: [{:offset, Membrane.Time.non_neg()}]

Options for pad :input

@type t() :: %Membrane.LiveAudioMixer{
  latency: non_neg_integer() | nil,
  native_mixer: boolean(),
  prevent_clipping: boolean(),
  stream_format: Membrane.RawAudio.t() | nil

Struct containing options for Membrane.LiveAudioMixer

Link to this section Functions

@spec options() :: keyword()

Returns description of options available for this module