Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4685396

method Synthesizer.remapInstrument() does not work

    Details

    • Subcomponent:
    • Resolved In Build:
      b80
    • CPU:
      generic
    • OS:
      generic

      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.

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

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                amenkov Alex Menkov
                Reporter:
                vitcsunw Vitc Vitc (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: