Step1:
As a huge fan of musicals and Disney movies, I decided to replace the music file with the song “We don’t talk about Bruno”.
Step2:
I think the color set is not pretty enough, so I changed the colors of the background and the circle to blue and red. The sketches were complicated so I spent a lot of time figuring out how to combine them together. And the New-pixels light up when the song is played. Which pixel lights up is due to the volume of the song (the higher the volume is, the bigger the sequence of the pixel is).
Step3:
However, I think this is not satisfying enough, so I decided to off the pixel immediately after it lights up, so only one pixel would turn on at the same time.
import processing.sound.*; import processing.serial.*; import osteele.processing.SerialRecord.*; Serial serialPort; SerialRecord serialRecord; SoundFile sample; Amplitude analysis; int W; //width of the tiles int NUM = 60; //amount of pixels int[] r = new int[NUM]; //red of each tile int[] g = new int[NUM]; //red of each tile int[] b = new int[NUM]; //red of each tile void setup() { size(640, 480); // load and play a sound file in a loop sample = new SoundFile(this, "Bruno.mp3"); sample.loop(); // create the Amplitude analysis object analysis = new Amplitude(this); // analyze the playing sound file analysis.input(sample); String serialPortName = SerialUtils.findArduinoPort(); serialPort = new Serial(this, serialPortName, 9600); serialRecord = new SerialRecord(this, serialPort, 4); serialRecord.logToCanvas(false); } void draw() { println(analysis.analyze()); background(#0224A7); noStroke(); // analyze the audio for its volume level float volume = analysis.analyze(); // volume is a number between 0.0 and 1.0 // map the volume value to a useful scale float diameter = map(volume, 0, 1, 0, width); // draw a circle based on the microphone amplitude (volume) fill(255, 0, 100); circle(width/2, height/2, diameter); int n = floor(diameter/20); r[n] = floor(random(255)); g[n] = floor(random(255)); b[n] = floor(random(255)); serialRecord.values[0] = n; // which pixel we change (0-59) serialRecord.values[1] = r[n]; // how much red (0-255) serialRecord.values[2] = g[n]; // how much green (0-255) serialRecord.values[3] = b[n]; // how much blue (0-255) serialRecord.send(); // send it! r[n] = 0; g[n] = 0; b[n] = 0; serialRecord.values[0] = n; // which pixel we change (0-59) serialRecord.values[1] = r[n]; // how much red (0-255) serialRecord.values[2] = g[n]; // how much green (0-255) serialRecord.values[3] = b[n]; // how much blue (0-255) serialRecord.send(); // send it! }