Standalone player

BassoonTracker provides a standalone player library that you can use in your own projects, to play module files without the tracker interface.
In addition to playing songs, you can also trigger samples individually.
This is especially well-suited for small (web) games: The complete playback library is only 16.6 kb when gzipped (48 kb when uncompressed).
Although the BassoonTracker standalone player is not the most complete mod-player on the web, it is the smallest and most CPU friendly one, playing without hickups even on mobile devices and older PC's.

You'll find a simple example here.
Hit the "play" button above to start the playback.

Library and sample code

Download the bassoonplayer-min.js file, include it in your project, and you're good to go!
If you need to support older browsers or zipped .mod files, you can use the Legacy Player instead.

The most simple example would be: <script src="bassoonplayer-min.js" type="module"></script> <script> BassoonTracker.load("url/to/file.mod").then( BassoonTracker.play ); </script> Or if you want to import the library in a module-based project, you can use something like: import BassoonTracker from './bassoonplayer-min.js'; await BassoonPlayer.load("url/to/file.mod"); BassoonPlayer.play(); Please note that most browsers disable audio playback until a user action, so you will probably need a "play" button to initiate playback.

Useful methods

Indicating playback progress

The playback itself is scheduled in WebAudio and completely detached from the main JavaScript thread.
Therefore, there are no direct events to indicate 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) and call BassoonTracker.getStateAtTime(time) periodically
(or BassoonTracker.getTimeStates() to get the complete list).
Note that the player schedules audio ahead, so the last item in the BassoonTracker.getTimeStates() list will be in the future.

Displaying pattern data

When a song is playing you can get the current pattern and row that is being played with BassoonTracker.getStateAtTime(BassoonTracker.audio.context.currentTime)
This returns an object with 2 properties: songPos and patternPos.
You can then get the current pattern using BassoonTracker.getSong().patterns[BassoonTracker.getSong().patternTable[songPos]]
For a full example, please refer to the Pattern View demo

Adjusting volume

If you want to adjust to volume, you can use BassoonTracker.audio.masterVolume which is a WebAudio GainNode.
If you want to adjust the volume for a specific track (e.g. to mute it), you can access each tracks audio output using BassoonTracker.audio.filterChains[i].output() which is a WebAudio GainNode. (where i is the 0-based index of the track)

More advanced player examples

Here is a more advanced example of the player, with a playlist, a progress bar, a volume selector, and an audio visualization area.

And finally an expanded example with an additional pattern view.