I have Java programming Related problems

when i run this program,it does nothing........it should produce sound but nothing.............What to do????



import javax.sound.midi.*;
class MiniMusicPlayer1
{
public static void main(String args[])
{
try
{
Sequencer sequencer = MidiSystem.getSequencer();
sequencer.open();

Sequence seq = new Sequence(Sequence.PPQ,1);
Track track = seq.createTrack();

for(int i=5;i<61;i=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)
{}
return event;

}
}

Replies

  • CEMember
    CEMember
    Hey sahilgandhi !

    What a superb work you have done ๐Ÿ˜€ Your program is perfectly working fine for me. It is making sound like someone is beating some musical instrument (I guess guitar or piano ๐Ÿ˜‰) very hardly.

    Check may be there is some problem in your computer system. You are not getting any compiler errors right? then just please wait for few seconds for listening the sound ๐Ÿ˜€
  • ms_cs
    ms_cs
    Only a single syntax error shown for me...
    Very superb program...If you have similar programs post it here.....
  • komputergeek
    komputergeek
    @sahilgandhi87: Nice program.Working fine.
  • CEMember
    CEMember
    ms_cs
    Only a single syntax error shown for me...
    Very superb program...If you have similar programs post it here.....
    Man, what syntax error it showed for you? ๐Ÿ˜• It was perfectly fine for me .
  • komputergeek
    komputergeek
    Even I am not getting any syntax error.
  • ms_cs
    ms_cs
    CEMember
    Man, what syntax error it showed for you? ๐Ÿ˜• It was perfectly fine for me .
    No ,,,While Copying the program I just missed some of the text

You are reading an archived discussion.

Related Posts

hi, please tell me from where can i download the rational rose class diagram developer?
I want to design two stage gear box with helical gears. Can u help me?
I'm not sure if I've posted this before. Do take a moment to look here - Thank an Engineer
hi , today when i opend my pc i tryed to open my oracle sql plus i entered username and paswerd username as :system password as i was using earliar...
Blu-ray disk is avalable in india??? and what is it's prices ??? what is it's writters prices???