jsmidgen icon indicating copy to clipboard operation
jsmidgen copied to clipboard

How to add note pauses?

Open zettam opened this issue 9 years ago • 3 comments

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.

zettam avatar Sep 10 '16 16:09 zettam

"rest" it is called I believe

zettam avatar Sep 10 '16 18:09 zettam

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)

walmik avatar Jan 28 '17 15:01 walmik

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

pateketrueke avatar Sep 18 '18 22:09 pateketrueke