I am building a midi piano in java. In this case, I want to play pitches ,record pitches and playback them.
Then I used java thread to add pitch to queue and add delay to queue. I used thread object to these process and call it in constructor. After the call this constructor it gives NullPointException
.
Can you help me found out why?
public PianoPlayer() throws MidiUnavailableException{
queue = new LinkedBlockingQueue<NoteEvent>();
delayQueue = new LinkedBlockingQueue<NoteEvent>();
machine = new PianoMachine(this);
processQueue.start();
processDelayQueue.start();
}
Thread processDelayQueue = new Thread() {
public void run(){
while(true){
if(queue.isEmpty()){
}
else{
try {
NoteEvent e=queue.take();
midi.Midi.wait(100);
queue.put(e);
} catch (InterruptedException ex) {
Logger.getLogger(PianoPlayer.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
};