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

Way to change timebase (ppq) instead of 128 #94

Closed MarmotCluster closed 2 years ago

MarmotCluster commented 2 years ago

I'm enjoying your package but have a problem. I usually use the result file in fl studio. default timebase is 96.

// notes array
new NoteEvent({
    pitch: [getKeyAsString(i)],
    startTick: i * 128 * (0 / 96),
    velocity: Number((100 / 128) * 100),
    //even tried '128 * ((i + 1) / 96)' and 'Math.round(128 * ((i + 1) / 96))'
    duration: `T${Math.floor(128 * ((i + 1) / 96))}`,
})

so i rounded tick values and imported the midi file in software but it's not working as i thought. dirtydesc

is there a way to set it manually for file?

MarmotCluster commented 2 years ago

Solved it by changing constants directly.