Search Results

Search found 1 results on 1 pages for 'ksemeks'.

Page 1/1 | 1 

  • MidiSystem.getSequencer() returns Audio Device Unavailable

    - by ksemeks
    I've keep having an exception thrown, on and on. When i try to make a new Sequencer object, i keep getting the javax.sound.midi.MidiUnavailableException: Audio Device Unavailable exception. So, here's the code: import javax.sound.midi.*; public class MiniMusicPlayer1 { public static void main(String[] args) { try { Sequencer sequencer = MidiSystem.getSequencer(); sequencer.open(); Sequence seq = new Sequence(Sequence.PPQ, 4); Track track = seq.createTrack(); for (int i = 5; i < 61; i += 4) { track.add(makeEvent(144, 1, i, 100, i)); track.add(makeEvent(128, 1, i, 100, (i+2))); } sequencer.setSequence(seq); sequencer.setTempoInBPM(220); sequencer.start(); } catch (Exception e) { e.printStackTrace(); } } public static MidiEvent makeEvent(int comd, int chan, int one, int two, int tick) { MidiEvent event = null; try { ShortMessage a = new ShortMessage(); a.setMessage(comd, chan, one, two); event = new MidiEvent(a, tick); } catch (Exception e) { e.printStackTrace(); } return event; } } And here's the complete error (at compile): javax.sound.midi.MidiUnavailableException: Audio Device Unavailable at com.sun.media.sound.MixerSynth.implOpen(MixerSynth.java:165) at com.sun.media.sound.AbstractMidiDevice.doOpen(AbstractMidiDevice.java:144) at com.sun.media.sound.AbstractMidiDevice.openInternal(AbstractMidiDevice.java:134) at com.sun.media.sound.AbstractMidiDevice.getReceiverReferenceCounting(AbstractMidiDevice.java:339) at javax.sound.midi.MidiSystem.getReceiver(MidiSystem.java:243) at javax.sound.midi.MidiSystem.getSequencer(MidiSystem.java:442) at javax.sound.midi.MidiSystem.getSequencer(MidiSystem.java:348) at MiniMusicPlayer1.main(MiniMusicPlayer1.java:9) First i was unable to play MIDI files on my pc, but then i got it to work, so now i can play MIDI files, that's okay. I tried even to close every process which uses my sound card, but the error is still there. Anyone can help me?

    Read the article

1