crossfade: New example for crossfading audio tracks using audiomixer
@nirbheek
Submitted by Nirbheek Chauhan Link to original bug (#752762)
Description
Created attachment 307971
crossfade: New example for crossfading audio tracks using audiomixer
/*
- crossfade: An example application to play a list of audio files with
- cross-fade between each file.
- This example application uses the audiomixer element combined with
- GstController and pad probes to play a list of audio files in such a way that
- the audio is cross-faded while switching between files.
- Each file is played by a decoder bin inside each CrossfadeItem. This bin has
- a queue right before its srcpad which has a "max-size-time" of
- 2 * CROSSFADE_TIME_MS. When an EOS is detected on the sinkpad of this queue,
- the next CrossfadeItem is attached to audiomixer, the correct pad offset is
- set, and fadein/fadeout is scheduled using GstControlSources.
- A crossfade can also be scheduled immediately by switching to the next item
- "early" using crossfade_app_activate_next_item_early().
- The list of CrossfadeItems can be edited and added to dynamically; except the
- currently-playing item and the next one (which has been prepared already).
- Bugs:
-
- If the size of the file being played is smaller than 3*CROSSFADE_TIME_MS
- and the file was played with a fadein crossfade (i.e., it was not the first
- file to be played), the queue before audiomixer which is used to detect a
- file going EOS will contain buffers of a total time less than
- CROSSFADE_TIME_MS. The crossfade will hence happen in whatever buffer-time
- is available.
-
- If CROSSFADE_TIME_MS is set to a value less than the duration of a single
- buffer, no crossfade will happen, but the switch will be gapless.
*/
This is a decent example of how to use audiomixer for gapless/crossfade playback in an audio player. Although the example expects files, this method of doing crossfade/gapless should also work with arbitrary URIs.
Patch 307971, "crossfade: New example for crossfading audio tracks using audiomixer":
0001-New-example-for-audio-crossfade-using-audiomixer-and.patch