How to properly switch between multiple audio sources while playing
OPENSOURCE Manuel Huber
manuel.huber at opensource.tttech.com
Thu Apr 4 16:17:30 UTC 2019
On Thu, Apr 4, 2019 at 4:53 PM Nirbheek Chauhan wrote:
> On Thu, Apr 4, 2019 at 6:55 PM OPENSOURCE Manuel Huber
> <manuel.huber at opensource.tttech.com> wrote:
>> To simplify the use-case, I tried to only switch between two sine
>> tones (just to get a basic understanding).
>>
>> 1. Using input-selector and valve
>>
>> audiotestsrc1 -> valve1 -+
>> +-> input-selector -> alsasink
>> audiotestsrc2 -> valve2 -+
>>
>> I heard some click's and pop's when switching...
>>
>
> Have you tried audiomixer? You can use it as a 'seamless switcher' by
> muting one sinkpad and unmuting the other.
The question is, how can I handle the actual case when I use filesrc +
decodebin or playbin instead of audiotestsrc2. Would putting a valve
there allow me to have the file playback PAUSED or even in NULL state
while playing a tone?
The pipeline should be "hidden" behind a simple API that allows to
play a file (till the end) or play a tone for a specific duration (not
at the same time).
>
> If you get 'glitching' (due to silence in between) which can happen if
> you get unlucky w.r.t. scheduling between muting one and unmuting the
> other, you can use the gst controller API for scheduling both to
> happen at the same time. See crossfade_app_set_pad_volume_fade() in
> the example attached here:
> https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/issues/208
>
> You can also use a linear fade to do a 'cross-fade' instead of a hard
> switch.
>
It sounds like a good idea for "stopping" the playback of the sine
tone when the specified duration is over without introducing an ugly
click / pop noise. Thanks for pointing me already to a good example ;)
Thanks for the quick response.
More information about the gstreamer-devel
mailing list