lunedì 7 maggio 2012

Processing music frequency visualizer super mario version

Today I'm posting about a new project in processing that uses minim audio library to visualize frequency using super mario tubes.
I think it's cool, here is the code

import ddf.minim.signals.*;
import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
import ddf.minim.ugens.*;

Minim minim;
AudioPlayer song;
FFT fft;

String song_file = "song.mp3";
PImage tube_up;
PImage tube_sec;
PImage bg_mario;
int m = 3;

void setup(){
  size(1200, 622);
  tube_up = loadImage("tube_up.png");
  tube_sec = loadImage("tube_sec.png");
  bg_mario = loadImage("bg_mario.png");
  minim = new Minim(this);
  song = minim.loadFile(song_file, 512);;
  fft = new FFT(song.bufferSize(), song.sampleRate());

void draw(){
  stroke(127, 255, 0, 200);
  for(int i = 0; i <= fft.getFreq(80)*m; i++){
    image(tube_sec, 10, height-(10+i));
  image(tube_up, 10, height-(74+fft.getFreq(80)*m));
  for(int i = 0; i <= fft.getFreq(150)*m; i++){
    image(tube_sec, 180, height-(10+i));
  image(tube_up, 180, height-(74+fft.getFreq(150)*m));
  for(int i = 0; i <= fft.getFreq(200)*m; i++){
    image(tube_sec, 350, height-(10+i));
  image(tube_up, 350, height-(74+fft.getFreq(200)*m));
  for(int i = 0; i <= fft.getFreq(300)*m; i++){
    image(tube_sec, 520, height-(10+i));
  image(tube_up, 520, height-(74+fft.getFreq(300)*m));
  for(int i = 0; i <= fft.getFreq(400)*m; i++){
    image(tube_sec, 690, height-(10+i));
  image(tube_up, 690, height-(74+fft.getFreq(400)*m));
  for(int i = 0; i <= fft.getFreq(500)*m; i++){
    image(tube_sec, 860, height-(10+i));
  image(tube_up, 860, height-(74+fft.getFreq(500)*m));

I think it's a simple sketch so I won't explain how does it function.
You can download the sketch and the file you need to run it here.
You can also try a web version here(java required).
The demo song that I put in the zip folder and that I used in the web version is
Drive Hard - PrototypeRaptor

I hope you like my post, if you have any question please comment or send me an e-mail to

Bye, Dami

P.S.:probably next week I'm gonna post about a TV B gone made using arduino and an Attiny85

Nessun commento:

Posta un commento