jsmidi
jsmidi copied to clipboard
Blank Notes
I can run notes such such as "G5, A#4" etc through your code and output it as midi. However how do I go about adding a rest. If i have a sequence in 4/4 that goes "A5,A5, rest, A5" how would I implement it so your code understand.
Thanks
+1
I see two possible solutions for adding rests. I have tested the first one, but not the second one.
- In the file midi.js (open it with text editor and have a look at the code), I don't use the function MidiEvent.createNote (around line 254) to create my notes, I use directly MidiEvent.noteOn (line 289) and MidiEvent.noteOff (line 309). I pass numbers to these functions which correspond to the MIDI numbers you can find here: [http://www.sengpielaudio.com/calculator-notenames.htm] in the section MIDI note numbers. It is likely that there are more numbers specified than your instrument has notes/keys/strings to play. In my case, I have a piano with lowest key A0, for that note I would pass the number 21 to the MidiEvent.noteOn function. When I pass the number 20, which would be G#0, my piano has no sample wav or mp3 file and no key to play that tone. So a tone without sound is played back for as long the duration of that tone lasts. That sounds like a rest. It is a workaround, no real solution, but it works for me.
- If you are using the MidiEvent.createNote function, you probably would pass a string like "C4" to the function. The function then looks up that string in the lookup table called noteTable around line 59. The lowest note on the piano would be A0, which corresponds to 0x15 in the table, which is 21 in decimal. Try to pass Ab0 or G0 to the MidiEvent.createNote function to get 0x14 or 0x13 from the table, which would be 20 or 19 in MIDI note numbers. If you have a Boesendorfer Imperial 290 piano, it has extended lower octaves, so try even lower notes.
short answer: "A5,A5,G0,A5"
if your MIDI instrument has sounds for all notes in the MIDI number table, you could try to delete a wav or mp3 file correspondig to a note you usually don't need to prevent your instrument from playing a tone.