Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A simple javascript metronome.
branch: master
Failed to load latest commit information.
lib Fixed name
src Fixed name
.gitignore Updated gitignore and homepage
Cakefile First commit
LICENSE.md First commit
README.md First commit
package.json Updated gitignore and homepage

README.md

Pendulum

Install with:

npm install pendulum

Simple metronome. You can include the script in your browser, or require it via Node.

Pendulum = require('pendulum').Pendulum;

In the browser, after including pendulum.js or pendulum.min.js, the Pendulum class will be available in the window object.

After that, creating a metronome is as simple as:

m = new Pendulum(80);

Where 80 is the beats-per-minute (BPM).

To start and stop the metronome:

m.start();
m.stop();

You may also want to change the BPM:

m.set(120);

Events

To register a callback function, use on.

m.on(event, callback);

The start event is fired when the metronome starts. The stop event is fired when the metronome starts. The bpm event is fired after calling set. The callback function takes two parameters: the old and the new BPM values.

m.on('bpm', function(oldBPM, newBPM) {
    console.log("BPM changed from " + oldBPM + " to " + newBPM);
});

Finally, the tick event is fired when the metronome ticks.

m.on('tick', function() {
    console.log("Tick!");
});

Todo

  • Set bpm using 'lento', 'adagio', etc.
  • Add musical meter notation ("3/4", etc) to stress different ticks
Something went wrong with that request. Please try again.