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;
}
}
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
-
CEMemberHey 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_csOnly a single syntax error shown for me...
Very superb program...If you have similar programs post it here..... -
komputergeek@sahilgandhi87: Nice program.Working fine.
-
CEMember
Man, what syntax error it showed for you? ๐ It was perfectly fine for me .ms_csOnly a single syntax error shown for me...
Very superb program...If you have similar programs post it here..... -
komputergeekEven I am not getting any syntax error.
-
ms_cs
No ,,,While Copying the program I just missed some of the textCEMemberMan, what syntax error it showed for you? ๐ It was perfectly fine for me .
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???