Help with code for Midi legato playing and pitchbend

johnwasser:
That is not what the picture of the log shows. It shows you send the pitchbend -2949 just before the D3 ON passes through, then you press and release D#3, and press and release C3, then send pitchbend 0 just before the D3 off passes through.

Does your output device allow Aftertouch (polyphonic key pressure) to be used for pitch control? That might allow you to pitch bend individual notes). Your sketch could add aftertouch for specific notes.

ok well i'm just testing the code out so i added some more notes so its easier to understand, so as u can see from the code i just posted i only want pitchbend to send on the D3 note out of all the notes in a scale but now if i press C3(60) pitchbend is not sent, while holding C3(60) if press D3(62) pitchbend is sent which is what i want, now though, when i release D3(60) C3 Continues playing and has pitchbend amount from note D3 which i do not want, i have treid many different combinations of noteon and noteoff commands but a different problem arises when playing different notes in a different sequence. How does afterthouch work with pitchbend?

#include <MIDI.h>  // Din Midi Library

MIDI_CREATE_DEFAULT_INSTANCE();

 void setup() {

 MIDI.begin(MIDI_CHANNEL_OMNI);

 MIDI.setHandleNoteOn(MyHandleNoteOn); // This command
  // tells the Midi Library which function you want to call when a NOTE ON command
  // is received. In this case it's "MyHandleNoteOn".
 MIDI.setHandleNoteOff(MyHandleNoteOff); // This command tells the Midi Library 
  // to call "MyHandleNoteOff" when a NOTE OFF command is received.
  
  
}


void loop() {
    
    MIDI.read();
    
   
}     // end loop function


// MyHandleNoteON is the function that will be called by the Midi Library
// when a MIDI NOTE ON message is received.
// It will be passed bytes for Channel, Pitch, and Velocity

void MyHandleNoteOn(byte channel, byte pitch, byte velocity) { 
  
  if(pitch == 60)
  MIDI.sendPitchBend(0,channel);
  if(pitch == 62)
  MIDI.sendPitchBend(-2949,channel);
  if(pitch == 63)
  MIDI.sendPitchBend(0,channel);
  if(pitch == 65)
  MIDI.sendPitchBend(0,channel);
  if(pitch == 67)
  MIDI.sendPitchBend(0,channel);
  if(pitch == 69)
  MIDI.sendPitchBend(0,channel);
}

// MyHandleNoteOFF is the function that will be called by the Midi Library
// when a MIDI NOTE OFF message is received.
// * A NOTE ON message with Velocity = 0 will be treated as a NOTE OFF message *
// It will be passed bytes for Channel, Pitch, and Velocity
void MyHandleNoteOff(byte channel, byte pitch, byte velocity) { 
 
}