jsmidgen
jsmidgen copied to clipboard
How to add note pauses?
I would like to add silent notes (pauses) directly just like I can add a d4 or any other note. I'm unable to find this in documentation. Any help would be appreciated.
"rest" it is called I believe
You can set the note to be an empty string in case you want to add a rest. So for instance,
track.noteOff(0, '', 64);
In there ^ 0 implies channel number, '' implies don't play any note and 64 implies, do this for 2 beats (assuming it s a 16 beat bar)
Seems like this does not works on the beginning of the track:
// test.js
const jsmidgen = require('jsmidgen');
const track = new jsmidgen.Track();
const file = new jsmidgen.File();
file.addTrack(track);
track.noteOff(0, '', 100);
track.noteOff(0, '', 100);
track.noteOff(0, '', 100);
track.noteOn(0, 'c2', 100, 100);
track.noteOff(0, 'c2', 100, 100);
require('fs').writeFileSync('output.midi', file.toBytes(), 'binary');
It always start playing on c2, no matter how many track.noteOff(0, 'c2', 100, 100); I put before.
$ node test.js && timidity output.mid