-
Notifications
You must be signed in to change notification settings - Fork 24
How to use loopsource
maxl0rd edited this page Aug 29, 2011
·
1 revision
LoopSource takes a source sample and loops it continuously.
var mySound:Sound; // the source sound
var length:Number = mySound.length * 44.1;
var mySample:Sample = new Sample( new AudioDescriptor(44100, 2), length);
mySample.extractSound(mySound, 0, length); // now all of the Sound's data is in this Sample
var myLoop:LoopSource = new LoopSource(new AudioDescriptor(44100, 2), mySample);
myLoop.firstFrame = 123;
myLoop.startFrame = 123;
myLoop.endFrame = 12345;The only thing to look out for is that extractSound could take a little while if you have a long sample. If you don't need to change loop points, then you can extract just the part that you need into the sample and loop over the whole thing. Hope that makes sense.
LoopSource also lets you change the playback rate (pitch), but the normal speed case is optimized and doesn't really incur any additional overhead.