DM2008: Programming for Interaction Mid-terms |STROBE LANE|

Standard

Mid-Terms Final Project: Strobe Lane; Close-up

 

Interaction Design: DM2008 Programming for Interaction

Mid-term Project: Interaction through Processing

Project Title: Strobe Lane (Music Visualization via LED)

Description: A Music Visualization Program via LED Lights which can react to any music that is input into its database to obtain a mesmerizing and aesthetic effect.

Software: Processing (JAVA), Arduino (StandardFirmata), BeatWrite, Minim library

Sample Song: Legendary by Markelody (NCS Release)

Draft 1:

How it works: First, I connected the circuit by using 3 LED lights and 1k Ohm Resistors to link the circuit to its breadboard. Then, I uploaded the StandardFirmata code onto the circuit via Arduino. Moving forward, I made use of the BeatWrite Software and adjusted some of the numbers and placed my music inside Processing, and ran the program with an Arduino-Processing Library and a Minim Library.

Moving forward: I will be attempting to attach more LEDs to the circuit while exploring more precise ranges for frequencies so that the light movement will be smoother.

 

Final Version:

What things created problems or challenges that needed to be solved:

The initial plan was to have a Music Visualizer via Processing only, but my computer was not compatible with sample codes from online because of (I suspect) microphone detection issues. On top of that, I was not familiar with using p5.js even with reference from the Coding Train. It was too high a hurdle for me at the moment. Hence, I decided to revert to a music visualizer via LED lights utilizing an Arduino instead, while having some visuals on the screen that could be detected based on the song input in its code.

For issues that were solved, explain how you solved them:

One of the problems I faced was that instead of the frequency, the lights were changing based on the tempo of the music instead, which created a very limited field to work with. As a result, instead of using beat.iskick, beat.issnare, and beat.ishat which are essentially the codes needed for music tempo to be detected, Corey guided me to use beat.isrange instead, which helped me to resolve the issue and allowed me to explore a whole different range of frequencies that could make the lights move more fluidly.

For issues that were not solved, you can talk about:

  • How you think the issues may be solved in the future: It was a downer that I couldn’t make use of a graphic sort of music visualizer, partially due to time constraint. However, exploration of p5.js would probably help me to solve the issue.
  • How you worked around the issue: I worked around the issue but making use of an Arduino setup instead of solely Processing.
  • What you tried fixing for the issue, modifying the strategy, etc.: I also made use of a visual that could react to the music in its setup rather than trying to use microphone detection for the lights to react to the music.

What you would do with the project if you had more time to develop it (if you wished to):

If I had more time to develop the project, I would try to modify the project by allowing the LED lights to dance along with a graphic visual instead of simply text.

What would you change about the project idea, now that you have spent time working on it:

Whatever I stated above. Also ideally, it could be the music visualizer that refused to work on my computer.

 

Source Code*:

*Requirements for code to be run:

  1. Arduino circuit has to be connected.
  2. StandardFirmata has to be uploaded into Arduino.
  3. Song has to be loaded into Processing Code.
  4. Minim Library has to be uploaded into Processing Code.

import processing.serial.*;
import ddf.minim.*;
import ddf.minim.analysis.*;
import cc.arduino.*;

Minim minim;
AudioPlayer song;
BeatDetect beat;
BeatListener bl;
Arduino arduino;

int ledPin1 = 12; // LED connected to digital pin 12
int ledPin2 = 10; // LED connected to digital pin 10
int ledPin3 = 8; // LED connected to digital pin 8
int ledPin4 = 6; // LED connected to digital pin 6
int ledPin5 = 4; // LED connected to digital pin 4
int ledPin6 = 2; // LED connected to digital pin 2

float dropSize, theSize, beatSize;

void setup() {
size(512, 200, P3D);

minim = new Minim(this);
arduino = new Arduino(this, Arduino.list()[2], 57600);

song = minim.loadFile(“song.mp3.mp3”, 2048);
song.play();

beat = new BeatDetect(song.bufferSize(), song.sampleRate());
// set the sensitivity to 300 milliseconds
// After a beat has been detected, the algorithm will wait for 300 milliseconds
// before allowing another beat to be reported. You can use this to dampen the
// algorithm if it is giving too many false-positives. The default value is 10,
// which is essentially no damping. If you try to set the sensitivity to a negative value,
// an error will be reported and it will be set to 10 instead.
beat.setSensitivity(10); //100
dropSize = theSize = beatSize = 100;
// make a new beat listener, so that we won’t miss any buffers for the analysis
bl = new BeatListener(beat, song);
textFont(createFont(“Times New Roman”, 100));
textAlign(CENTER);

arduino.pinMode(ledPin1, Arduino.OUTPUT);
arduino.pinMode(ledPin2, Arduino.OUTPUT);
arduino.pinMode(ledPin3, Arduino.OUTPUT);
arduino.pinMode(ledPin4, Arduino.OUTPUT);
arduino.pinMode(ledPin5, Arduino.OUTPUT);
arduino.pinMode(ledPin6, Arduino.OUTPUT);
}

void draw() {
background(0);
fill(255);
// if(beat.isKick()) {
if(beat.isRange(0, 3, 4)) {
arduino.digitalWrite(ledPin1, Arduino.HIGH); // set the LED on
dropSize = 200;
}
if(beat.isRange(3, 6, 4)) {
arduino.digitalWrite(ledPin2, Arduino.HIGH); // set the LED on
dropSize = 200;
}
//if(beat.isSnare()) {
if(beat.isRange(6, 10, 4)) {
arduino.digitalWrite(ledPin3, Arduino.HIGH); // set the LED on
theSize = 200;
}
//if(beat.isHat()) {
if(beat.isRange(10, 15, 4)) {
arduino.digitalWrite(ledPin4, Arduino.HIGH); // set the LED on
beatSize = 200;
}
if(beat.isRange(15, 21, 4)) {
arduino.digitalWrite(ledPin5, Arduino.HIGH); // set the LED on
dropSize = 200;
}
if(beat.isRange(21, 26, 4)) {
arduino.digitalWrite(ledPin6, Arduino.HIGH); // set the LED on
dropSize = 200;

}
arduino.digitalWrite(ledPin1, Arduino.LOW); // set the LED off
arduino.digitalWrite(ledPin2, Arduino.LOW); // set the LED off
arduino.digitalWrite(ledPin3, Arduino.LOW); // set the LED off
arduino.digitalWrite(ledPin4, Arduino.LOW); // set the LED off
arduino.digitalWrite(ledPin5, Arduino.LOW); // set the LED off
arduino.digitalWrite(ledPin6, Arduino.LOW); // set the LED off
textSize(dropSize);
text(“DROP”, width/4, height/2);
textSize (dropSize);
text (“DROP”, width/2, height/0.5);
textSize(theSize);
text(“THE”, width/2, height/2);
textSize(theSize);
text(“BEAT”, 3*width/4, height/2);
dropSize = constrain(dropSize * 0.95, 100, 200); // 0.95, 16, 32
theSize = constrain(theSize * 0.95, 100, 200);
beatSize = constrain(beatSize * 0.95, 100, 200);
}

void stop() {
// always close Minim audio classes when you are finished with them
song.close();
// always stop Minim before exiting
minim.stop();
// this closes the sketch
super.stop();
}