javamidijavax.sound.midi

How to Receive the Response of a MIDI Bulk Tuning Dump Request?


I'am using the MIDI Tuning Standard to change the tuning from concert pitch A4 = 440 Hz to arbitrary tuing frequencies. It works well on my machine with Windows 7 and JDK 1.8.0. But I want check before, if the Tuning Standard is available.

Synthesizer synthesizer = MidiSystem.getSynthesizer();
System.out.println(synthesizer.getDeviceInfo().getName());

Prints out Gervill and as described on the Gervills Homepage, it supports the Tuning Standard.

Is the Gervill synthesizer part of the current JREs on all Platforms (Windows, Linux, Mac)? And if yes, will it be part for long time?

If Gervill will replaced by another synthesizer that don't support the MIDI Tuning Standard, I want to test if its available or not.

How to Test, if the MIDI Tuning Standard is Available?

My idea is to send a BULK TUNING DUMP REQUEST and if I get an response, I'am sure that it is available otherwise not.

//@formatter:off
final byte[] data = new byte[] {
        (byte) 0xf0, // SysEx Header
        (byte) 0x7e, // Non-Realtime
        (byte) 0x7f, // Target Device = All Devices
        (byte) 0x08, // MIDI Tuning
        (byte) 0x00, // Bulk Tuning Dump Request
        (byte) 0x00, // preset = 0
        (byte) 0xf7, // EOX
};
//@formatter:on
SysexMessage dumpRequest = new SysexMessage(data, data.length);

So the spec says:

The receiving instrument shall respond by sending the bulk tuning dump message described in the following section for the tuning number addressed.

But my question is, how can I receive this response?

For playing notes and send the retuning, I use MIDI in this way:

final int PPQN = 16; // Pulses/Ticks per quarter note
Sequence sequence = new Sequence(Sequence.PPQ, PPQN);
final Track track = sequence.createTrack();

// Send dump request
track.add(new MidiEvent(dumpRequest, 0));

// How to receive the response of the request?

final Sequencer sequencer = MidiSystem.getSequencer();
sequencer.setSequence(sequence);
sequencer.open();
sequencer.start();
// ...

Solution

  • As you can see in the MIDI implementation chart, Gervill (like almost any other software synthesizer) does not send any MIDI messages.

    You cannot check the default synthesizer's features from your code.

    If you wanted to use a specific synthesizer, you would have to create it manually. (Gervill's class would be com.sun.media.sound.SoftSynthesizer.)