48 pot MIDI controller needs to be faster...

Your input, ChanVal and oldChanVal all hold 7 or 8 bit values. So declare them as byte not int.

Note that some controller numbers have predefined meanings. You probably want a bit more control over which physical pot controlls which MIDI controller, rather than just writing to controllers 0 .. 47. In particular, controller 0 is bank Select so altering that randomly will give you unpredictable results.

So I suggest adding

bye controller[48] = {
80, 81, 82, 83,
86, 86, 87 .... and so on ....
}

and then

  if(chanVal[a] != oldChanVal[a]){  //test to see if any of the values in the chanVal array have changed
    Serial.write(0xB0);
    Serial.write(controller[a]);
    Serial.write(chanVal[a]);