Some of you might have seen my previous post on SoundLoop2 that you can see in action here. But it had some timing inconsistencies, due in big part to setInterval.
I decided to deconstruct my SoundLoop2 and refactor it in a simpler manner. This resulted in 4 classes.
- MusicBuilder Class to handle “playlists” and loop modes
- SoundObject Class wich is a simplefied version of SoundLoop2
- SOCollection Class wich is a simple Array of SoundObjects with custom method to retrieve information.
- Timer Class wich calculates the exact (I hope) time elapsed between the start and the desired duration and returns an event when done.