SoundCipher playNote duration
in
Contributed Library Questions
•
7 months ago
I am trying to make an app with piano keys, and when you click on the keys, a note plays. I want to change the duration of the note based on how long the key is pressed, so timing from mousePressed() to mouseReleased(). I have the math, but I don't know how to use this as the duration of the current note, because the duration is already defined when the note starts, so it just uses the length that the previous key was clicked. Is there a way to have the length of the note defined by the length that the piano key is pressed?
Here is some of my code:
import arb.soundcipher.*;
int difftime;
int ptime;
int d;
void mouseReleased() {
difftime = millis() - ptime;
d = difftime/1000;
}
void mousePressed () {
ptime = millis();
sc.playNote(60, 100, d);
}
1