head(banger)phones part 2

UPDATE to the update:  I’ve just uploaded my final presentation slides for the head(banger)phones in PDF format.  Download here.

This is an progress update on my final project for Physical Computing, the head(banger)phones.

head(banger)phones

head(banger)phones

head(banger)phones

Since I presented my work in progress in class two weeks ago, I have moved the accelerometer (pictured above) to the top of the headphones instead of on the side of the left headphone.  I also reconsidered the actual “headbanging” motion required by the user to trigger sounds.  After doing some user testing on myself, I realized that this wasn’t the most comfortable of motions to keep up (or to track in software).  I am still going to retain the name head(banger)phones for the project though, because it sounds cool, is unique enough to show up first on Google, and because the parentheses evoke headphones.

Anyway, the new concept is to have the user move his/her head front and back, left and right while wearing the head(banger)phones.  The program will play a constant minimalist beat, and the action of head tilt on 2 axes trigger other sound elements to be played at different degress of head tilt.  In other words, I am composing a musical object that exists in the perceptual space of the headphones, and the user will hear different aspects of the musical object depending on the position of his/her head.

Also, I’ve decided that I don’t actually need to use MIDI at all to make this work.  I can just have the Arduino send a serial out message to Processing, which in turn interprets the accelerometer tilt readings and uses the Minim library to play back samples I have created.

[head(banger)phones part 1]

Here is the simple and straightforward Arduino code I am using to send the accelerometer readings to Processing:

int accelerometerX = 0;
int accelerometerY = 1;

int accelValueX=0;
int accelValueY=0;
void setup()
{
// start serial port at 9600 bps:
Serial.begin(9600);
}

void loop()
{
accelValueX = analogRead(accelerometerX);
accelValueY = analogRead(accelerometerY);
Serial.print(accelValueX, DEC);
Serial.print(“,”);
Serial.println(accelValueY, DEC);
// pause for 10 milliseconds:
//delay(10);
}

Update: Here is my Processing code:

import ddf.minim.signals.*;
import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
import processing.serial.*;

int counter = 0; //variable for controlling tempo
int tempo = 60; //the higher the number, the slower it goes

//minimum and maximum values coming from accelerometer
int minX = 250;
int maxX = 480;
int minY = 250;
int maxY = 480;

Serial myPort; // The serial port
int accelX=0;
int accelY=0;

Minim minim;
AudioSample x1;
AudioSample x2;
AudioSample x3;
AudioSample x4;
AudioSample x5;
AudioSample x6;
AudioSample y1;
AudioSample y2;
AudioSample y3;
AudioSample y4;
AudioSample y5;
AudioSample y6;

void setup()
{
println(Serial.list());
myPort = new Serial (this, Serial.list()[0], 9600);
minim = new Minim(this);
size(1440,850);
background(0);
textFont(createFont(“Courier”, 80));
textAlign(CENTER);
fill(255);
text(“head(banger)phones”, width/2, height/2 – 50);
text(“(move your head)”, width/2, height/2 + 50);

x1 = minim.loadSample(“x1.mp3”, 1440);
x2 = minim.loadSample(“x2.mp3”, 1440);
x3 = minim.loadSample(“x3.mp3”, 1440);
x4 = minim.loadSample(“x4.mp3”, 1440);
x5 = minim.loadSample(“x5.mp3”, 1440);
x6 = minim.loadSample(“x6.mp3”, 1440);

y1 = minim.loadSample(“y1.mp3”, 1440);
y2 = minim.loadSample(“y2.mp3”, 1440);
y3 = minim.loadSample(“y3.mp3”, 1440);
y4 = minim.loadSample(“y4.mp3”, 1440);
y5 = minim.loadSample(“y5.mp3”, 1440);
y6 = minim.loadSample(“y6.mp3”, 1440);
}

void draw()
{
counter = (counter+1)%tempo;

if (counter == 0)
{
//play samples according the the X value
if (accelX == 1) {
x1.trigger();
}
else if (accelX == 2) {
x2.trigger();
}
else if (accelX == 3) {
x3.trigger();
}
else if (accelX == 4) {
x4.trigger();
}
else if (accelX == 5) {
x5.trigger();
}
else if (accelX == 6) {
x6.trigger();
}

//play samples according the the Y value
if (accelY == 1) {
y1.trigger();
}
else if (accelY == 2) {
y2.trigger();
}
else if (accelY == 3) {
y3.trigger();
}
else if (accelY == 4) {
y4.trigger();
}
else if (accelY == 5) {
y5.trigger();
}
else if (accelY == 6) {
y6.trigger();
}
}
}

void serialEvent(Serial myPort)
{
// read the serial buffer:
String myString = myPort.readStringUntil(‘\n’);
// if you got any bytes other than the linefeed:
if (myString != null) {
myString = trim(myString);
// split the string at the commas
// and convert the sections into integers:
int sensors[] = int(split(myString, ‘,’));
if (sensors.length > 0) {
accelX = int(map(sensors[0], minX,maxX,1,6));
accelY = int(map(sensors[1], minY,maxY,1,6));
println(accelX + “,” +accelY); //debugging to make sure the values are coming through and being translated
}
}
}

//don’t really know what this does, but the Minim sample code says to be sure to do this, so can’t hurt
void stop()
{
x1.close();
x2.close();
x3.close();
x4.close();
x5.close();
x6.close();
y1.close();
y2.close();
y3.close();
y4.close();
y5.close();
y6.close();
minim.stop();
super.stop();
}

Published by

leesean

Foossa Facts