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

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 com.sun.media.sound.HeadspaceMixer.open(HeadspaceMixer.java:628)
at com.sun.media.sound.AbstractPlayer.open(AbstractPlayer.java:138)
at MiniMusicPlayer1.main(MiniMusicPlayer1.java:11)

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
  • 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Should localization be done inside spring controller 5 32
hibernate insert example 13 34
jsp insert to database example 2 46
Java 8 to Java 6 8 20
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

839 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