Using UNO R3 + USB Host Shield to relay MIDI via powered USB Hub?

Is that what you mean?

No.

byte Message1[2],Message2[2];                 // Construct the midi message (2 bytes)
    Message1[0]=0xC0;                 // 0xC0 is for Program Change 
    Message1[1]=number;               // Number is the program/patch
    Message2[0]=0xC0;                 // 0xC0 is for Program Change 
    Message2[1]=number;               // Number is the program/patch 
 
    Midi1.SendData(Message1);          // Send the message 
    Midi2.SendData(Message2);          // Send the message

That do ... while construct looks very convoluted and not something I would ever use.