Created
March 20, 2018 11:08
-
-
Save ssaurel/96ae4b3e5ff5c6b3fb70efe381968e72 to your computer and use it in GitHub Desktop.
playNote, stopNote and isNotePlaying implementations for the Piano tutorial
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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