JDK-8290993 : Gervill receivers are not independent
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.sound
  • Affected Version: 11.0.15
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: linux
  • CPU: x86_64
  • Submitted: 2022-07-02
  • Updated: 2022-12-02
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11
11-poolUnresolved
Description
A DESCRIPTION OF THE PROBLEM :
If MidiDevice.getMaxReceivers()==-1 makes any sense, the receivers should act independently, as if two devices were present.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Apply getReceiver() twice on a Gervill soft synthesizer object. Two distinct Receiver objects will be obtained.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
When one receiver changes, say, the sound of MIDI channel 1 to piano, and another receiver changes its MIDI channel 1 to violin, and to each receiver a note is sent, two different sound timbres should be produced.
ACTUAL -
Both notes sound the same.

---------- BEGIN SOURCE ----------
public boolean GetTwoIndependentReceivers (Receiver [] inhereplease)
{
    for (MidiDevice.Info info : MidiSystem.getMidiDeviceInfo ()) try
    {
        MidiDevice device = MidiSystem.getMidiDevice (info);
        if (   device instanceof Synthesizer
            && (   device.getMaxReceivers () < 0
                || device.getMaxReceivers () >= 2)) try
        {
            device.open ();
            inhereplease [0] = device.getReceiver ();
            inhereplease [1] = device.getReceiver ();
            // will be distinct as objects, but with Gervill not independent
            return true;
        } catch (Exception ex) {}
    } catch (Exception ex) {}
    return false;
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
I have tried to create two Gervill SoftSynthesizers objects on the same audio line, and one receiver for each. No exception is being thrown, but the resulting audio is a total mess – perhaps yet another bug?


Comments
Additional Information from submitter: =========================== One reason why more than one independent receivers are very desirable: Many notation programs, when asked to export an orchestra score to a MIDI file, will use the "Port number" feature of the MIDI file standard to obtain as many sets of 16 (15) channels each as needed. When they import such a file, the original number of channels is reproduced even if larger than 16. To play such a file on Gervill correctly, one independent Receiver object per Port is required. (Java offers a ready-made MIDI file player, which may profit from that feature/correction as well.) If you agree on the desirability but find implementation too hard, I can offer my assistance.
02-12-2022