I could not get my code to compile, I even copied the code from the github here it is
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 ex) {
ex.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;
}
}
I type in javac MiniMusicPlayer1.java
and it gives me a number of errors, all related to midievent. The first error says Midievent.java:1 error: class...expected.
The main error I see is
"cannot access Midievent...bad source file .\MidiEvent.java.....file does not contain class MidiEvent....Please remove or make sure it appears in the correct subdirectory of the sourcepath
What could the problem be? I read other people using the same code without issues