Example of the standalone BassoonTracker playback routine, playing a module file without the tracker interface.
Hit the "play" button above to start the playback.
Just include a single JS file and you're good to go.
Size comparisons (v0.4.0)
of provided libraries
The most simple example would be:
The second parameter in BassoonTracker.load defines autoplay.
Please note that most modern browser disable audio playback until a user action, so you may need a "play" button to initiate playback.
You can use a third parameter as callback function when the loading of the file is done.
After BassoonTracker.init you might want to check "Audio.context" to see if the browser supports WebAudio.
Some useful methods:
BassoonTracker.getSong() (gets the current song)
BassoonTracker.getSong().length (in patterns)
BassoonTracker.getSong().patterns (array of patterns)
BassoonTracker.getSong().patternTable (array of pattern positions in the song)
BassoonTracker.audio (pointer to the main audio object)
The playback itself is scheduled in WebAudio and completely detached from the main JS thread.
Therefore there are no direct events to indicated playback progress.
If you want to display some UI with a progress indicator you will have to keep track of the start time of the song (Audio.context.currentTime)
to get the complete list).
Note that the Tracker schedules audio ahead, so the last item in the BassoonTracker.getTimeStates() list will be in the future.
Refer to this example with progress tracking
for a demo.
If you want to adjust to volume, you can use
which is a WebAudio GainNode.