Note overlap
Thank you for this great library. I am developing a rhythm sequencer. If for instance, I have a kick sound lasting for 600ms, and I have two consecutive pulses of this kick separated by 500ms, I can’t achieve to play the two pulses during their original length, or without cutting their duration manually or inherited from duration
.
- Can those two pulses overlay on the same channel?
- If not, what would be a solution to get something like this:
Kick [ms
Kick Kick |--------------- |---------------
In conclusion: can midi notes overlay?
Comments
Unfortunately for you, as far as I know, this is the normal MIDI behaviour. You cannot have the same note on the same channel playing twice at the same time.
In situations like this, people have been using another channel for the second note. This is not the most convenient thing but it does the trick.
Thank you very much for your answer Jean-Philippe. Currently, I suspect my notes to be ignored because the previous one’s duration isn’t over. Considering that, what would you recommand to allow all my notes to play? Should I, for instance add a stopNote() before all playnote()?
Usually, the new note shuts down the old one. That is, there is an implicit noteoff before a noteon. This is the device's doing. You can try calling
stopNote()
but I do not think it will change anything.Fine. One more last question, I don’t find how to control volume with the library. The W3C spec is also very quiet about volume control with webmidi. Did I miss something?
Device-wide master volume control can be achieved by sending a "Universal Real Time System Exclusive message". The code to do this in v2.5.x would look something like this:
WebMidi.js does not really offer any help when it comes to system exclusive message. This is something that's on my todo list. This is the actual syntax of that message:
You can also send a control change message to whichever channel you want to assign the volume for. For example, here is how you can set the volume of channel 1 to 54:
Hope this helps!