Instantly share code, notes, and snippets.

Embed
What would you like to do?
playNote, stopNote and isNotePlaying implementations for the Piano tutorial
public void playNote(int note) {
if (!isNotePlaying(note)) {
PlayThread thread = new PlayThread(note);
thread.start();
threadMap.put(note, thread);
}
}
public void stopNote(int note) {
PlayThread thread = threadMap.get(note);
if (thread != null) {
threadMap.remove(note);
}
}
public boolean isNotePlaying(int note) {
return threadMap.get(note) != null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment