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

Why does a slower tempo create a little rest between NoteEvents? #99

Closed AndaRebeca closed 1 year ago

AndaRebeca commented 1 year ago

I have a track with 4 chords having: time signature: (4/4) bpm (tempo): 120 duration of the NoteEvent : "T512"

When I change the bpm to 60, a little rest appears between chords. How can I make the chords play cursively as when I have a bpm of 120? @grimmdude

marian-simonca commented 1 year ago

This is happening to us as well for the same configuration. Any help? @grimmdude

grimmdude commented 1 year ago

Hi @AndaRebeca & @marian-simonca, I can't seem to replicate this issue. When I create a MIDI file using those parameters I end up with each chord being held for a whole note as I would expect, given that each beat consists of 128 ticks.

Here's the code I'm using, can you post your code?

const MidiWriter = require('midi-writer-js');

const track = new MidiWriter.Track();

track.setTempo(60);
track.setTimeSignature(4, 4);

track.addEvent([
    new MidiWriter.NoteEvent({pitch: ['C4', 'E4','G4'], duration: 'T512'}),
    new MidiWriter.NoteEvent({pitch: ['C4', 'E4','G4'], duration: 'T512'}),
    new MidiWriter.NoteEvent({pitch: ['C4', 'E4','G4'], duration: 'T512'}),
    new MidiWriter.NoteEvent({pitch: ['C4', 'E4','G4'], duration: 'T512'}),
]);

const write = new MidiWriter.Writer(track);
console.log(write.dataUri());