grimmdude / MidiWriterJS

♬ A JavaScript library which provides an API for programmatically generating and creating expressive multi-track MIDI files and JSON.
MIT License
547 stars 58 forks source link

More than one instrument at a time #37

Closed MystiriodisLykos closed 6 years ago

MystiriodisLykos commented 6 years ago

Hello,

Is there a way to have more than 1 instrument play at a time? For example with the zelda-main-theme I would like to have the Lead be a violin instead of a piano. I have tried to change the instrument number as follows

// Lead Instrument
tracks[0] = new MidiWriter.Track();
tracks[0].addEvent(new MidiWriter.ProgramChangeEvent({instrument : 41}));
// Bass
tracks[1] = new MidiWriter.Track();
tracks[1].addEvent(new MidiWriter.ProgramChangeEvent({instrument : 1}));

With this change when I try to play the generated file the lead will start out as a violin but switch back over to a piano when the bass comes in. Should I be trying to do this in a different way or is it just not possible right now?

grimmdude commented 6 years ago

Hi @MystiriodisLykos,

Thanks for reaching out, I will take a look at this this evening.

-Garrett

MystiriodisLykos commented 6 years ago

Hey @grimmdude Do you have any updates on this? Thanks, Brendan

grimmdude commented 6 years ago

Hi @MystiriodisLykos,

I tested this out using MuseScore2 for playback and it seems to work as expected. What software are you using for playback?

-Garrett

grimmdude commented 6 years ago

Closing this out, feel free to reopen if needed.

-Garrett

MystiriodisLykos commented 6 years ago

Hello @grimmdude,

I have tried using midi.js for playback in the browser and I have also tried Windows media player.

Thanks, Brendan

mitchkm commented 5 years ago

I can't back this up but it seems the way Windows media player plays a multi-track midi file is by placing all the notes onto one track. Thus all the program change events affect all notes.