Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 6 of 6

Thread: USB Midi Note off Question

  1. #1

    USB Midi Note off Question

    Hi Guys,

    Question regarding a midi drum sequencer, when you trigger a step, a 'usbMIDI.sendNoteOn' message is sent, and when you deactivate that step, a 'usbMIDI.sendNoteOff' message is sent. However, the midi note still remains in the DAW piano roll. I'm wondering how one would remove that step when the noteOff message is sent, otherwise the DAW sequencer still plays the note even though the MIDI sequencer LED remains OFF, which is misleading to the user.

    Any ideas?

    Cheers,
    M

  2. #2
    Senior Member
    Join Date
    Nov 2012
    Location
    Boston, MA, USA
    Posts
    1,102
    Sounds like a problem with your DAW (which one?) expecting only NoteOn with a velocity of zero as NoteOff, and not handling actual NoteOff correctly.

    To test, try sending NoteOn with zero velocity. If that fixes it, file a MIDI conformance issue on your DAW.

  3. #3
    Ableton Live.

    I changed the message to NoteOn with 0 velocity and still the note remains even after the step has been turned off.

  4. #4
    Senior Member oddson's Avatar
    Join Date
    Feb 2013
    Location
    Isle in the Salish Sea
    Posts
    947
    It's not clear to me what you mean by this but it does sounds like it's the DAW's behaviour that you want to change not the Teensy.

    Isn't it the same issue when you send notes from a MIDI-keyboard? How is this not an issue for the user?

    If the DAW's state (paused record?) is available to the Teensy you could add a conditional that only sends the note-on/off if the DAW is in an active play/record state... but this means notes won't sound either and this may be worse than recording errant notes.

    If I'm way off base perhaps you could spell out your issue in much greater detail?

  5. #5
    Junior Member
    Join Date
    Apr 2017
    Posts
    16
    Post some code and we may be able to figure out what's going on.

  6. #6
    Sure, this is what I'm using. Very simple, but perhaps I'm missing something.

    Code:
    void Sequencer(byte realTimeByte) {
      if (activeMode == SEQUENCER) {
        if (realTimeByte == CLOCK) {
    
          sequencePosition++;
    
          // Handle MIDI ** NEEDS IMPROVEMENT WITH NOTE OFF 
          if (stepState[i] == 1) { //This is a simple button state
            if (sequencePosition == i * 6) {
              usbMIDI.sendNoteOn(note, velocity, channel);
            }
          } else {
            if (sequencePosition == i * 6) {
              usbMIDI.sendNoteOff(note, velocity, channel);
            }
          }
    
          //Reset sequence position.
          if (sequencePosition == sequenceLength) {
            sequencePosition = sequenceStart;
          }
        }
    
        if (realTimeByte == START || realTimeByte == CONTINUE) {
          sequencePosition = sequenceStart;
        } else {
          if (realTimeByte == STOP) {
            //Do Nothing
          }
        }
      }
    }
    Last edited by mtiger; 01-06-2018 at 06:19 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •