sahilgandhi87
sahilgandhi87
Branch Unspecified
08 Mar 2009

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;

}
}
CEMember

CEMember

Branch Unspecified
08 Mar 2009
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

Branch Unspecified
08 Mar 2009
Only a single syntax error shown for me...
Very superb program...If you have similar programs post it here.....
komputergeek

komputergeek

Branch Unspecified
08 Mar 2009
@sahilgandhi87: Nice program.Working fine.
CEMember

CEMember

Branch Unspecified
13 Mar 2009
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

Branch Unspecified
14 Mar 2009
Even I am not getting any syntax error.
ms_cs

ms_cs

Branch Unspecified
15 Mar 2009
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

Share this content on your social channels -

Only logged in users can reply.