Building a sysex message in Java for Garage band

832 views Asked by At

I am trying to control my GarageBand sequencer by sending some midi messages from a Java program. It works well for ShortMessage. For example, I can record a C3 in GarageBand in this way :

ShortMessage myMsg = new ShortMessage();
myMsg.setMessage(ShortMessage.NOTE_ON, 0, 60, 93);
Receiver receiver = MidiSystem.getReceiver();
receiver.send(myMsg, -1);

Now I would like to send some SysEx message to "control" my sequencer, for example, to start the recording. But building a SysexMessage is harder than a ShortMessage since it requires to build an array of bytes. In particular, one must specify the "manufacturer ID". Looking for some informations on the web about this issue gave me the feeling that I was not going in the right direction because nothing seems really clear. Is someone familiar with this problem ?

1

There are 1 answers

0
CL. On

SysEx messages can be create with a byte array:

byte[] mmcStart = new byte[]
    { (byte)0xf0, 0x7f, 0x7f, 0x06, 0x02, (byte)0xf7 };
SysexMessage myMsg = new SysexMessage(mmcStart);

Manufacturer IDs are used to prevent conflicts when using vendor-specific messages. Standardized messages use reserverd manufacturer IDs 7E (for non-realtime messages) or 7F (for realtime messages).

Please note that, in addition to the MMC Start message, there is also a plain MIDI Start message (ShortMessage.START).

However, GarageBand supports neither; see GarageBand Control Codes.