grimmdude / MidiWriterJS

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

impossible to add CC automations #68

Closed iBundin closed 1 year ago

iBundin commented 4 years ago

Hello. There are no data related to timing in Track.ControllerChange(cc#, val). Only one CC value is exported for each track at tick position 0. I would suggest moving ControlChange to Event type and adding startTick argument to it. In case there is some mechanic to store CC automation, it would be great to add it to documentation. Thank you!

grimmdude commented 1 year ago

Hi @iBundin (& @rualark, @willemodendaal, @jonvandermeulen, @jeffm)

Sorry for such a late reply, finally getting around to addressing some of these.

You should be able to add controller change events at any point in a track by adding it like this:

track.addEvent(new MidiWriter.ControllerChangeEvent({controllerNumber: 1, controllerValue: 127}));

This event will be added with a zero tick delta from the event before it.