Mapping Music

April 20th, 2009. Filed under: audio, processing, programming.

using an FFT analysis

3 Responses to Mapping Music

  1. nik

    saweeet

  2. pires

    this render looks really nice! i am trying myself to produce some graphics and animations on processing using music and some different sounds as well but im new to processing so its going to take a wile…do you have this projects code open source?

    nice work! keep up…

  3. nick

    Here’s the code, let me know what you come up with!

    nick

    import ddf.minim.analysis.*;
    import ddf.minim.*;

    Minim minim;
    AudioPlayer song;
    FFT fft;

    float x, y, x2, y2;

    void setup()
    {
    background(255);
    size(1000, 1000);
    minim = new Minim(this);

    song = minim.loadFile("highplaces.mp3", 512);
    song.loop();
    // create an FFT object that has a time-domain buffer the same size as jingle's sample buffer
    // note that this needs to be a power of two and that it means the size of the spectrum
    // will be 512. see the online tutorial for more info.
    fft = new FFT(song.bufferSize(), song.sampleRate());
    x = width/2;
    y = height/2;

    }

    void draw()
    {

    stroke(30,20);
    strokeWeight(1);

    // perform a forward FFT on the samples
    fft.forward(song.mix);
    for(int i = 0; i < 25; i++) { x2 = cos(fft.getBand(i)*8) * (fft.getBand(i)*3)/20.0 + x; y2 = sin(fft.getBand(i)*8) * (fft.getBand(i)*3)/20.0 + y; line(x2, y2, x, y); x = x2; y = y2; } fill(255); } void stop() { // always close Minim audio classes when you finish with them song.close(); minim.stop(); super.stop(); }

Leave a Reply

You must be logged in to post a comment.