I was lucky enough to win a bet with a friend (something about the melting temperature of a plastic..) and got his superb grammaphone. Here’s what i wanted to do : i will place a woofer inside of the grammaphone’s horn, and connect it to an amplifier, an arduino and a computer. It will basically be a “remake” of the grammaphone or “a new version” of it. The role of the arduino is to be connected to the LoL Shield, which will be reacting to the sound waves, it will displayed an audio spectrum. That will not be the only option, i also want to use the “crank”, basically triggering an energy or something when the platform is moving.
This is what i ended up doing : on the mechanical wheels of the gramophone, i saw there was a little space between the biggest wheel and the wood. I thought this would be a good place to install a pressure sensor which would trigger something. Therefore i decided to install the pressure sensor under that wheel and stick some velcro on the wheel itself so that a pressure is applied on the sensor every half lap. The reason for the pressure sensor location is that it can be triggered by cranking the handle. Therefore all the user needs to do is cranking the handle, as on any gramophones, and the mechanism (from analog to digital) will run by itself.
When pressure is applied onto the pressure sensor (which is connected to the breadboard inside the gramophone box), it is detected on processing as values. I used a code that sends bytes from arduino to processing (serial event) so that i could use a sound library on processing : MINIM. What i asked arduino is to detect values when pressure is applied. What i asked processing is to detect that arduino detected values. When it detects that, those bytes are sent to processing and when the value is superior to 1, play a music (player.play) otherwise, pause it (player.pause). At the same time, i have a LOL (Lots of Leds) shield acting as an audio spectrum and reacting as sound waves to the beats and frequencies of the sound. So every time sound is detected, the LoL shield reacts as an audio spectrum, otherwise, it stops. To have the music played from the computer to the amplifier to the woofer, i obvisouly needed an audio jack. If i wanted the LoL Shield to work at the same time, i’d need another one. So what i did is that i installed a double audio jacks receiver on the amplifier so i can plug both the sound and the LoL shield. Only problem with this is that i’m loosing a bit of the quality of the sound; but the horn of the gramophone amplifies the sound by itself.
HERE IS THE VIDEO : http://vimeo.com/33864489
Here is the code for arduino :
#include <Charliplexing.h>
#include <fix_fft.h>
#define AUDIOPIN 5
int press1 = 0;
int val1 = 0;
char im[128], data[128];
char data_avgs[14];
int i=0,val;
void setup() {
LedSign::Init(); //Initilizes the LoL Shield
Serial.begin(9600);
}
void loop() {
for (i=0; i < 128; i++){
val = analogRead(AUDIOPIN);
data[i] = val;
im[i] = 0;
};
fix_fft(data, im, 7, 0);
for (i=0; i< 64; i++){
data[i] = sqrt(data[i] * data[i] + im[i] * im[i]); // this gets the absolute value of the values in the array, so we’re only dealing with positive numbers
};
// average bars together
for (i=0; i< 14; i++) {
data_avgs[i] = data[i*4] + data[i*4 + 1] + data[i*4 + 2] + data[i*4 + 3]; // average together
data_avgs[i] = map(data_avgs[i], 0, 30, 0, 9); // remap values for LoL
}
// set LoLShield
for (int x=0; x < 14; x++) {
for (int y=0; y < 9; y++) {
if (y < data_avgs[13-x]) { // 13-x reverses the bars so low to high frequences are represented from left to right.
LedSign::Set(x,y,1); // set the LED on
}
else {
LedSign::Set(x,y,0); // set the LED off
}
}
}
val1=analogRead(press1);
//Serial.println(val1);
//Serial.println(val1);
Serial.write(val1);
}
Here is the code for processing :
//—————— Serial Variables ——————–
//this is a library we are importing into this sketch
import processing.serial.*;
Serial myPort; // The serial port
int[] serialInArray = new int[1]; // Where we’ll put what we receive
int serialCount = 0; // A count of how many bytes we receive
boolean firstContact = false; // Whether we’ve heard from the microcontroller
int sensor1; // Our Incoming Sensor variables
int oldsensor1; //Saved Sesnor vars
//——————————————————-
import ddf.minim.*;
AudioPlayer player;
Minim minim;
Timer timer;
int val1=0;
boolean checkForce = true;
void setup() {
String portName = Serial.list()[0];
myPort = new Serial(this, portName, 9600);
size(800, 800,P2D);
minim = new Minim(this);
player = minim.loadFile(“tasteyou.mp3”, 2048);
}
void draw () {
background(0);
stroke(255);
if (checkForce == true)
player.play();
else
player.pause();
// println(checkForce);
}
void serialEvent(Serial myPort) {
val1 = myPort.read(); // read it and store it in val
if (val1 > 0) checkForce = true;
else checkForce = false;
//println(val1);
}