Looping MP3 with no gap

Looping MP3 with no gap
0

#1

On the Build a Simon Game the sound continues to play while the button is pressed, but the MP3 provided is less than 1 second long, how could I continuously loop it or drag it during the middle (as it doesn’t seem to be the same through all the duration)?


#2

As far as I know, there’s no browser native resampling API, and looping is going to sound awful. The way the example project accomplishes this is via the WebAudio API, which is an interface to a very simple waveform synthesis engine. If you’re at all familiar with synthesizers, you’ll recognize many of the concepts here.


#3

Seems like even with the WebAudio API the audio file itself has silence at the start and end, is there an easy way to simply loop the part that actually has sound? I’ve read that by default MP3 files have this silent gaps, but if it wasn’t possible to perfectly loop I don’t think the provided files would be MP3 (although the consensus seems to be that OGG is better).


#4

Nope.

I don’t think I was clear with my last post. The example project isn’t looping an audio file. It’s generating audio via a simple synthesis engine in the browser. The files you’re looking at are provided because it’s easier to simply load and play an audio file than it is to use the WebAudio API, but they’re not what you’re hearing in the example. It would be a good idea to trim the silence in those audio files, but this should be done at the source.


#5

I’ve trimmed the silences and converted into OGG. You can get them all in an archive here.


#6

Thanks a lot, but I guess there’s not much to do if the example project isn’t actually looping, so I suppose I’ll play only once (since the WebAudio API seems pretty confusing to me).

Thanks for the help!