Audio

Filed under: sketches

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

AudioPlayer buddha;
BeatDetect beat;
float eRadius;

void setup() {
  size(300, 300);
  Minim.start(this);
  buddha = Minim.loadFile("RockTheCasbah.wav");
  buddha.play();
  beat = new BeatDetect();
  eRadius = 20;
}

void draw() {
//  background(0);
  fill(0, 50);
  noStroke();
  rect(0, 0, width, height);
  smooth();
  stroke(255);
  for(int i = 0; i < buddha.bufferSize() - 1; i++)
  {
    line(i, 50 + buddha.left.get(i)*250, i+1, 50 + buddha.left.get(i+1)*250);
    line(i, 250 + buddha.right.get(i)*250, i+1, 250 + buddha.right.get(i+1)*250);
  }

  beat.detect(buddha.mix);
  float a = map(eRadius, 20, 80, 60, 255);
  fill(60, 255, 0, a);
  if ( beat.isOnset() ) eRadius = 280;
  ellipse(width/2, height/2, eRadius, eRadius);
  eRadius *= 0.95;
  if ( eRadius < 20 ) eRadius = 20;
}

void stop()
{
  // an AudioPlayer you got from Minim.loadFile()
  buddha.close();
  // an AudioInput you got from Minim.getLineIn()
  //input.close();
  super.stop();
}

bene posted on April 29th, 2008  

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Pages

Calendar

January 2009
M T W T F S S
« May    
 1234
567891011
12131415161718
19202122232425
262728293031  

Most Recent Posts