United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4685396 : method Synthesizer.remapInstrument() does not work

Details
Type:
Bug
Submit Date:
2002-05-15
Status:
Resolved
Updated Date:
2006-07-19
Project Name:
JDK
Resolved Date:
2006-07-19
Component:
client-libs
OS:
generic
Sub-Component:
javax.sound
CPU:
generic
Priority:
P2
Resolution:
Fixed
Affected Versions:
1.4.1
Fixed Versions:

Related Reports
Duplicate:
Relates:

Sub Tasks

Description
Name: vtR10009			Date: 05/15/2002


  Spec for Synthesizer.remapInstrument() from the package
javax.sound.midi reads:
" Remaps an instrument. Instrument to takes the place of instrument from. 
For example, if from was located at bank number 2, program number 11, 
remapping causes that bank and program location to be occupied instead 
by to. Instrument from is unloaded.
  Parameters:
     from - instrument to be replaced
     to - new instrument to be used in place of the old instrument
  Returns:
     true if the instrument could be remapped, false otherwise."

But default synthesizer does not unload "from" instrument and load "to"
instead. Such behavior contradicts to the spec.

This bug causes failure of new JCK test:
  api/javax_sound/midi/Synthesizer/index.html#remap
  
To reproduce the bug run the following test with JDK build with 1.4.1-beta-b11:
------------------------------- test.java --------------------------------
import javax.sound.midi.*;

public class test{
    public static boolean isInstrumentExist(Instrument inst, Instrument[] 
instArr) {
        for (int i = 0; i < instArr.length; i++) {
            if (inst.equals(instArr[i])) return true;
        }
        return false;
    }
    public static void main(String args[]) {
        boolean failed = false;
        Synthesizer synth = null;
    
        Instrument[] instrs, avInstrs;
        Instrument from, to;
        Soundbank sBank;
    
        try {
            synth = MidiSystem.getSynthesizer();
            synth.open();
    
            instrs = synth.getLoadedInstruments();
            for (int i = 0; i < instrs.length; i++) {
                synth.unloadInstrument(instrs[i]);
            }
    
            if (instrs.length != 0) {
                System.err.println(" Non-zero length array!");
                failed = true;
                for (int i = 0; i < instrs.length; i++) {
                    System.err.println("Instrument: " + instrs[i]);
                }
            }
            
            sBank = synth.getDefaultSoundbank();
            if (sBank == null) {
                System.err.println("No default bank. Ok.");
                System.exit(1);
            }
    
            instrs = sBank.getInstruments();
            if (synth.loadAllInstruments(sBank)) {
                synth.unloadInstrument(instrs[instrs.length - 1]);
                from = instrs[0];
                to = instrs[instrs.length - 1];
                if (!synth.remapInstrument(from, to)) {
                    System.err.println(" Instrument does not mapped!");
                    failed = true;
                } else {
                    if (isInstrumentExist(from, synth.getLoadedInstruments())) {
                        System.err.println(" Instrument from is not unloaded.");
                        failed = true;
                    }
                    if (!isInstrumentExist(to, synth.getLoadedInstruments())) {
                        System.err.println(" Instrument to is not correctly" +
                                   mapped.");
                        failed = true;
                    }
                }
            }
            
    
        } catch (MidiUnavailableException mue) {
            System.err.println("MidiUnavailableException was thrown: " + mue);
            System.exit(1);
        } finally {
            if (synth != null) synth.close();
        }
    
        if (failed == true) {
            System.exit(1);
        } else {
            System.exit(0);
        }
    }
}
---------------------------Logs-------------------------------------------
novo101:templates$ javac test.java ; java -showversion test
java version "1.4.1-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-beta-b11)
Java HotSpot(TM) Client VM (build 1.4.1-beta-b11, mixed mode)

 Instrument from is not unloaded.
 Instrument to is not correctly mapped.

--------------------------------------------------------------------------
======================================================================

                                    

Comments
EVALUATION

It looks like native code remaps the instrument and after remap new instrument sounds instead replaced one, but java implementation doesn't change its instrument list accordingly.
Also implementation doesn't unload "from" instrument.
It's too risky to fix in mustang, retargeting to dolphin.
                                     
2005-10-07
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
dragon


                                     
2004-06-14
PUBLIC COMMENTS

method ramapInstrument does not work
                                     
2004-06-10
EVALUATION

###@###.### 2002-05-15
	Implementations should have the possibility to not implement this feature. Committing to Mantis.

###@###.### 2002-11-25
	Further investigation showed that this is really an implementation problem - it seems that the implementation does not really remaps the instrument, but reports true. Committing to Tiger. The TCK test should be adapted to not fail when remapIntrument returns false.


###@###.### 2003-09-22
	No time for tiger. Commit to dragon.
                                     
2003-09-22



Hardware and Software, Engineered to Work Together