While looking through the Tone.JS documentation, I found that MIDI files were supported.
MIDI To use MIDI files, you’ll first need to convert them into a JSON format which Tone.js can understand using Midi. Although there are many resources online to convert MIDI to JSON, I have not found a single code example or any documentation demonstrating the usage of MIDI files and/or JSON files.
Throughout many journeys through the documentation, I only found examples for playing .mp3 files and using effects. Google search was unfruitful as well. Is there anyone that can give me a code snippet demonstrating this?
Check out the source code of http://tonejs.github.io/Midi/. The JS is in the
<script>tag at the bottom of the<body>It looks like you need to loop through the object manually and schedule each note with tonejs. Here is the relevant part of the code. currentMidi is the Midi object constructed using the result of reading the midi file from the upload box. currentMidi is then looped through and has its tracks and notes processed and scheduled.
To get the
Midiclass you will need https://github.com/Tonejs/Midi. I think their claim that it is tonejs friendly is a bit exaggerated, as you still need to write the code to play the individual notes, with all the setup required for that also. I would expect more of a single function to play the returnedMidiobject.