Closed paul1868 closed 8 years ago
Hi, thanks for your message. To specify an instrument you need to create a new ProgramChangeEvent
and specify the instrument number:
track.addEvent(new MidiWriter.ProgramChangeEvent({instrument : 1}));
You can find a list of all available MIDI instrument codes here: http://www.ccarh.org/courses/253/handout/gminstruments/
The actual sound of the instruments will depend on the software you're using to playback the MIDI file generated by this library. As far as adding custom instruments, that will also depend on the software you use for playback since MIDI files don't contain any actual audio information
Hi, Thanks for this work, it looks very interesting and promising!
Concerning instrument change, I tried to change the demo on the website, the playback on the web page does not seem to change instruments sounds when I change the "instrument" parameter in ProgramChangeEvent, but when downloading the files I can then hear different instruments, although with the Chopin Prelude example, sometimes it seems that only the first note is changed (i applied the new instrument on both tracks), the rest is still piano. It did not always happen though. On the other hand, the "Hot Cross Buns" example works good when downloading midi file.
-edit: well now i can't reproduce this "only the first note change" thing when downloading the midi file :)
Again, great job, i'm very interested by this!
Hi @jopango, thanks for checking this out. That's correct; the library I'm using for playback on the demo page doesn't support instrument changes unfortunately. As you found, downloading the midi and playing in a player that does support them should work fine. Let me know if you have any other issues with that. What player are you using?
-Garrett
Thanks guys. I didn't some more research and understand how it works now.
Cool component. Can you add some sample code on defining instruments. I'm only able to get the Piano to play and would like to try out others and add custom ones.