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?


  • 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()?

  • edited February 4

    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.outputs[1].sendSysex(0x7F, [0x7F, 0x7F, 0x04, 0x01, 0x12, 0x34]);

    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:

    0xF0  SysEx (this is auytomatically included by WebMidi.js)
    0x7F  Realtime
    0x7F  Channel. Could be from 0x00 to 0x7F. Here we set it to "disregard channel".
    0x04  Sub-ID -- Device Control
    0x01  Sub-ID2 -- Master Volume
    0xLL  Bits 0 to 6 of a 14-bit volume
    0xMM  Bits 7 to 13 of a 14-bit volume
    0xF7  End of SysEx (this is auytomatically included by WebMidi.js)

    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:

    WebMidi.outputs[1].sendControlChange("volumecoarse", 54, 1);

    Hope this helps!

Sign In or Register to comment.