MIDI Messages - Affecting a note once NoteON has been sent.

Hello there.
Im currently designing a musical instrument interface for multi-sensor input.
In a way this is more a MIDI question than a Arduino question, but maybe someone has had some expeirence from an Arduino perspective.
The current code is NOT using midi.h library, so we can understand the basics before we start using libraries.

I wonder if anyone could explain the rules around sending midi commands > Specifically.

  1. How to affect the Channel Pressure / Aftertouch of a note once the NoteON command has been sent already.

My secondary questions are more specific:
We are using a breath sensor (MPXV7002) with puff and draw for NoteON.

  1. How does midi ‘Breath Control’ differ from standard midi NoteOn commands?
  2. Can/should we use it?
  3. What does it do to the messages to sent?

We would like to read the pressure of the breath sensor constantly to give a expressive Volume for the note output. Dynamic control of the amplitude envelope.
We can route the channel pressure / aftertouch to do this in the midi device. But im wondering the best way to do this.

here is a snippet of the code:

int measBS;                     // value of Breath Sensor pin 
int BS = 0;                       // BREATH SENSOR pin assignment
int Potpin = 1;                 // Pot pin assignment
int PotVal;                      // variable for Pot
int lastPotVal = 1000;
int note;                        // variable for note
int Vel;                        
boolean noting = false;

void setup() {
  Serial1.begin(31250);             //  Set MIDI baud rate:
  pinMode(ledPin, OUTPUT);      // sets the digital pin as output
  noting = false;
}

void loop () {
  PotVal = 0;                  // set variables to 0
  measBS = 0;                 // set variables to 0
  measBS = analogRead(BS);       // read BB pin analog 0
  PotVal = analogRead(Potpin);   // read Pot pin
  PotVal = PotVal/10;            // reduce sensitivity of PotVal - range 0 -> 102
  //Serial.println("PotVal = " ); //
  //Serial.println(PotVal);
  
  if(PotVal != lastPotVal){
     noteOn(0x90, note, 0x00); 
     if(noting == true){
       note = PotVal; 
       noteOn(0x90, note, 0x60);  
     }
     lastPotVal = PotVal;
  }
  
  
  measBS = (measBS - 535);        // calibrate BS so no input =0
  if (measBS > 0) {
    digitalWrite(ledPin, HIGH);   // sets the LED on
  }
  else {
    digitalWrite(ledPin, LOW);    // sets the LED off
  }
  if (measBS<2) { //Neutral to inhale
      noteOn(0x90, note, 0x00); 
      noting = false;
  }
  else { // puffing
     Serial.println("Puff");  // print the value
     Serial.println(measBS, DEC);
     Vel = (measBS * 10);          // amplify BS valuo to get more vel values
     note = PotVal; 
     // note number = pot value
     if(noting == false){
        noteOn(0x90, note, 0x60);   // define noteOn
        Serial.println("I sent a note");  // print the value
     }
     else{
        Serial.println("noting is true"); 
     }
  }
}

void noteOn(int cmd, int pitch, int velocity) {
  Serial1.write(cmd);
  Serial1.write(pitch);
  Serial1.write(velocity);
  noting = true;
}

There is a specific MIDI message for aftertouch/pressure. See http://www.midi.org/techspecs/midimessages.php If that message doesn't work for breath control, I'm sure there's a midi message that will handle it.

Pete

Thank you pete. I have indeed been working from that table most of the way through. Its really useful.

I've managed to get the aftertouch working. But I guess my question is about the differences / similarities between After Touch - Channel Pressure - Breath Control. -besides the obvious that breath control is for breath controllers. Aftertouch will affect only the pressed single note and Channel pressure affects the whole channel. I was wondering what programming functions happen to make breath control different from the other channels if at all.

Vahakn

My experience with MIDI, such as it is, has only been with keyboards/synth, but I would guess that there's something about breath controllers which will trigger the equivalent of a note on since the note should start sounding when you blow rather than there being an obvious switch closure as there is with a keyboard. If you have access to a breath-controlled device, it would be easy to write/find a midi-monitor sketch which would allow you to see precisely what it generates.

Pete

Pete thats a good idea. Im using Midi Monitor at the moment and its great. I think i'll change my channel output to Breath Control and just see what comes in.

Right now, the breath sensor reads the very first value that comes in (i guess as velocity), which as it is so sensitive, is a very low value. And then as you continue to breath we need to send those further readings to increase the volume of the note intelligently or expressively, not just the instrument volume.