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

SPEC: get/set Mono and Omni do not work

    XMLWordPrintable

Details

    Description



      Name: vtR10009 Date: 07/23/2002


        The MidiChannel methods to get/set Mono and Omni
      state do not function at all. They are not implemented for
      default synthesizer.

      This bug causes failure of new JCK tests:
       api/javax_sound/midi/MidiChannel/index.html#Mono
       api/javax_sound/midi/MidiChannel/index.html#MuteOmni
       
      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;
              Receiver rcvr;
              ShortMessage msg = new ShortMessage();
              long timeStamp = -1;
              int i = 0;
              int chanNum = 0;

              int val = 10;
              int noteNumber = 60;
              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(1);
                  }
           
                  chan.setMono(true);
          
                  if (!chan.getMono()) {
                      failed = true;
                      System.err.println("getMono() does not return true!");
                  }
          
                  chan.setOmni(true);
          
                  if (!chan.getOmni()) {
                      failed = true;
                      System.err.println("getOmni() does not return true!");
                  }

                  chan.setOmni(true);

                  if (chanNum == 0) {
                      msg.setMessage(ShortMessage.PROGRAM_CHANGE, (chanNum + 1), 17,
      0);
                  } else {
                      msg.setMessage(ShortMessage.PROGRAM_CHANGE, (chanNum - 1), 17,
      0);
                  }
                  rcvr = synth.getReceiver();
                  rcvr.send(msg, timeStamp);

                  if (chan.getProgram()!= 17) {
                      System.err.println("getProgram() returns:" + chan.getProgram());
                      failed = true;
                      System.err.println("the channel does not respond to messages "
                              + "sent on other!");
                  }
                  
              } catch (MidiUnavailableException mue) {
                  System.err.println("MidiUnavailableException was thrown: " + mue);
                  System.err.println("could not test.");
              } catch(InvalidMidiDataException invMDEx) {
                  invMDEx.printStackTrace();
                  failed = true;
                  System.err.println("InvalidMidiData was thrown!");
              } 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)

      getMono() does not return true!
      getOmni() does not return true!
      getProgram() return:0
      the channel does not respond to messages sent on other!
      test failed

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

      Attachments

        Issue Links

          Activity

            People

              fbomerssunw Florian Bomers (Inactive)
              vitcsunw Vitc Vitc (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: