getting volume data in Flash and Processing

Update: Here’s a fabulous explanation on the getSpectrum() class for Flash.

I’ve compiled a list of basic resources for you to play around with before class on Wednesday in case you haven’t found these already. If you’re working with Processing, remember to place your sound file inside of a folder called “data” inside of your sketch’s folder. If you’re using flash, remember that computeSpectrum only deals with two channel audio (for our purposes right now this is OK). I also placed some code at the end of this post that uses beat detect. You will be able to tell the difference between beat detect and Minim’s standard volume.get by the blue flashiness. Enjoy!

Processing with Ess

Showing the level from an FFT with color

Showing a level of volume across frequency using color

Processing with Minim

Getting volume data in time (without an FFT)

Flash

computeSpectrum reading (a variation of the example I used in class) a sound file

ComputeSpectrum Using an external actionScript file

Minim–BeatDetect Example

// Example By Colin Owens
import ddf.minim.*;
import ddf.minim.analysis.*;
Minim minim;
AudioPlayer song;
BeatDetect beat;
int multiplier = 10;
int count = 0;
int dotSize = 5;
void setup()
{
  size(1024, 768);
  minim = new Minim(this);
  song = minim.loadFile("true.mp3");
  song.play();
  beat = new BeatDetect();
}
void draw()
{
  background(0);
  beat.detect(song.mix);
  for(int i = 0; i < song.bufferSize() - 1; i++)
  {
    noStroke();
    fill(210,180,20);
    smooth();
    ellipse(count*multiplier, height/3 + song.left.get(i)*250, dotSize, dotSize);
    ellipse(count*multiplier, (height/3)*2 + song.right.get(i)*250, dotSize, dotSize);
if ( beat.isOnset() ) {
  fill(20,180,210);
   ellipse(count*multiplier, height/3 + song.left.get(i)*250, dotSize*10, dotSize*10);
    ellipse(count*multiplier, (height/3)*2 + song.right.get(i)*250, dotSize*10, dotSize*10);
}
    count++;
    if (count >= width) {
      count=0;
    }
    if (dotSize <= 0) {
      dotSize=1;
      multiplier = 10;
    }
  }
  if(keyPressed) {
    if (keyCode == LEFT) {
      multiplier = multiplier -1;
      dotSize = dotSize -1;
    }
    if (keyCode == RIGHT) {
      multiplier = multiplier +1;
      dotSize = dotSize +1;
    }
  }
}
void stop()
{
  song.close();
  super.stop();
}

Post a comment.