Click Tracks for your JavaScript
A light-weight utility for emitting events that are in-time with music.
Description
The main export is a constructor that can be called with differently based on use-case. Some examples are:
- Emit events for every beat timed with an audio/video source
- Emit events for every beat with out a source
- Emit events at defined cues, like music notation
Examples
Install
npm i click-track
Usage
Basic timer running at 120 bpm
const track = new ClickTrack({
tempo: 120,
autostart: true,
});
track.on('beat', (e) => {
console.log(e.beat);
});
Basic timer running at 60 bpm
const track = new ClickTrack({
autostart: true,
});
track.on('beat', (e) => {
console.log(e.beat);
});
Basic cues
When the default tempo is 60, the cues are synonymous with seconds
const track = new ClickTrack({
cues: [1, 3, 5, 7],
autostart: true,
}});
track.on('cue', (e) => {
console.log(e.beat);
});
Basic cues with tempo
const track = new ClickTrack({
cues: [1, 3, 5, 7],
tempo: 120,
autostart: true,
}});
track.on('cue', (e) => {
console.log(e.beat);
});
Basic cues with data
To pass data with each cue, use tuples for each cue.
const track = new ClickTrack({
cues: [[1, "A"], [3, "B"], [5, "C"], [7, "D"]],
tempo: 120,
autostart: true,
}});
track.on('cue', (e) => {
console.log(e.data);
});
TODO