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.
notifications
Notifications
:schedule_eos
- mixer will sendend_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
Element options
Passed via struct Membrane.LiveAudioMixer.t/0
prevent_clipping
boolean()
Default value:
false
Defines how the mixer should act in the case when an overflow happens.- If true, the wave will be scaled down, so a peak will become the maximal
value of the sample in the format. See
Membrane.AudioMixer.ClipPreventingAdder
. - If false, overflow will be clipped to the maximal value of the sample in
the format. See
Membrane.AudioMixer.Adder
.
- If true, the wave will be scaled down, so a peak will become the maximal
value of the sample in the format. See
native_mixer
boolean()
Default value:
false
The value determines if mixer should use NIFs for mixing audio. Only clip preventing version of native mixer is available. SeeMembrane.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 discardedStart 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 iflatency
is set to nil.
pads
Pads
input
:input
Accepted formats:
%RawAudio{sample_format: sample_format}
when sample_format in [:s8, :s16le, :s16be, :s24le, :s24be, :s32le, :s32be]
Direction: | :input |
Availability: | :on_request |
Flow control: | :auto |
Pad options:
offset
Time.non_neg()
Default value:
0
Offset of the input audio at the pad.
output
:output
Accepted formats:
RawAudio
Direction: | :output |
Availability: | :always |
Flow control: | :auto |
Link to this section Summary
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