Skip to content

Commit

Permalink
Sending midi clock
Browse files Browse the repository at this point in the history
  • Loading branch information
t638403 committed Jun 5, 2016
1 parent 03a52d3 commit 59a4b60
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
22 changes: 12 additions & 10 deletions services/metronome.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ Box.Application.addService('metronome', function(application) {
events.EventEmitter.call(this);
var _this = this;
var notes = {
whole:new ExactInterval(beatInterval(bpm)),
half:new ExactInterval(beatInterval(bpm * 2)),
third:new ExactInterval(beatInterval(bpm * 3)),
//whole:new ExactInterval(beatInterval(bpm)),
//half:new ExactInterval(beatInterval(bpm * 2)),
//third:new ExactInterval(beatInterval(bpm * 3)),
quarter:new ExactInterval(beatInterval(bpm * 4)),
eighth:new ExactInterval(beatInterval(bpm * 8)),
sixteenth:new ExactInterval(beatInterval(bpm * 16))
//eighth:new ExactInterval(beatInterval(bpm * 8)),
//sixteenth:new ExactInterval(beatInterval(bpm * 16)),
midiclock:new ExactInterval(beatInterval(bpm * 24))
};

Object.keys(notes).forEach(function(note) {
Expand All @@ -44,12 +45,13 @@ Box.Application.addService('metronome', function(application) {
});
}
function setBpm(bpm) {
notes.whole.setInterval(beatInterval(bpm));
notes.half.setInterval(beatInterval(bpm * 2));
notes.third.setInterval(beatInterval(bpm * 3));
//notes.whole.setInterval(beatInterval(bpm));
//notes.half.setInterval(beatInterval(bpm * 2));
//notes.third.setInterval(beatInterval(bpm * 3));
notes.quarter.setInterval(beatInterval(bpm * 4));
notes.eighth.setInterval(beatInterval(bpm * 8));
notes.sixteenth.setInterval(beatInterval(bpm * 16));
//notes.eighth.setInterval(beatInterval(bpm * 8));
//notes.sixteenth.setInterval(beatInterval(bpm * 16));
notes.midiclock.setInterval(beatInterval(bpm * 24));
}

function beatInterval(bpm) {return 60000 / bpm;}
Expand Down
3 changes: 3 additions & 0 deletions services/song.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Box.Application.addService('song', function (application) {
midiOut.sendMessage(msg);
});
});
metronome.on('midiclock', function (nr) {
midiOut.sendMessage(midiMsgr.clock());
});

var midiMate = 2;
var currInstrument = 0;
Expand Down

0 comments on commit 59a4b60

Please sign in to comment.