Page 1 of 1

MIDI Out Jack: Sending SysexMessage possible?

Posted: Sun May 30, 2021 11:13 am
by AndreasFranke
Ahoi! :)
A quick question: Is it possible to send other MIDI message types like SysexMessage, instead of ShortMessage with VM' MIDI Out Jacks?
I'm asking for a friend. :lol:

Andreas

Re: MIDI Out Jack: Sending SysexMessage possible?

Posted: Sun May 30, 2021 1:07 pm
by honki-bobo
Hey Andreas,

I have no experience with sending MIDI SysEx data in VMD, but from looking at the JavaDoc of MidiMessage, ShortMessage and SysexMessage I think it should be possible to create valid SysEx data and send it as ShortMessage. Both, ShortMessage and SysexMessage inherit the protected method setMessage(byte[] data, int length). I don't have the time to test this right now, but you can try to implement a class that extends ShortMessage and make the setMessage(byte[] data, int length) method public like so:

Code: Select all

import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.ShortMessage;

public class MyMidiMessage extends ShortMessage {
	public void setMessage(byte[] data, int length) {
		try {
			super.setMessage(data, length);
		} catch (InvalidMidiDataException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
The byte array would contain your SysEx data, and length is simply the length of the array. You can handle MyMidiMessage exactly like ShortMessage and try to pass it to the MIDI Out Jack. If the compiler is complaining, add a cast to ShortMessage.

Re: MIDI Out Jack: Sending SysexMessage possible?

Posted: Sun May 30, 2021 2:07 pm
by AndreasFranke
honki-bobo wrote: Sun May 30, 2021 1:07 pm Hey Andreas,

I have no experience with sending MIDI SysEx data in VMD, but from looking at the JavaDoc of MidiMessage, ShortMessage and SysexMessage I think it should be possible to create valid SysEx data and send it as ShortMessage. Both, ShortMessage and SysexMessage inherit the protected method setMessage(byte[] data, int length). I don't have the time to test this right now, but you can try to implement a class that extends ShortMessage and make the setMessage(byte[] data, int length) method public like so:

Code: Select all

import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.ShortMessage;

public class MyMidiMessage extends ShortMessage {
	public void setMessage(byte[] data, int length) {
		try {
			super.setMessage(data, length);
		} catch (InvalidMidiDataException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
The byte array would contain your SysEx data, and length is simply the length of the array. You can handle MyMidiMessage exactly like ShortMessage and try to pass it to the MIDI Out Jack. If the compiler is complaining, add a cast to ShortMessage.
Aaah, good hint. I will look at this....
Thank you so much!

Andreas