bpm-counter
JavaScript library for calculating beats per minute.
⏱ Uses performance.now()
by default, override with your own timestamps if necessary
♻️ Automatically resets when pausing between taps
Usage
;const counter = ;
Call the tap()
method with a touch or click event.
counter;
Optionally you can pass timestamps in ms.
counter;counter;counter;counter;
Or initialize with an array of timestamps in ms.
const counter = 0 500 1000 1500;
To read the BPM:
counterbpm;
Waiting 1.5 * average interval length will reset the counter. To reset manually:
counter;
Installation
yarn add bpm-counter
or
npm install bpm-counter
Credits
- TSDX – Zero-config CLI for TypeScript package development