P-Comp: Sine Wave of Doom AKA the Poser Theremin

In this week’s lab, we learned about Serial Duplex and continued to learn more about how to get Arduino and Processing to talk to each other.

In my spin on the lab, I hooked up 2 potentiometers through the Arduino to control the frequency and panning of a sine wave in Processing that is manifested on screen and as audio.  I don’t know why I chose red and blue for the sine waves.  Maybe I’ve been watching too much TV coverage of the presidential campaign.  In any case, the effect is that of a sine wave of doom or a poser theremin.

To get Processing to play sound, I used the Minim library.  I basically poached some example code from the Minim site and tweaked it so the sound responds to analog ins from the Arduino instead of mouseX and Y in the original sketch.

IMG_4826

I hope to use more exciting sensors later on to make it more expressive and musical when I get back from fall break next week, but it took me awhile to tweak the software side of things and the computer store was already closed by the time I got around to this. Here it is in action:

My digital camera didn’t pick up the audio very well, so here is an MP3 of some “music” I made.  And here is another attempt.

And finally, here is the Processing code:

import processing.serial.*;     // import the Processing serial library
import ddf.minim.*;
import ddf.minim.signals.*;

Serial myPort;                  // The serial port
AudioOutput out;
SineWave sine;
int sensors[] = new int[2];

int passX;
int passY;

void setup(){
myPort = new Serial(this, Serial.list()[0], 9600);
myPort.bufferUntil(‘\n’);
size(512, 200);
// always start Minim before you do anything with it
Minim.start(this);
// get a line out from Minim, default sample rate is 44100, bit depth is 16
out = Minim.getLineOut(Minim.STEREO, 512);
// create a sine wave Oscillator, set to 440 Hz, at 0.5 amplitude, sample rate 44100 to match the line out
sine = new SineWave(440, 0.5, 44100);
// set the portamento speed on the oscillator to 200 milliseconds
sine.portamento(200);
// add the oscillator to the line out
out.addSignal(sine);
passX = 0;
passY = 0;
}

void draw()
{
background(0,50);
stroke(255);
// draw the waveforms
for(int i = 0; i < out.left.size()-1; i++)
{
stroke(#FF0000); //left is red
line(i, 50 + out.left.get(i)*50, i+1, 50 + out.left.get(i+1)*50);
stroke(#0023FC); //right is blue
line(i, 150 + out.right.get(i)*50, i+1, 150 + out.right.get(i+1)*50);
}
float freq = map(passY, 0, 1023, 1500, 60);
sine.setFreq(freq);
// pan always changes smoothly to avoid crackles getting into the signal
// note that we could call setPan on out, instead of on sine
// this would sound the same, but the waveforms in out would not reflect the panning
float pan = map(passX, 0, 1023, -1, 1);
sine.setPan(pan);
}

void stop()
{
out.close();
super.stop();
}

void serialEvent(Serial myPort)
{
// read the serial buffer:
String myString = myPort.readStringUntil(‘\n’);
myString = trim(myString);
int sensors[] = int(split(myString, ‘,’));
for (int sensorNum = 0; sensorNum < sensors.length; sensorNum++)
{
// print(“Sensor ” + sensorNum + “: ” + sensors[sensorNum] + “\t”);
}
passX = sensors[0];
passY = sensors[1];
//println();
//print(“PassX= ” + passX + “, PassY= ” + passY);
//println();

}

Forum on Participation and Politics Online

Forum on Participation and Politics Online

Yesterday, I attended a forum on democracy, politics and participation online hosted by OneWebDay at NYU Law School. The forum was part of Internet Week in New York. I have uploaded the entire panel discussion as a podcast for you to experience yourselves.

The Panelists:

Baratunde Thurston – Comedian, Pundit; Web Editor, The Onion

Andrew Rasiej – Founder, Personal Democracy Forum

Jay Rosen – Professor, NYU Department of Journalism; Founder, New Assignment.net

Moderator: Allison Fine – Author, Momentum: Igniting Social Change in the Connected Age

Photos of the Forum on Flickr.

New Hepnova Track: How Long?(Live Version)

Hepnova has just released a preview track from our new album – How Long (live version), was written and sung by Sophia Chang, with arrangements, instrumentals and production by Hepnova.  Click on the image above to listen.

New Gear: Zoom H2 Handy Recorder

I received my new Zoom H2 Handy Recorder in the mail today. I can’t wait to try it out. I will definitely be bringing it on my trip to San Francisco this weekend (October 6-8), and look forward to using it to make LEESEAN.net and Hepnova.com demos, field recordings and podcasts in the future.