From a5160b624fea0f3ea4f9440443f0d7d705e3605b Mon Sep 17 00:00:00 2001 From: ragamroll Date: Tue, 19 Feb 2013 12:01:39 -0800 Subject: [PATCH] Update inc/jasmid/replayer.js --- inc/jasmid/replayer.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/inc/jasmid/replayer.js b/inc/jasmid/replayer.js index 3932762..a44c9f3 100644 --- a/inc/jasmid/replayer.js +++ b/inc/jasmid/replayer.js @@ -59,6 +59,10 @@ function Replayer(midiFile, timeWarp, eventProcessor) { // function processEvents() { function processNext() { + if ( midiEvent.event.type == "meta" && midiEvent.event.subtype == "setTempo" ) { + // tempo change events can occur anywhere in the middle and affect events that follow + beatsPerMinute = 60000000 / midiEvent.event.microsecondsPerBeat; + } if (midiEvent.ticksToEvent > 0) { var beatsToGenerate = midiEvent.ticksToEvent / ticksPerBeat; var secondsToGenerate = beatsToGenerate / (beatsPerMinute / 60); @@ -78,4 +82,4 @@ function Replayer(midiFile, timeWarp, eventProcessor) { return clone(temporal); } }; -}; \ No newline at end of file +};