Hey HN,
I just released v4 of my gapless playback library that I first built in 2017 for https://relisten.net. We stream concert recordings, where gapless playback is paramount.
It's built from scratch, backed by a rigid state machine (the sole dependency is xstate) and is already running in production over at Relisten.
The way it works is by preloading future tracks as raw buffers and scheduling them via the web audio API. It seamlessly transitions between HTML5 and web audio. We've used this technique for the last 9 years and it works fairly well. Occasionally it will blip slightly from HTML5->web audio, but there's not much to be done to avoid that (just when to do it - lotta nuance here). Once you get on web audio, everything should be clean.
Unfortunately web audio support still lacks on mobile, in which case you can just disable web audio and it'll fallback to full HTML5 playback (sans gapless). But if you drive a largely desktop experience, this is fine. On mobile, most people use our native app.
You can view a demo of the project at https://gapless.saewitz.com - just click on "Scarlet Begonias", seek halfway in the track (as it won't preload until >15s) and wait for "decoding" on "Fire on the Mountain" to switch to "ready". Then tap "skip to -2s and hear the buttery smooth segue.
Look very nice, I may end up using for https://museeks.io, gapless playback has been on the roadmap for a while, but WebAudio APIs have always been super cryptic, a higher-level API is very much welcome.
How does this relate to https://github.com/regosen/Gapless-5 - looks like that is also recently updated.
Really appreciate you using XState!
In the second demo, the audio for “Mama Tried” ended up in the track titled “Row Jimmy” instead of the track titled “Mama Tried” ;)
Also, the demo UI drops the playback state if you switch from one tab to the other; if you play a track in one tab, switch to the other tab, and switch back to the first tab, there's no option to pause the already-playing song. Thanks to this I'm currently listening to five instances of the Grateful Dead singing “Mama Tried” offset by about 5 seconds lmao
Perfect use case for a web based sample sequencer!
It's not gapless on firefox latest.
Maybe you should use shorter example songs, so that you don't have to "skip to -2s" and can have the emotional experience of gapless playback.