Results 1 to 3 of 3
  1. #1
    Revenna's Avatar
    Revenna is offline Member
    Join Date
    May 2010
    Location
    West Virginia
    Posts
    8
    Rep Power
    0

    Default MidiUnavailableException

    Hi. I'm working on a program that involves MIDI playback using the Sequencer interface and I'm having an odd problem. I've tried it on two separate computers, both with the same OS (WinXP) and same version of JRE, somehow MidiSystem.getSequencer() fails and throws a MidiUnavailableException on one computer but not the other.

    Here's the output of MidiSystem.getMidiDeviceInfo() on the machine that doesn't work:
    Java Code:
    Java Sound Sequencer
    Software sequencer / synthesizer module
    Sun Microsystems
    Version 1.0
    
    Microsoft MIDI Mapper
    Windows MIDI_MAPPER
    Unknown vendor
    5.0
    
    Microsoft GS Wavetable SW Synth
    Internal software synthesizer
    Unknown vendor
    5.10
    
    Real Time Sequencer
    Software sequencer
    Sun Microsystems
    Version 1.0
    
    Java Sound Synthesizer
    Software wavetable synthesizer and receiver
    Sun Microsystems
    Version 1.0
    And here's the output on the machine where it does work:
    Java Code:
    Microsoft MIDI Mapper
    Windows MIDI_MAPPER
    Unknown vendor
    5.0
    
    Microsoft GS Wavetable SW Synth
    Internal software synthesizer
    Unknown vendor
    5.10
    
    Real Time Sequencer
    Software sequencer
    Sun Microsystems
    Version 1.0
    
    Java Sound Synthesizer
    Software wavetable synthesizer and receiver
    Sun Microsystems
    Version 1.0
    The documentation is pretty clear on what a MidiUnavailableException is, but not what to do when it happens. Where do I go from here?

  2. #2
    m00nchile is offline Senior Member
    Join Date
    Feb 2010
    Location
    Ljubljana, Slovenia
    Posts
    470
    Rep Power
    5

    Default

    Do both computers have the MIDI file in question? Did you hard-code the path to the MIDI file, or made it relative to the path of the class file? If you packaged the MIDI file with your .class file, it's probably a pathing issue.
    Ever seen a dog chase its tail? Now that's an infinite loop.

  3. #3
    Revenna's Avatar
    Revenna is offline Member
    Join Date
    May 2010
    Location
    West Virginia
    Posts
    8
    Rep Power
    0

    Default

    The error is thrown by the constructor when it initializes the Sequencer (which is held in a variable), before any file handling is done.
    Java Code:
        Sequencer sequencer;
    
        public MidiPlayer(){
        }
        try{
            sequencer = MidiSystem.getSequencer();
        }
        catch(MidiUnavailableException e){
            System.out.println("Constructor: MIDI Unavailable"); //<-----Error happens here
        }
    Could I not be doing enough to initialize the sequencer? The system has three or four sequencers, and there aren't any other programs using any of them. Here's what the documentation says:
    Obtains the default Sequencer, connected to a default device. The returned Sequencer instance is connected to the default Synthesizer, as returned by getSynthesizer(). If there is no Synthesizer available, or the default Synthesizer cannot be opened, the sequencer is connected to the default Receiver, as returned by getReceiver(). The connection is made by retrieving a Transmitter instance from the Sequencer and setting its Receiver. Closing and re-opening the sequencer will restore the connection to the default device.
    For some reason that made me try this (info is an Array of MidiDevice.Info):
    Java Code:
            MidiSystem.getSequencer().getTransmitter().setReceiver(MidiSystem.getMidiDevice(info[0]).getReceiver());
    Same error, MidiUnavailableException

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •