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

Different time length in Sequence and Sequencer

XMLWordPrintable

    • tiger
    • generic
    • generic
    • Verified



      Name: vtR10009 Date: 03/28/2002


      Two methods return time length of Midi Sequence in Java Sound API:
        javax.sound.midi.Sequencer.getMicrosecondLength()
        javax.sound.midi.Sequence.getMicrosecondLength()

      But these methods return different values for same sequence in
      JDK RI(1.4.1-beta-b06) and spec does not state anything that could
      imply the time may differ for particular Sequencer.

      This bug causes failure of new JCK test:
        api/javax_sound/midi/Sequencer/index.html#Sequencer

      To reproduce the bug run the following test with JDK build 1.4.1-beta-b06:
      ------------------------------- test.java --------------------------------
      import javax.sound.midi.*;
      import java.io.*;

      public class test{
          public static void main(String args[])
          {
              boolean failed = false;
              File seqfile;
              Sequencer seq = null;
              Sequence midiData = null;
              
              try {
                  seq = MidiSystem.getSequencer();
                  seq.open();
                  seqfile = new File(".", args[0]);
                  midiData = MidiSystem.getSequence(seqfile);
                  seq.setSequence(midiData);
                  if (seq.getMicrosecondLength() != midiData.getMicrosecondLength()) {
                      System.out.println("Sequencer MicrosecondLength was : "
                              + seq.getMicrosecondLength());
                      System.out.println("Sequence MicrosecondLength was : "
                              + midiData.getMicrosecondLength());
                      failed = true;
                  }

              } catch (MidiUnavailableException munEx) {
                  munEx.printStackTrace();
              } catch (InvalidMidiDataException invmEx) {
                  invmEx.printStackTrace();
              } catch (IOException ioEx) {
                  ioEx.printStackTrace();
              }
          
              if( failed ) {
                  System.err.println("Test failed!");
              } else {
                  System.out.println("OKAY");
              }
              System.exit(0);
          }
      }

      ---------------------------Logs-------------------------------------------
      novo101:templates$ java -showversion test metatest.mid
      java version "1.4.1-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-beta-b06)
      Java HotSpot(TM) Client VM (build 1.4.1-beta-b06, mixed mode)

      Sequencer MicrosecondLength was : 31904280
      Sequence MicrosecondLength was : 31879166
      Test failed!
      --------------------------------------------------------------------------
      ======================================================================

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: