Skip to content

Instantly share code, notes, and snippets.

@jaegonlee
Created September 10, 2018 07:18
Show Gist options
  • Save jaegonlee/7575a0c3ceaa6eb8064b3bb5915a6f6f to your computer and use it in GitHub Desktop.
Save jaegonlee/7575a0c3ceaa6eb8064b3bb5915a6f6f to your computer and use it in GitHub Desktop.

Revisions

  1. jaegonlee created this gist Sep 10, 2018.
    32 changes: 32 additions & 0 deletions fft.pde
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    import processing.sound.*;

    AudioIn input;
    FFT fft;

    //float smoothingFactor = 0.2;
    float[] sum = new float[128];

    public void setup() {
    size(512, 360);
    background(255);
    input = new AudioIn(this, 0);
    input.start();

    fft = new FFT(this, 128);
    fft.input(input);
    }

    public void draw() {

    background(125, 255, 125);
    fill(255, 0, 150);
    noStroke();

    fft.analyze();

    for (int i = 0; i < 128; i++) {
    //sum[i] += (fft.spectrum[i] - sum[i]) * smoothingFactor;
    sum[i] = fft.spectrum[i];
    rect(i*4, height, 4, -sum[i]*height);
    }
    }