SoundManager Rev 2 + Loop Sequencing
I’ve updated SoundManager with a couple new features.
- Manual and Automatic step based sequencing of loops.
- Cross Fading between manual loop transitions.
- Panning.
- Global fade out, disabling and enabling
The sequencing is the really promising addition to this revision. I’m excited about this as I have a background in the Recording Engineering industry as well as doing underground dance music production. Before I get started, I must say that it’s not quite perfect yet. There is an issue with loops transitioning seamlessly depending on the processor load. It’s much much better then in AS2, but it still happens. If you’re dealing with audio/music that isn’t heavily dependent precise tempos, then you should be ok. If you are, then just be aware of this issue if your swf has a lot going on in it. I have a couple of ideas on how to fix this, but I want to make sure it’s efficient on the processor and continue doing more research on this first. I also need to get up to speed and/or get some hep with ByteArray level loading:)
Before using the sequencing feature, all loops need to be added/registered with the SoundManager:
SoundManager.getInstance().addItem(new Loop1());
SoundManager.getInstance().addItem(new Loop2());
SoundManager.getInstance().addItem(new Loop3());
// etc…
All the above loops are registered using the library class references such as Loop1(). They can be later accessed using the string such as “Loop1″ as you will see below.
The SoundManager now has two new methods for setting up looping. The previous and still useful method is just by setting the number of loops in the play() arguments. The new methods use:
No depending on if you add a single String for the Sound ID or an Array. Using a single String will start the sequencer in auto mode. The loop you specify in the String will continuously loop until you use the method:
The first item is the String for the next sound. The is added to the sequence and starts as soon as the playing loop reaches the end. The second argument is a true/false for cross fading between loops.
For automatic sequencing you simple add an Array of Sound ID strings:
The above will automatically play each loop in order and then stop at the end.
Here’s a diagram of the sequencing:

There are a number of features that I plan on adding and/or enhancing:
- Some way to indicate cross fading in an automatic sequence
- XML input of sequences
- BPM output
- Specifying of multiple phrases before the upcoming loop starts (I.e. play the loop 4 times before progressing)
I’ve omitted the source fla for the external sounds in the QueueLoader example because of the file size. Here’s the code that is on the first frame of the externalsounds.swf
SoundManager.getInstance().addItem(new Loop1());
SoundManager.getInstance().addItem(new Loop2());
SoundManager.getInstance().addItem(new Loop3());
SoundManager.getInstance().addItem(new Loop4());
All of the above class references “Loop1″, etc. are located in the Library with the respective export for actionscript labels.
A number of people have been doing great work on audio processing and ByteArray streaming of PCM sound data, etc. Parsing the byte level data of loaded items is very tedious, but I plan on looking into this as a possbility for addressing the looping issue as well as other features.
I plan on including this code with a working example in the next revision of QueueLoader which I plan on posting soon. In the meantime, here’s the source:
Sound Manager Rev2 Source
Saturday, November 10th, 2007