MidiUnavailableException question

Posted on 2004-03-24
Last Modified: 2012-06-21
    The following code complies but at runntime I get the following error:

javax.sound.midi.MidiUnavailableException: Audio Device Unavailable
at MiniMusicPlayer1.main(

Can someone tell me why I get this error and how can I fix it?

import javax.sound.midi.*;

public class MiniMusicPlayer1
{  public static void main(String[] args)
      Sequencer sequencer = MidiSystem.getSequencer();;
      Sequence seq = new Sequence(Sequence.PPQ, 4);
      Track track = seq.createTrack();
      for (int i = 5; i < 61; i+=4)
         track.add(makeEvent(128,1,i,100,i + 2));
      catch (Exception ex)
   public static MidiEvent makeEvent(int comd, int chan, int one, int two, int tick)
   {  MidiEvent event = null;
      {  ShortMessage a = new ShortMessage();
         a.setMessage(comd, chan, one, two);
         event = new MidiEvent(a, tick);
      catch(Exception e){}
         return event;
Question by:LearningJava
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
LVL 92

Expert Comment

ID: 10674106
Cause the Sequencer is not available :)

If it does exist and is configured correctly perhaps another application is already using it.

Author Comment

ID: 10679864
How do I troubleshoot this problem?
LVL 92

Accepted Solution

objects earned 500 total points
ID: 10682952
Make sure the device is present, and check that no other application is using it.
LVL 92

Expert Comment

ID: 10690651

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question