GaplessLoopedSound

author:
Cooper
description:
Allows smooth, gapless, looped playback of mp3's. Resolving the mp3 issue which causes a click when it loops mid music
lastupdate:
2013-12-23
compatible:
v1.4.1
tag:
mp3, looped, Sound
homepage:
https://gist.github.com/mountainstorm/8106250
download:
https://gist.github.com/mountainstorm/8106250

Overview

Starling2D extension to allow playing of looped mp3's without the 'click' as it loops (due to the issue with mp3 frame sizes).

In short mp3's are terrible for looping. The way the codec works you end up with encoder and decoder delay at the start and potential padding at the end. When this plays you gets little gap when it loops :(

Thankfully there is a solution if you've used LAME to do the encoding.

To use this library you have four choices (in preference order):

1. (Recommended) var rain:Sound = GaplessLoopedSound.createWithLAME(assets.getByteArray("rain"));
2. var rain:Sound = new GaplessLoopedSound(assets.getSound("rain"), delay, padding)
3. var rain:Sound = GaplessLoopedSound.createWithGuess(assets.getSound("rain"), originalSampleLength); // guesses
4. var rain:Sound = new GaplessLoopedSound(assets.getSound("rain")); // uses some defaults which might work

Changelog

Source Code

%gist(8106250)%

User Comments

Feel free to edit this part of the page!