int k;
int f;
rand2f
pow2
log10
fun void valueshift()
{
SinOsc s => dac;
440 => s.freq;
int i;
f++;
while (i < 50)
{
Std.rand2f(200, 1000) => s.freq;
Std.rand2f(10, 500)*1::ms => now;
i++;
}
f--;
}
while (k < 6)
{
spork~ valueshift();
2000::ms => now;
k++;
}
while (f > 0 )
{
500::ms => now;
}
ChucK Source file here.
int scorelength;
Std.rand2(10, 30) => scorelength;
int score[scorelength];
float beat[scorelength];
int ups;
int downs;
int change;
int extra;
int doublebar;
float f;
scorelength / 4 $ int => doublebar;
<<< "scorelength", scorelength >>>;
scorelength * 0.4 => f;
f $ int => ups;
<<< "ups", ups >>>;
scorelength * 0.4 => f;
f $ int => downs;
<<< "downs", downs >>>;
scorelength * 0.2 => f;
f $ int => change;
<<< "change", change >>>;
scorelength - ups - downs - change => extra;
change + extra => change;
<<< "change + extra", change >>>;
int i;
int control;
0 => int shift;
function void upper(int move){
score[i-1] + move + shift => score[i];
ups--;
}
function void downer(int move){
score[i-1] - move + shift => score[i];
downs--;
}
function void changer(int move){
score[i-1] + move + shift => score[i];
change--;
}
function void rythmscore(){
<<< "rythm" >>>;
int kk;
for (1 => int ii; ii < scorelength; ii++)
{
1 => beat[ii];
kk++;
if (kk == 3){
if (maybe){
0.7 => beat[ii];
} else 1.3 => beat[ii];
}
if (kk > doublebar){
0 => kk;
if (maybe){
2.54 => beat[ii];
} else 4.56 => beat[ii];
}
}
}
function void makescore() {
<<< "score" >>>;
1 => score[0];
for (1 => i; i < scorelength; i++)
{
if (score[i-1] == 7)
{
8 => shift;
}
if (shift == 8){
if (score[i-1] == 11){
0 => shift;
}
}
0 => control;
<<< "shift", shift >>>;
if (ups > 0)
{
control + 1 => control;
}
if (downs > 0)
{
control + 2 => control;
}
if (change > 0){
control + 4 => control;
}
<<< "control" , control >>>;
if (control == 0){
Std.rand2(0,2) => int choice;
<<< "choice", choice >>>;
if (choice == 0){
upper(4);
}
if (choice == 1){
downer(4);
}
if (choice == 2){
changer(-8);
}
}
if (control == 1){
upper(2);
}
if (control == 2){
downer(2);
}
if (control == 3){
if (maybe){
upper(3);
}else downer(3);
}
if (control == 4){
changer(5);
}
if (control == 5){
if (maybe){
upper(5);
}else changer(6);
}
if (control == 6){
if (maybe){
downer(3);
}else changer(3);
}
if (control == 7){
Std.rand2(0,2) => int choice;
<<< "choice", choice >>>;
if (choice == 0){
upper(4);
}
if (choice == 1){
downer(2);
}
if (choice == 2){
changer(5);
}
}
}
}
makescore();
rythmscore();
SinOsc s => Envelope env => dac;
1 => env.value;
0.1 => s.gain;
while (true){
int j;
for (1 => j; j < scorelength; j++)
{
<<< "score: ", score[j] >>>;
if (Std.mtof(score[j] + 69.0) > 100){
if (Std.mtof(score[j] + 69.0) < 2000){
Std.mtof(score[j] + 69.0) => s.freq;
}
}
<<< "freq: ",s.freq() >>>;
130::ms => env.duration;
1.0 => env.target;
1 => env.keyOn;
100::ms => now;
beat[j] * 500::ms => now;
130::ms => env.duration;
0.0 => env.target;
1 => env.keyOn;
400::ms => now;
<<< "beat: ", beat[j] >>>;
}
makescore();
rythmscore();
<<< "next score" >>>;
150::ms => env.duration;
0.0 => env.target;
1 => env.keyOn;
1000::ms => now;
0 => env.keyOff;
1 => env.value;
}
ChucK Source file here.