• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

JavaSound

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Everyone!

I am new to Java and learning through HeadFirst.

MidiSystem.getSequencer() is throwing exception.

Even my system is having four MidiDevices(software implemented).


The exception is:
javax.sound.midi.MidiUnavailableException: MIDI OUT transmitter not available

How to solve the issue?

Please help!

Thanks and Regards,
Charanjeet singh
 
Charanjeet dhaliwal
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This problem is solved.

But now the program is not making any sound?

import javax.sound.midi.*;

public class MiniMusicApp{
public static void main(String[] args){
MiniMusicApp mini = new MiniMusicApp();
mini.play();
}

public void play(){
try{

MidiDevice.Info[] deviceInfo = MidiSystem.getMidiDeviceInfo();

System.out.println(deviceInfo.length);

MidiDevice md = null;


for(int i = 0;i < deviceInfo.length;i++){
if(deviceInfo[i].getName().contains("Sequencer"))
md = MidiSystem.getMidiDevice(deviceInfo[i]);
System.out.println(deviceInfo[i].getName() + " : " + deviceInfo[i].getVendor());
}


Sequencer player = (Sequencer)md;
player.open();

Sequence seq = new Sequence(Sequence.PPQ,4);

Track track = seq.createTrack();


ShortMessage a = new ShortMessage();
a.setMessage(144,1,44,100);
MidiEvent noteOn = new MidiEvent(a,1);
track.add(noteOn);



ShortMessage b = new ShortMessage();
b.setMessage(128,1,44,100);
MidiEvent noteOff = new MidiEvent(b,1);
track.add(noteOff);

player.setSequence(seq);

player.start();
}
catch(Exception e){
e.printStackTrace();
}
}
}


Please Help...
 
Ranch Hand
Posts: 1164
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch Charanjeet. I would suggest you study the "OCJP for java 6" book by Kathy Sierra and Bert Bates if you are new to the language. It is written in lay man language and easy to understand. You need to get the fundamentals crystal clear.
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic