Hi ,
I would like my program switch on the same case automatically, in order to actualise data from void draw.
For the moment, I have to tap on the shift key to actualise the case ‘default’. In this way, each time I tap on the shift key, I have my new datas parameterised in my case ‘default’.
I would like to do the same think, but rather than I tap on the keyboard, I would like my program trig by itself the case ‘default’ or the case ‘1’ … , with ???, an order, a function, I don’t know.
Actually, i want my program automatise the switch to the same case or an other case, to actualise my data which come from void draw ().
Thanks for yours lights!
I put a part of my program below
// in void draw
kickSize = constrain(kickSize * 0.95, 16, 32);
snareSize = constrain(snareSize * 0.95, 16, 32);
hatSize = constrain(hatSize * 0.95, 16, 32);
k = map (kickSize, 16, 32, 1,2); //beat
s = map (snareSize, 16, 32, 1,2); // kick
h = map (hatSize, 16, 32, 1,2);// snare
/*
println (k);
println (s);
println (h);
println();
*/
if ( k > 1.5 ) { // if the beat is louder 1.5 switch on case 7 with doit();
doit();
float v= frequencyEnergy(k);
}
}
float frequencyEnergy (float dVal) {
dVal= dVal *1;
return dVal;
}
void doit() {
if (k>1.7){
print ("Frequency_ENERGY");println (k); println(frequencyEnergy(k));
key='7';
}
}
void keyPressed() {
doit (); //The program does = each time I push the shift key AND kick is upper
// than 1.7--> go on case 7
// otherwise program switch on the case 0 == if (k<1.7) AND i push on the
// shift key, it actualise case 0 with new value of k, s, h (kick, snare, hat) .
switch (key) {
default:
// noiseDetail(mouseX/30, mouseY/300);
net.naturalFrequency[0] = frequencyEnergy(k)*TWO_PI * noise(t);
t += dt;
net.naturalFrequency[1] = 1.0*s*TWO_PI * noise(t);
t += dt;
net.naturalFrequency[2] = 1.0*h*TWO_PI * noise(t);
t += dt;
net.naturalFrequency[3] = 0.9*TWO_PI * noise(t);
t += dt;
net.naturalFrequency[4] = 1.1*TWO_PI * noise(t);
t += dt;
println ("DEFAULT");
print ("Kick"); println (k);
print ("snare"); println (s);
print ("hat"); println (h);
println ();
print ("Freq Energy Kick"); println(frequencyEnergy(k));;
break;
case '7':
doit();
noiseDetail(mouseX/30, mouseY/300);
net.naturalFrequency[0] = 1.0f*k*TWO_PI * noise(t);
t += dt;
net.naturalFrequency[1] = 1.0f*s*TWO_PI * noise(t);
t += dt;
net.naturalFrequency[2] = 1.0f*h*TWO_PI * noise(t);
t += dt;
net.naturalFrequency[3] = 0.9f*TWO_PI * noise(t);
t += dt;
net.naturalFrequency[4] = 1.1f*TWO_PI * noise(t);
t += dt;
print ("Frequency-Energy inside case 7: "); println(frequencyEnergy(k));
print ("Kick"); println (k);
println(s);
println (h);
println ();
println ();
break;
}
}