Problem with duration in SoundCipher
in
Contributed Library Questions
•
1 month ago
Hi, I have this code, but my problem is that the durations don't change, I tried with different values but the result is the same, does anyone know how can I do? I´ll try to do a musical score but I need to change the values of durations depending of the notes.
import arb.soundcipher.*;
import arb.soundcipher.constants.*;
SoundCipher part1 = new SoundCipher(this);
float[] pitches = {69, 69, 76, 76, 78, 78, 76, 74, 74, 73, 73, 71, 71, 69};
float[] dynamics = new float[pitches.length];
float[] durations = {0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 1, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 1};
float y;
int n = 0;
float xLoc = 0.0;
void setup() {
for (int i=0; i<pitches.length; i++) {
dynamics[i] = random(40) + 70;
}
background(0);
size(640, 360);
stroke(255);
frameRate(2);
}
void draw() {
if (n >= pitches.length) {
n = 0;
}
if (xLoc > width) {
background(0);
xLoc = 0.0;
}
line(xLoc, height-3*pitches[n], xLoc + 15.0 , height-3*pitches[n]);
part1.playNote(pitches[n], dynamics[n], durations[n]);
n += 1;
xLoc += 20.0;
}
void stop() {
part1.stop();
}
1