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

Sequencer cannot access external MIDI devices

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P4
    • None
    • 2.1
    • client-libs

    Description



      Name: jk109818 Date: 11/22/2002


      FULL PRODUCT VERSION :
      java version "1.4.1_01"

      FULL OPERATING SYSTEM VERSION :
      Microsoft Windows XP [Version 5.1.2600]

      ADDITIONAL OPERATING SYSTEMS :

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      I use some software synths and a midi loopback device, but
      it should be ok to test with the internal Windows software
      synthesizer only (and maybe some external hardware gears).

      I use the following midi configuration:
      1. Internal Windows software synthesizer (appears as midi device)
      2. Roland Virtual Sound Canvas Ver.3 (appears as midi device)
      3. Midi Yoke NT driver (loopback midi device)
      4. D-Lusion Rubber Duck 2 (connected via Midi Yoke)
      5. Orion Professional (connected via Midi Yoke)

      This configuration is verified with another sequencer program.
      I was able to control 1 and 2 directly as midi device and
      4 and 5 via the Midi Yoke loopback device.

      Here are the midi devices listed by the sample program:
      1 Java Sound Synthesizer
      2 Java Sound Sequencer
      3 Microsoft MIDI-Mapper
      4 Roland VSC

      5 MIDI Yoke NT: 1
      6 MIDI Yoke NT: 2
      7 MIDI Yoke NT: 3

      8 MIDI Yoke NT: 4
      9 MIDI Yoke NT: 5
      10 MIDI Yoke NT: 6

      11 MIDI Yoke NT: 7
      12 MIDI Yoke NT: 8
      13 Microsoft GS Wavetable SW Synth
      14 MIDI Yoke NT: 1

      15 MIDI Yoke NT: 2
      16 MIDI Yoke NT: 3
      17 MIDI Yoke NT: 4

      18 MIDI Yoke NT: 5
      19 MIDI Yoke NT: 6
      20 MIDI Yoke NT: 7

      21 MIDI Yoke NT: 8


      A DESCRIPTION OF THE PROBLEM :
      javax.sound.midi.MidiSystem.getMidiDeviceInfo() lists
      all midi devices correctly, but the sequencer
      javax.sound.midi.Sequencer uses only the internal
      wavetable sequencer of the VM. It's not possible
      to redirect the midi stream to an external midi
      device (e.g. the Windows software synthesizer).
      I have only software synths in my system, but
      I bet it doesn't work for external hardware
      synths, too.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Compile the sample code ('javac Midiplayer.java').
      2. Run the class without parameters to get a list
      of the available midi devices ('java Midiplayer').
      3. Try to play a midi file over an external midi device
      (e.g. 'java MidiPlayer somesong.mid 13'). You will
      always hear the internal Java synthesizer.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      When I choose an external midi out device I expect to
      hear the external gear that listens to this device.
      Actually I hear always the internal Java Sound
      Synthesizer.

      Note: Listen carefully to the sound of the music.
      Use the internal Windows synth for comparation (or
      better: Some non-GM synth). Try to use the Java Sound
      Sequencer ... what's happening? What would you expect?


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.io.*;
      import javax.sound.midi.*;
      import java.util.*;

      public class MidiPlayer
      {
        private static void play(String fileName, int deviceNo)
          throws Exception
        {
          // open midi out device
          MidiDevice.Info [] midiDevices = MidiSystem.getMidiDeviceInfo();
          if(deviceNo < 0 || deviceNo >= midiDevices.length) {
            throw new IllegalArgumentException("Midi device number out of range");
          }
          MidiDevice midiDevice = MidiSystem.getMidiDevice(midiDevices[deviceNo]);
          midiDevice.open();
          // open sequencer
          Sequencer sequencer = MidiSystem.getSequencer();
          Transmitter trans = sequencer.getTransmitter();
          sequencer.open();
          // connect sequencer and midi out device
          trans.setReceiver(midiDevice.getReceiver());
          // play sequence
          Sequence seq = MidiSystem.getSequence(new File(fileName));
          sequencer.setSequence(seq);
          sequencer.start();
          // wait till end of sequence
          while(sequencer.isRunning()) {
            Thread.sleep(100);
          }
          // close all
          sequencer.stop();
          sequencer.close();
          midiDevice.close();
        }

        public static void main(String[] args) {
          if(args.length != 2) { // show help and device info
            System.out.println("Usage:");
            System.out.println("java MidiPlayer [midiFile] [deviceNumber]");
            System.out.println("");
            System.out.println("Midi Devices:");
            MidiDevice.Info [] midiDevices = MidiSystem.getMidiDeviceInfo();
            for(int i = 0; i < midiDevices.length; i++) {
              System.out.println("" + (i + 1) + " " + midiDevices[i].toString());
            }
            System.out.println("");
          } else { // play midi
            try {
              play(args[0], Integer.parseInt(args[1]) - 1);
            } catch(Exception e) {
              e.printStackTrace();
              System.exit(1);
            }
          }
          System.exit(0);
        }
      }

      ---------- END SOURCE ----------
      (Review ID: 173342)
      ======================================================================

      Attachments

        Issue Links

          Activity

            People

              fbomerssunw Florian Bomers (Inactive)
              jkimsunw Jeffrey Kim (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: