midi-clock

Creates a virtual midi clock ticking at 96 PPQ

npm install midi-clock
6 downloads in the last month

midi-clock

Creates a virtual midi clock ticking at 96 PPQ

Install

$ npm install midi-clock

Example

var MidiClock = require('midi-clock')

// in node just do this (uses process.hrtime):
var clock = MidiClock()

// in browser
var audioContext = new webkitAudioContext()
var clock = MidiClock(audioContext)

clock.start()

clock.on('position', function(position){

  // log on each beat, ignore the rest
  var microPosition = position % 24
  if (microPosition === 0){
    console.log('Beat:', position / 24)
  }

})

setTimeout(function(){
  // change to 120bpm after 10 seconds
  clock.setTempo(120)
}, 10000)
npm loves you