 byte getVelocity(byte pPos) {
   if (noteTime[pPos] == 0) {
     noteTime[pPos] = millis();
-    /* Serial.println("Time");
-      Serial.println(noteTime[pPos], DEC);
-      Serial.println("Velocity");
-      Serial.println(127, DEC);
-      Serial.println("Pos");
-      Serial.println(pPos, DEC);
-      delay(10);*/
     return 127;
   } else {
     byte tempVelocity = map(abs(millis() - noteTime[pPos]), 0, sensitivity, 127, 10);

            }*/
          if ((i + 12 * j) % 2 == 0) {
            if (keyState[i + 12 * j + 1] == 1) {
              midiSend(noteOn, keyMidi[i + 12 * j], getVelocity((i + 12 * j) / 2));
            } else {
              updateVelocity((i + 12 * j) / 2, (byte)1);
            }
          } else {
            if (keyState[i + 12 * j - 1] == 1) {
              midiSend(noteOn, keyMidi[i + 12 * j], getVelocity((i + 12 * j) / 2));
            }
            else {
              updateVelocity((i + 12 * j) / 2, (byte)1);

  }
}

/**
    Method to send a control message with analog values.
    @param pChannel the channel to send the message.
    @param pControl the note to turn on.
    @param pValue the value to send.
*/
void controlMessage(byte pChannel, byte pControl, byte pValue){
  pChannel += control-1;
  midiSend(pChannel,pControl, pValue);
}

/**
    Method to send a note on message.  
    @param pChannel the channel to send the noteon.
    @param pPitch the note to turn on.
    @param pVelocity the velocity of the note.
 */
void noteOn(byte pChannel, byte pPitch, byte pVelocity){
  pChannel += noteON-1;
  midiSend(pChannel, pPitch, pVelocity);
}

/**
    Method to send a note off message.
    @param pChannel the channel to send the noteoff.
    @param pPitch the note to turn off.
 */
void noteOff(byte pChannel, byte pPitch){
  pChannel += noteOFF-1;
  midiSend(pChannel, pPitch, 0);
}

/**
   Method to send the midi message.
   @param statusByte the status midi command.
   @param dataByte1 the first data byte.
   @param dataByte2 the second data byte.
   @return void
*/
void midiSend(byte statusByte, byte dataByte1, byte dataByte2) {
  if (!debug) {
    Serial.write(statusByte);
    Serial.write(dataByte1);
    Serial.write(dataByte2);
  } else {
    Serial.println("Begin Message.");
    Serial.println(statusByte, BIN);
    Serial.println(dataByte1, BIN);
    Serial.println(dataByte2, BIN);
    Serial.println("End Message.");
  }
}
