just_audio icon indicating copy to clipboard operation
just_audio copied to clipboard

Cross Fade between audio tracks within a playlist

Open iamrwa opened this issue 3 years ago • 11 comments

Is your feature request related to a problem? Please describe.

Despite using the gapless function, moving to the next music track in a playlist sounds really jarring.

In most cases, using the 'gapless' function does not eliminate the silence and dip in volume between music tracks because most music files fade-out to silence as they reach their end and fade-in from silence. As a result, there is no smooth transition between music tracks.

Describe the solution you'd like

Crossfading between music tracks to make a mixed playlist sound much more seamless and natural-sounding transitions.

Would like to be able to set the duration of crossfades, such as 10 seconds. In this case, a crossfade duration setting of 10 seconds would start to fade-out the current music track and fade in the next track in the playlist. This would result in a continuous mix and flow of music.

Crossfade function would be used when switching between music tracks such as when choosing the previous or next track, stop or start playing a music track.

Describe alternatives you've considered

  1. Transform a successfully working crossfade jquery script into Dart and integrate it into just-audio
  2. Edit all music tracks to remove the silences and fades at the beginning and end.

Additional context See this article for further clarification about Crossfade https://www.howtogeek.com/57252/how-to-use-crossfade-in-audacity-for-seamless-transitions-between-audio-tracks/

iamrwa avatar Sep 16 '22 12:09 iamrwa

Hi @flmuse

Crossfade is an open issue in ExoPlayer: https://github.com/google/ExoPlayer/issues/3438 . Crossfade will not be a feature of just_audio until the platform support is there.

However, you can certainly achieve a similar effect using the current API. Essentially, create two player instances, one to render the current audio track, and one to render the next audio track. Listen to the position, and when it reaches the crossfade point, simultaneously start the second player. Also use a Timer (or similar) to do a fade-in or fade-out by repeatedly calling setVolume at an interval.

ryanheise avatar Sep 16 '22 12:09 ryanheise

Hi @ryanheise Thank you for your suggestion, will try this.

Kind regards.

iamrwa avatar Sep 16 '22 12:09 iamrwa

Hi @ryanheise

do you have a demo apk using just-audio?

Pls send the details where to download.

Kind regards.

iamrwa avatar Sep 16 '22 13:09 iamrwa

You can try downloading the fuzing app which implements this effect, and for more insights you can read fuzing's comment here.

ryanheise avatar Sep 16 '22 13:09 ryanheise

@ryanheise thanks

iamrwa avatar Sep 16 '22 14:09 iamrwa

@ryanheise would this be possible to do while using just_audio_background?

A solution I can think of is a new method to select what player should be used to interface with the rest of the system, would this work?

aguilaair avatar Nov 22 '22 09:11 aguilaair

yes this would work. pls clarify further. Thanks.

On Tue, Nov 22, 2022 at 9:54 AM Eduardo M. @.***> wrote:

@ryanheise https://github.com/ryanheise would this be possible to do while using just_audio_background?

A solution I can think of is a new method to select what player should be used to interface with the rest of the system, would this work?

— Reply to this email directly, view it on GitHub https://github.com/ryanheise/just_audio/issues/815#issuecomment-1323394237, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABQGKVOK4UJZKNCK676V2DLWJSJ4TANCNFSM6AAAAAAQOI573Y . You are receiving this because you were mentioned.Message ID: @.***>

iamrwa avatar Nov 22 '22 11:11 iamrwa

I'd like to avoid overcomplicating just_audio_background with advanced features that could be more appropriately handled by using audio_service directly. If you have more advanced requirements such as multiple players, you should use audio_service.

ryanheise avatar Nov 22 '22 12:11 ryanheise

Does audio_service have cross fade?

On Tue, Nov 22, 2022 at 12:05 PM ryanheise @.***> wrote:

I'd like to avoid overcomplicating just_audio_background with advanced features that could be more appropriately handled by using audio_service directly. If you have more advanced requirements such as multiple players, you should use audio_service.

— Reply to this email directly, view it on GitHub https://github.com/ryanheise/just_audio/issues/815#issuecomment-1323561802, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABQGKVOKQZFJM7SI4NR5SNTWJSZHDANCNFSM6AAAAAAQOI573Y . You are receiving this because you were mentioned.Message ID: @.***>

iamrwa avatar Nov 22 '22 14:11 iamrwa

It definitely does not have cross fade. I am guessing that you didn't follow the link in the just_audio_background README that points to audio_service. Please have a read, it explains what audio_service is, isn't, has, doesn't have, etc.

ryanheise avatar Nov 22 '22 14:11 ryanheise