Assignment 9.1

posted Jul 15, 2010, 10:13 AM by Unknown user

I built a completely new circuit for this one. I got rid of the push buttons and added two potentiometers attached to analog pins 0 and 4 so that I could get two analog values to control the frequency(pitch) and amplitude(volume).

void setup() { size(400, 220, P2D); // sets window size minim = new Minim(this); // get a line out from Minim with default bufferSize, sample rate, and bit depth out = minim.getLineOut(Minim.STEREO); // create a sine wave oscillator, set to value of freq, value of amp, sample rate from line out sine = new SineWave(freq, amp, out.sampleRate()); // set the portamento speed on the oscillator to 200 milliseconds sine.portamento(200); // add the oscillator to the line out out.addSignal(sine); // declares myPort and begins serial communication at 9600 bps myPort = new Serial(this, Serial.list()[0], 9600); // store values from myPort in a buffer until value is reached myPort.bufferUntil('\n');