comment 0

Physical Computing [Lab 02]: Noisy Video Synth

Welcome back for week 2! Let’s see how our little LED friend is getting on…

Week 2 LED Pot small

Hooked up to a potentiometer? Nice! That serial data looks great.

But could we perhaps use it for something a little more interesting? Something like…a noisy visual synth??


Of course we could!

So what’s going on here exactly? Well, we have a potentiometer hooked up to an Arduino Uno, which is sending values from 0-1023. This data is then sent to two places.

Firstly, the data is read by the Arduino and controls the tone coming from the surface transducer (basically a speaker without a cone – put it on something to hear it resonate!). I’m using the standard firmata example to grab the data and send it to openFrameworks, with some musical additions at the very bottom. I’ll paste them here for convenience:

 // MUSICAL ADDITIONS---------------------------------------------------------------

  int potValue = analogRead(A0);
  potValue = map(potValue, 0, 1023, 55, 110);
  int pause = 2 * 1.30;
  tone(8, potValue, 500);

So we’re reading the value from the potentiometer (on the analog pin 0) and mapping it to a range of 55-110Hz. This way you can get some nice clicking and buzzing, and even some phasing with the weird constant buzz that could either be coming from the surface transducer or the code. Who knows.

The data is sent to an openFrameworks project I adapted from a textbook, and have been using for live visual performances. I wanted to utilise what Hunt and Wanderly refer to as “one-to-many” mapping, with one component influencing multiple parameters. Using some code from the standard firmata example in openFrameworks, I was able to take the data from the pot and mapped it to eRad (the radius that the particles are constrained within), bornRate (how often new particles are created) and rotate (the direction and speed of rotation). Here’s the relevant code:

void ofApp::analogPinChanged(const int & pinNum) {

    // analog pin event handler, called whenever an analog pin value has changed
    // do something with the analog input. here we're simply going to print the pin 
    // number and value to the screen each time it changes
    potValue = ard.getAnalog(pinNum);
    param.eRad = ofMap(potValue, 0, 1024, 0, 650);
    bornRate = ofMap(potValue, 0, 1024, 0, 3000);
    param.rotate = ofMap(potValue, 0., 1024, -300, 300);
    cout << "eRad: " << param.eRad << "   " << "bornRate: " << bornRate << "   " <<  
         "rotate: " << param.rotate << endl;

As always, the full code is available on my GitHub.

See you next week!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s