Beepbox
A simple library for playing beepbox songs. This library is a more polished version of what I made for my 2018 JS13kGames entry!
This is an open source project under the MIT license, see LICENSE.md for additional information.
Usage
Create an audio context and load a song
;;const player = song;
Play a beepbox song (once)
/** * Play the loaded clip once. * * @returns * The generic node from Audio.generateNode() for this sequence. */player;
Loop a beepbox song (infinitely)
/** * Play the loaded clip infinitely. * * @returns * The generic node from Audio.generateNode() for this sequence. */player;
Play a single note
/** * Play a single note with the given params. * * @param * The note frequency to play. * @param * The duration to play the note (seconds). * @param * The time offset to play the note (seconds). * @param * The OscillatorNode type to use; https://developer.mozilla.org/en-US/docs/Web/API/OscillatorNode/type * @param * The gain (volume) to play the note at (0.0 - 1.0). * * @returns * The generic node from Audio.generateNode() for this sequence. */player;
Example
'use strict'; ;; const player = song;player;
Contact
- Author: Zack Urben
- Twitter: https://twitter.com/zackurben (better)
- Contact: zackurben@gmail.com