-
Bug
-
Resolution: Fixed
-
P3
-
1.4.1
-
b12
-
generic
-
generic
Name: vtR10009 Date: 07/25/2002
Specification for the method MidiChannel.getController(int controller) from
the package javax.sound.midi is ambiguous:
"Obtains the current value of the specified controller. The return value is
represented with up to 14 bits; the resolution is dependent on the controller
number. For controllers 0-31, the resolution is always 14 bits.
Returns: the current value of the specified controller"
It is not clear should the method getController() return entire 14-bit
value for controller numbers 0-31, or MSB value? And what values should
be returned for 32-63 controller numbers.
Method controlChange() sets the values separatly. But actually
current MidiChannel implementation for default synthesizer returns
7-bit value for MSB controller numbers. This behavior contradicts
to the spec that return value is represented with up to 14 bits.
This bug may affect new JCK test:
api/javax_sound/midi/MidiChannel/index.html#control
To reproduce the bug run the following test with JDK build 1.4.1-rc-b17:
------------------------------- test.java --------------------------------
import javax.sound.midi.*;
import javax.sound.sampled.*;
public class test{
static boolean isSoundAccessDenied = false;
{
SecurityManager securityManager = System.getSecurityManager();
if (securityManager != null) {
try {
securityManager.checkPermission(new AudioPermission("*"));
} catch (SecurityException e) {
isSoundAccessDenied = true;
}
}
}
public static void main(String args[]) {
Synthesizer synth = null;
MidiChannel mChanArr[];
MidiChannel chan = null;
boolean failed = false;
int i = 0;
int chanNum = 0;
int val = 16;
int contr = 39; //Channel volume LSB
try {
synth = MidiSystem.getSynthesizer();
synth.open();
mChanArr = synth.getChannels();
while ((i < mChanArr.length) && (chan == null)) {
chanNum = i;
chan = mChanArr[i++];
}
if (chan == null) {
System.err.println("No channels in this synthesizer!");
System.exit(0);
}
chan.controlChange(contr, val);
if (chan.getController(contr) != val) {
System.out.println("Controller(" + contr +") does not
supported. It's Ok. "
+ " value: " + chan.getController(contr));
}
//Channel volume MSB
chan.controlChange((contr - 32), val);
if (chan.getController(contr - 32) != (val*7)) {
failed = true;
System.err.println("Controller(" + (contr - 32) + ") does not
return proper"
+ " value: " + chan.getController((contr - 32)));
}
//Channel volume LSB
if (chan.getController(contr) != 0) {
failed = true;
System.err.println("Controller(" + contr +") does not return
proper"
+ " value: " + chan.getController(contr));
}
} catch (MidiUnavailableException mue) {
System.err.println("MidiUnavailableException was thrown: " + mue);
System.err.println("could not test.");
} catch(SecurityException se) {
if (isSoundAccessDenied) {
System.err.println("No permissions to "
+ "open device!");
System.exit(1);
}
se.printStackTrace();
System.err.println("Sound access is not denied but "
+ "SecurityException was thrown!");
} finally {
if (synth != null) synth.close();
}
if( failed ) {
System.err.println("test failed");
System.exit(1);
} else {
System.out.println("OKAY");
System.exit(0);
}
}
}
---------------------------Logs-------------------------------------------
novo101:templates$ javac test.java; java -showversion test
java version "1.4.1-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-rc-b17)
Java HotSpot(TM) Client VM (build 1.4.1-rc-b17, mixed mode)
Controller(39) does not supported, It's Ok, value: 0
Controller(7) does not return proper value: 16
test failed
--------------------------------------------------------------------------
======================================================================