Skip to content

Instantly share code, notes, and snippets.

@ssaurel
Created March 20, 2018 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssaurel/96ae4b3e5ff5c6b3fb70efe381968e72 to your computer and use it in GitHub Desktop.
Save ssaurel/96ae4b3e5ff5c6b3fb70efe381968e72 to your computer and use it in GitHub Desktop.
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