Help wanted !!! Building a midi controller

reading pin 2 I have mux #3. Lets say this is the first of three. I would poll the 8 pins for a hit, assigning Y0 C4, Y1 C#, Y2 D, Y3 D#, Y4 E, Y5 F, Y6 F#, and Y7 G. pin 1 will have mux #2 with notes G# to D#, pin O mux #1 with C5 and so on. I'm considering adding a MCP4921 12-Bit DAC and inplementing pitched.h but that gives me audio out and I want midi.
Can I use bitwrite to set and save the state of the y pins

==================================
Work In Progress

for (mux_number=0; mux_number <3; mux_number++){ // for (mux_number = 0 to 2){
  for (channel_number=0; channel_number <8; channel_number++); // for (channel_number = 0 to 7){
   read array [mux_number, channel_number]
   do your processing
   // next  channel_number
   }
// next mux_number
}

Yes, that looks like a pretty efficient way to read the values of the 64 inputs.
Now the trick is, after each read, to send the appropriate midi note command
Maybe do that as 16x4 array
array[i, j]
Array will be accessed:

[0,0] = 59
[0,1] = 60
[0,2]  = 61

etc, for the 32 notes you have defined.
See below for how I think your noteOn/noteOff would be inserted .

/* ReadMultiplexedSensorsAndSendMIDI
* ------------
*
* Reads 4 16 channel Multiplexers and sends the values
*
*  Stephen Williams <http://fluidforms.at> *
*/

#define CONTROLpin1 2
#define CONTROLpin2 3
#define CONTROLpin3 4
#define CONTROLpin4 5

// Variables:
char sensorValueToSend = 0;            // Value of the sensor
int actualSensorValue = 0;             // value from the analog input

// Some error chacking would be good here.
//If the values exceede 128 the will not fit in one byte.
void sendCommand(char command, char sensorID, char value) {
 serialWrite(command);
 serialWrite(sensorID);
 serialWrite(value);
}


void setup() {
 //  set the states of the I/O pins:
 pinMode(LEDpin, OUTPUT);
 pinMode(CONTROLpin1, OUTPUT);
 pinMode(CONTROLpin2, OUTPUT);
 pinMode(CONTROLpin3, OUTPUT);
 pinMode(CONTROLpin4, OUTPUT);

 beginSerial(19200);
}


void loop() {
 int i;
 int j;
 for (i=0; i <16; i++) {

  // set control pins on the multiplexers
  digitalWrite(CONTROLpin1, (i&15)>>3);//bit4
  digitalWrite(CONTROLpin2, (i&7)>>2);//bit3
  digitalWrite(CONTROLpin3, (i&3)>>1);//bit2
  digitalWrite(CONTROLpin4, (i&1)   );//bit1

  // read the analogue inputs and send the values of the sensors.
  for(j=0; j<4; j++){

//****************** replace this part
    actualSensorValue = analogRead(j);
    // You will have to adjust this line so that can send the
    // sensor value in one byte.
    sensorValueToSend = actualSensorValue / 15;
    sendCommand(0x90, i+16*j, sensorValueToSend);
// ******************** with this part
//****************************************
val = analogRead(readInZero); //  the "#define readInZero 0" type statements are ok for mapping Mux to analog port
// Serial.print(readInZero); //use the result  << only need for debug
if( val >= PIEZOTHRESHOLD ) {
t=0;
// this while mini-loop reads over & over waiting for the signal to die down?
// keep conversion time in mind again
while(analogRead(readInZero) >= PIEZOTHRESHOLD/2) {
t++;
}
noteOn(drumchan,note_59, t*2); // replace note_59 with array[i,j]
delay(t);
noteOff(drumchan,note_59,0);
}

// *********************************************
  }
  // if you uncomment this line you can check the control pins
  // of the multiplexers with your multimeter.
  //delay(500);
 }
}