# Car Alarm in =>

So I’m taking this Beginning Object-Oriented Programming class this semester with the hopes of getting into the beginning robot-music-making-cool-awesome class next Fall. Music tech school? Yes please! Here’s the ChucK code for anyone who happens to need a car alarm. (And yes, I’m still drawing, just not uploading much…. yet!) 😀
I’d totally attach an audio file if I knew how. Right now we’re working directly in miniAudicle, so if you download that then you can hear the car alarm in all its glory 😛

//===========================================//
// Author: Tahnee Gehm //
// Assignment: 1 “Hello, ChucK. Make sound!” //
// Date: September 17, 2010 //
//===========================================//

<<<“Tahnee Gehm – Assignment 1”>>>;

//START 1
TriOsc a => dac;
.1 => a.gain;
int freqa;
1300 => freqa; //Starting frequency here
int checka;
0 => checka; //making sub-counter exist
for (0 => int asound; asound < 1; 0 == asound) { freqa => a.freq;
freqa –; //lowering sound
.0007::second => now; //in these increments

if(freqa <500) { 1300 => freqa; //if below 500, reset high
checka ++; //add 1 to sub-counter in loop
//<<>>;
if (checka > 7)
{
0 => a.gain;
1 => asound; //sub counter affects main counter, ends loop
}
}
}
//END 1

//START 2

SinOsc b => dac;
0 => int bcounter;
while (bcounter < 16) //Loops all the for statements 16 times { float gainb; .2 => gainb; //shhhhhh, don’t blow out your eardrums
gainb => b.gain;
int freqb;
1500 => freqb; //starting high

for (0 => int countb_a; countb_a < 1000; countb_a == 0) { freqb++; //increase frequency freqb => b.freq;
//<<>>;
.00015::second => now;
countb_a++; //sends to part b_b
}
for (0 => int countb_b; countb_b < 1000; countb_b == 0) { freqb–; //decrease frequency freqb => b.freq;
//<<>>;
.00015::second => now;
countb_b++; //ends to part b_a; rinse/repeat
}
bcounter ++;//for statements have gone through once; add 1 to counter
}

0 => b.gain;

//END 2

<<<“Turn off your @#\$^&* car alarm!”>>>;

//START 3
TriOsc c => dac;
.2 => c.gain;
int freqc;
1000 => freqc;

for (0 => int csound; csound < 16; csound == 0) { freqc –; //lowering frequenC (pun intended) freqc => c.freq;
//<<>>;
.00025::second => now;
if (freqc == 200)
{
1000 => freqc;
csound ++; //add to main counter
}
if (csound == 16)
{
0 => c.gain; //silence after loop ends
}
}

//END 3

//START 4
SqrOsc d => dac;
SawOsc dd => dac; //extra buzz, closer to “authentic”
.05 => d.gain;
.05 => dd.gain;
for (0 => int dsound; dsound < 4; dsound == 0) { 420 => d.freq;
420 => dd.freq;
.8::second => now; //starting frequency
650 => d.freq;
650 => dd.freq;
.8::second => now; //ending frequency; ping-pong effect
dsound ++; //add to main counter
//<<>>;
if (dsound == 4)
{
0 => d.gain;
0 => dd.gain; //silence when main counter is maxed out
}
}

//END 4

<<<“I SAID TURN OFF THAT !#@\$^% CAR ALARM!”>>>;
//har har har

//START 5
SqrOsc e => dac;
.2 => e.gain;

int freqe;
200 => freqe;

for (0 => int countf; countf < 2; 0 == countf) { freqe ++; freqe => e.freq;
//<<>>;
.006::second => now;
if (500 == freqe)
{
0 => e.gain;//brief pause
.3::second => now;
.2 => e.gain;
200 => freqe;
countf ++;
}
if (countf == 2) //when counter ends…
{
0 => e.gain; //…shhhh
}
}

//END 5

//START 6
SawOsc f => dac;
TriOsc ff => dac; //added buzzzzzz

220 => f.freq;
220 => ff.freq;
.2 => float gainf;
int countf; //sub-counter
0 => countf;
for (0 => int soundf; soundf < 1; 0 == soundf) { .2 => gainf;
gainf => f.gain;
gainf => ff.gain;
countf ++;
//<<>>;
.25::second => now;

0 => gainf;
gainf => f.gain;
gainf => ff.gain;
.25::second => now;

if (countf > 7)
{
1 => soundf; //end main counter
}
}
//END 6

//RE-START A, BUT AS G
TriOsc g => dac;
.1 => g.gain;
int freqg;
1300 => freqg;
int checkg;
0 => checkg;
for (0 => int gsound; gsound < 1; 0 == gsound) { freqg => g.freq;
freqg –;

.0007::second => now;

if(freqg <500) { 1300 => freqg;
checkg ++;
//<<>>;
if (checkg > 4)
{
0 => g.gain;
1 => gsound;
}
}
}
//END A

//Okay, I’ll turn it off…

SqrOsc h => dac;
float gainh;
int freqh;
800 => freqh; //starts pretty high

for (0 => int hclock; hclock <2; hclock == 0) { .1 => gainh; //Working with Sqr; trying to not annoy neighbors
gainh => h.gain;

freqh ++;
freqh => h.freq;
//<<>>;
.0004::second => now;

if (freqh > 1000) //gets high enough–
{
hclock ++;
0 => h.gain; //brief pause
.2::second => now;
800 => freqh; //re-set freq, will loop ++
.1 => gainh; //once maxed out, everything ends
}
}
//Car alarm off!
<<<“Car alarm turned off. Happy?”>>>;