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

how to use different duration for each note in note array #53

Closed drumtj closed 1 year ago

drumtj commented 5 years ago

hi How to add note event with different lengths at the same time?

[MidiWriterJS] new MidiWriter.NoteEvent({pitch:['C4', 'D4', 'E4'], duration: '4'});

[Tone js example] poly.triggerAttackRelease(["Eb3", "G4", "C5"], "2n"); poly.triggerAttackRelease(["Eb3", "G4", "C5"], ["2n", "4n", "4n"]); ---> i need like this

grimmdude commented 5 years ago

Hi @drumtj,

Currently the best way to create concurrent note events with different durations is by using separate tracks.

-Garrett

drumtj commented 5 years ago

Hi..

I am already using multitrack for several instruments. Is it impossible to apply multiple notes of different lengths to a single note event?

grimmdude commented 5 years ago

Hi @drumtj,

You can try using the Track.mergeTrack() method to combine two tracks with different event durations into one.

http://grimmdude.com/MidiWriterJS/docs/Track.html#mergeTrack

-Garrett