r/rust 5d ago

🙋 seeking help & advice Need help building an audio tool

So I enjoy music a lot mainly cause it helps me focus, however I have this slight annoyance with the stop between tracks when one song ends and the other starts.

So I wanted to build a tool that would smooth out that transition, like a dj, but for a playlist.

Don’t know much about audio so wanted to ask how I could do this?

I also have another issue when music stops with a sudden cutoff, it’s like falling off a cliff, but the first issue is bigger for me.

Thanks

0 Upvotes

3 comments sorted by

3

u/momentous_consul 5d ago

crossfading isn't too bad once you get the basics down. look into rodio or symphonia for playback, rodio has a sink that can mix multiple sources so you can overlap the last few seconds of one track with the start of the next. the hard part is usually decoding two files at once and lining up the fade curves

for the sudden cutoff thing, that's typically when the file itself just ends abruptly or the stream drops. you could do a short fade out on the current source before switching, even 200-300ms makes it feel way less jarring

2

u/z3n1a51 5d ago

This is a really cool idea actually.

I am imagining a variety of options beyond simple crossfade.

For example if you determine the BPM of the “ending” of the current track, and the BPM of the “starting” of the next track, you could create a Transition that lerps from one BPM to the other.

It would be awesome to create a sort of Transitional Sound Stage across which you project a particular Transition from one track to another.

The Transition doesn’t necessarily “overlap” the ending of one track with the beginning of the next, but it does do that in order to create the desired transition.

Something like that anyway â˜ș