Created
January 21, 2016 20:59
-
-
Save JimmyHoffa/bf988f5d498db2851c33 to your computer and use it in GitHub Desktop.
get a midi file's notes and time offsets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Using: https://raw.githubusercontent.com/nfroidure/MIDIFile/master/dist/MIDIFile.js | |
$('#input-area').prepend('<input type="file" id="someFile" />'); $('#someFile').change(function() { var f = document.getElementById('someFile').files[0]; var fr = new FileReader(); fr.onload = function(d) { window.fileNotes = $.map(new MIDIFile(window.SomeBuff = d.target.result).getMidiEvents().filter(function(e) { return e.subtype === 9 || e.subtype === 8 }), function(e) { return { ms: e.playTime, note: (e.param1 - 27)/(67-27), on: e.subtype === 9 }; }) }; fr.readAsArrayBuffer(f); }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment