Final Project

So it’s finally time to create something cool out of what I learned this semester. For this project, I decided to build something that would ultimately help me in what I do: music production. As much as I love the flashy stuff Processing can do, I felt that Max would be the ideal platform for sound manipulation. I ended up learning a lot about Max in this Processing class, but hey, everything is useful at some point. Especially because all my music tech friends are total Max geeks and I feel left out. This was a great chance to learn Max and put something together that is both fun and useful. My idea was to create something that could augment the capabilities of keyboard instruments. When a key is pressed on a piano, there’s not much else that can be done to affect the sound. Unless you’re an experimental prepared piano artist, you’re limited to working with the sound of the hammers hitting the strings. When I was doing research for this project I remembered something I had seen a long time ago: piano keys with sensors that allow the player to create vibrato effects. What an awesome idea, I thought. If I could make my own DIY version of something like that I’d be very happy. So that’s what I tried. The first step was finding the right sensor for this type of application. A soft potentiometer, or simply soft pot, seemed to be a good choice. It is easy to install, relatively cheap, and fits perfectly with the hand gesture I want for my system. The soft pot outputs different voltages depending on where you press it along it’s length. It’s ideal for this type of finger movement as the user can ergonomically adjust the depth of the vibrato as she or he plays the keys. Another advantage to this potentiometer is that it comes with a self-adhesive back and is soft enough to cut to the exact size of my keyboard keys. Here’s what the soft pot looks like:

delete

This project is just a test of my DIY vibrato system, so I started small. I only ordered four soft pots from http://www.adafruit.com. Here’s how I hooked up them up on my Arduino Uno and key board:

photo

The circuit is very simple: the 5V+ and gnd pins of each soft pot go to their respective lines on the breadboard, while the middle floating pin of each sensor goes into the Arduino’s analog input A0, A1, and A2. This allows me to write some code for the Arduino to read each analog input and transmit it serially to Max. Here’s what I wrote for the Arduino:

int softPot1 = A0;

int softPot2 = A1;

int softPot3 = A2;

void setup()

{

Serial.begin(9600); }

void loop()

{ Serial.print(analogRead(softPot1));

Serial.print(” “);

Serial.print(analogRead(softPot2));

Serial.print(” “);

Serial.print(analogRead(softPot3));

Serial.println(“,”);

}

This code sends the voltage values of each pot in three columns, which are then decoded on Max’s side. Here’s what my Max patch looks like:

Screen Shot 2014-07-03 at 3.49.14 PM

IT WORKS! It still sounds pretty crude because I haven’t added an envelope generator to adjust the attack and decay of each note. It works polyphonically though, which is definitely a desirable feature for most music production (except 8-bit music for 1990s video games). It was a bit of a pain to get the polyphony and FM synthesizer working properly. Again, I barely knew how to do anything in Max before this project. And here it is, it works! This patch is also cool because it let’s the user define how much the serial values from Arduino affect the patch. If you use the full range of values from the stream, from 0 to 1023, the sensors changes the sounds drastically because it greatly increases the harmonicity ratio, or the ratio between the carrier frequency and modulating frequency. (For more info on FM synthesis: http://www-reynal.ensea.fr/IMG/pdf/Article_Chowning_Synthese_FM.pdf) So besides creating vibrato effects with the low-frequency oscillator (LFO) of the FM synth, the user can increase the modulating frequency and create a great variety of harmonic sequences. Basically, this thing can make several different types of sound. All you gotta do is slide your finger up and down the keys — don’t forget to still press them down though, you’re still playing a keyboard!

Advertisements

Useless Box

My first Arduino controlled hardware is useless. Literally though. That’s the point of the box I built: it has a switch that turns on a servo, whose only purpose is to turn off the switch. Amazing right? I got inspiration from several Youtube videos of different “useless box” designs. Mine is pretty simple, it consists of a plastic box through which I drilled a couple holes to fit the switch and servo:

image-2

Then I soldered stuff just to feel legit:

image-1

And finally assembled the box and connected it to the breadboard/Arduino.

image

 

I also added a piezo speaker to give the useless box a bit more character. When the system turns itself off, the speaker on the breadboard plays a silly melody, which comes in one of Arduino’s sample programs. It adds another level of uselessness to the whole thing, and sounds pretty pathetic, which is ultimately funny.

The code for this Arduino pet trick is as follows:

 
#include <Servo.h> // add servo library
#include “pitches.h” // add pitches library (on a separate tab)

 

// array with the notes of the melody

int melody[] = {
NOTE_C4, NOTE_G3, NOTE_G3, NOTE_A3, NOTE_G3, 0, NOTE_B3, NOTE_C4
};
int noteDurations[] = {
4, 8, 8, 4, 4, 4, 4, 4
};
Servo myServo; // initialize servo

 

//define servo variables

int pos = 0;
int inputPin = 2;
int val = 0;
void setup() {
myServo.attach(9);
pinMode(inputPin, INPUT);

}

void loop() {
val = digitalRead(inputPin);
if (val == HIGH){    // if statement that checks if switch is ON and activates servo
delay(250);
for(pos = 0; pos < 180; pos += 1){
myServo.write(pos);
delay(7);
myServo.write(180);
}

// for loop to play the melody
for (int thisNote = 0; thisNote < 8; thisNote++) {

int noteDuration = 1000 / noteDurations[thisNote];
tone(8, melody[thisNote], noteDuration); // tone function with designated pin, melody notes, and note duration variable

int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);

noTone(8); // stop tone
}
}
}

 
Here’s a video of the most useless of Arduino projects in action:

 

Sol LeWitt

Inspired by Sol LeWitt’s algorithms for creating his Wall Drawings (http://en.wikipedia.org/wiki/Sol_LeWitt#Wall_drawings), I put together a simple Processing code that randomizes lines across the canvas. Although LeWitt’s algorithm is much more convoluted, my code simply scatters very long lines across Processing’s window to produce something that resembles LeWitt’s drawings. I tried to animate lines that would slide in and out of frame to produce the same effect. I tried for a long time until I was shown a simple workaround solution in class; this is my simple workaround for something I didn’t know how to create!

 

void setup() {
size(420, 420);
background(255);
smooth();
frameRate(1);
}

void draw() {
translate(random(0,width),random(0,height));
rotate(random(0,PI/2));
if (endx < 350) {

line(0, 0, random(10000,20000), random(10000,20000));

}

}

Wacky Clock Animation

This week I wrote my first (wacky) animation in Processing! My first idea was to build on last week’s sketch and make it animated. I wanted to turn my drum kit drawing into a set of buttons that play sampled drum sounds. It turned out to be slightly harder than I expected… So I moved on to another idea suggested in the assignment prompt: making a clock! I thought it would be interesting to make a clock that doesn’t keep time, just to be funny.

I first created pointers from the center of my animation that went everywhere with a random() function for the second XY coordinates of line(). Because it randomly created lines of different lengths it looked like I had both short and long pointers going everywhere. Getting wackier by the minute, pun intended. Then I thought the numbers should also do something weird, but first I had to figure out how to actually display numbers. I looked up how to load a font into your sketch, store it into a variable, and then use the textFont() and text() functions to display the numbers for my clock. I finally made the numbers move around randomly within a short range by setting up their coordinates with random() again. Why not make them change colors too? Very wacky. Finally, I realized my master/timepiece would only be completely with a wacky background, so I also made it change color randomly. I had to tone the colors and frame rate down to avoid potential epileptic seizures.

 

Here’s the code:

 

//Vitor Hirtsch
//Animation #1
//June 9, 2014

 

PFont font; //set up font
void setup(){
size(800,800); //size of window
frameRate(12);

font = loadFont(“Handwriting-Dakota-48.vlw”);
textFont(font, 150); //select font size

}

void draw(){
int bgd = color(random(200,255),random(200,255),random(200,255)); //randomize background colors
background(bgd);

//clock circle
stroke(1);
strokeWeight(40);
fill(bgd);
ellipse(width/2, height/2,width/1.1,height/1.1);
ellipseMode(CENTER);

// animated numbers

fill(bgd/2);
text(“1”,random(width/2.1,width/1.9),random(height/4.7,height/3.5));

fill(bgd/3);
text(“2”,random(width/1.6,width/1.5),random(height/3.2,height/3));

fill(bgd/4);
text(“3”,random(width/1.3,width/1.5),random(height/2.1,height/1.9));

fill(bgd/5);
text(“4”,random(width/1.4,width/1.3),random(height/1.6,height/1.4));

fill(bgd/6);
text(“5”,random(width/1.7,width/1.9),random(height/1.4,height/1.2));

fill(bgd/7);
text(“6”,random(width/2.3,width/2.1),random(height/1.2,height/1.15));

fill(bgd/8);
text(“7”,random(width/3.6,width/3.4),random(height/1.3,height/1.2));

fill(bgd/9);
text(“8”,random(width/5.8,width/5.7),random(height/1.4,height/1.3));

fill(bgd/10);
text(“9”,random(width/7,width/6.8),random(height/1.7,height/1.6));

fill(bgd/11);
text(“10”,random(width/5.5,width/5.4),random(height/2.2,height/2.1));

fill(bgd/12);
text(“11”,random(width/4.8,width/4.6),random(height/4.1,height/2.8));

fill(bgd/13);
text(“12”,random(width/3,width/2.9),random(height/3.5,height/3.3));

//random pointers
strokeWeight(10);
line(width/2,height/2,random(width),random(height));

}

Drum set sketch and the meaning of interactivity

The number of zombies has dramatically increased in the past few years, especially in cities like New York. They walk slowly, zigzaging on the sidewalk, their heads hanging down from their neck, until they eventually trip or bump into someone. But don’t worry, these zombies aren’t after brains, what they really care about is texting their fellow zombies or simply beating the hard level of a stupid game. It really baffles me how people cannot seem to stop looking at their phone even when they’re walking. Although it seems like it, I don’t think NYC has enough open holes on the street to make texting while walking a dangerous behavior… but oh my god, it’s so incredibly annoying. What makes people want to look at a tiny piece of glass all day? I would argue that we do that because we like interactivity (even when we’re about to fall into a manhole).

This Summer I decided to take “Introduction to Interactive Media” at NYU Tisch to better understand interactive systems and eventually come up with my own interactive design. The very first idea I was exposed to was the very definition of interactivity. What is it that makes something interactive? Have we been misusing this term and mislabeling things? How can basic programming skills and circuit building knowledge help us understand and develop truly interactive systems?

The first couple chapters of Chris Crawford’s “The Art of Interactive Design” give as tentative definition of what interactivity might be. It’s a tentative definition because the author himself says that there isn’t one correct definition of interactivity. For Crawford, the concept of interactivity can be approached from many angles. His main claim is that a truly interactive system must be composed of two actors, who go through three steps to achieve interactivity: listening, thinking, and speaking. These three main actions help us cross out a bunch of stuff from our list of interactive things. As Crawford argues, it became a common thing to label things as interactive to increase the value of certain objects, for example a carpet with the drawing of city. Kids can play on the carpet and pretend to navigate an imaginary city, but the carpet is neither listening, thinking, or speaking.

In programming terms, a system “listens” through an input, “thinks” with an algorithm that processes the input, and then “speaks” with an output. Crawford also points out that there are different levels of interactivity; some systems may be really good at acquiring input, some might have a more developed “brain” or algorithm, while others might give us several types of outputs. Some are great at everything, and those are at the top of the spectrum of interactivity.

 

And after all this rant about interactive stuff, enjoy my first sketch in Processing. It’s completely non-interactive:

 

size(800,600);

background(400,300,200);

// kick drum

stroke(200,200,100);

strokeWeight(5); fill(200,100,0);

rect(285,200,220,160);

// tom 1

fill(200,100,100);

strokeWeight(5);

stroke(200,120,100);

ellipse(340,300,85,85);

// tom 2

fill(200,100,100);

strokeWeight(5);

stroke(200,120,100);

ellipse(450,305,100,100);

// floor tom

fill(200,100,100);

strokeWeight(5);

stroke(200,120,100);

ellipse(520,410,115,115);

// snare

fill(200,100,100);

strokeWeight(5);

stroke(200,120,100);

ellipse(315,400,90,90);

// Set cymbals to no stroke stroke

Weight(1); noStroke();

// hihat

fill(400,350,100);

ellipse(220,360,90,90);

fill(1);

ellipse(220,360,10,10);

// crash

cymbal fill(400,350,100);

ellipse(270,200,115,115);

fill(1);

ellipse(270,200,10,10);

// ride cymbal

fill(400,350,100);

ellipse(550,230,160,160);

fill(1);

ellipse(550,230,10,10);

// bench

fill(1);

ellipse(395,480,80,80);