-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBeatListener.pde
30 lines (26 loc) · 919 Bytes
/
BeatListener.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
class BeatListener implements AudioListener {
private BeatDetect beat;
private AudioPlayer source;
BeatListener(BeatDetect beat, AudioPlayer source) {
this.source = source;
this.source.addListener(this);
this.beat = beat;
}
void samples(float[] samps) {
beat.detect(source.mix);
}
void samples(float[] sampsL, float[] sampsR) {
beat.detect(source.mix);
}
void onset(int time, int val) {
// Add conditions to trigger actions based on onset values at specific indices
if (time == 2 && val > 100) {
// Trigger an action for onset at index 2 with a threshold value of 100
// Example: arduino.digitalWrite(ledPin11, Arduino.HIGH);
} else if (time == 4 && val > 100) {
// Trigger an action for onset at index 4 with a threshold value of 100
// Example: arduino.digitalWrite(ledPin9, Arduino.HIGH);
}
// Add more conditions as needed
}
}