Skip to content

trynoice/january

Repository files navigation

Noice Logo

Noice January

Node.js codecov

Common APIs used by Noice Web applications for gapless audio playback.

How it works?

We use Web Audio APIs to support gapless playback. Since BaseAudioContext.decodeAudioData() method doesn't allow decoding small chunks of an audio file individually, we serve them from the server side as split segments alongside an index file. The index file holds references to all chunks corresponding to an audio file. On the client side, we read the index file first. We then read and decode individual chunks and precisely queue them to an audio context for playback.

The following is an example of an index file.

0000.mp3
0001.mp3
0002.mp3

Browser Support

  • Firefox 107: Sometimes, a slight jitter is audible during playback when one chunk finishes and the next starts.
  • Google Chrome 108: Works flawlessly.
  • Microsoft Edge 107: Works flawlessly.

Gapless Audio Encoding Caveats

Using FFMPEG's segment or stream_segment muxers to split and encode the audio files causes gaps during playback. Instead, we use -ss and -to flags to encode individual segments of an audio file one by one.

ffmpeg -y -i source.wav -c mp3 -ab 320k -ac 2 -ar 44100 -ss 0 -to 10 0000.mp3

License

GNU GPL v3

White Noise icon by Juraj Sedlák