onetwoeight
OneTwoEight is a simple BPM counting library. Unlike other BPM counters, it uses a rolling average to calculate BPM, as well as resetting the average when extraneous values are detected.
Install
$ npm install onetwoeight
Usage
The counter can be initiated with no arguments. If arguments are provided, they are a length of rolling average window, and a tollerance range that beats can fall in. If no parameters are used, they will default to a window of 20 and a tolerance of 0.2.
var onetwoeight = ;bpm = ;
Beats are recorded using the tap method.
bpm;
The current bpm can be retreived with the bpm method. It can take an optional boolean as a single paramater to indicate 'precision mode'. If the parameter is true, it will not round the result of the calculation.
bpm; //128bpm; // 128.88650100738751
Counter
A demo counter is provided
node bpm.js
Pressing the space bar will initiate a tap. Pressing t will toggle precision
mode. Ctrl + c
will exit.
1 : ???2 : 1303 : 1254 : 1275 : 1266 : 1257 : 1278 : 1269 : 12710 : 128