import ddf.minim.*; import controlP5.*; //declaration of minim object Minim minim; //audio input variable AudioInput sound; //declaration of ControlP5 object ControlP5 cp5; float weight_1 = 1; float weight_2 = 1; //sound amplitude multiplier float amplitude = 150; //size of radial wave float radius = 20; void setup() { size(1920, 1080); minim = new Minim(this); sound = minim.getLineIn(Minim.STEREO, 1024); cp5 = new ControlP5(this); ///declare a slider with a range of 0 - 100 cp5.addSlider("weight_1") .setPosition(40,830) .setRange(0,100) .setSize(20,200) .setValue(0) .setColorForeground(color(20,200,200)) .setColorLabel(color(0)) .setColorBackground(color(70,70,70)) .setColorValue(color(0,0,0)) .setColorActive(color(0,255,255)) ; cp5.addSlider("weight_2") .setPosition(1860,830) .setRange(0,100) .setSize(20,200) .setValue(0) .setColorForeground(color(20,200,200)) .setColorLabel(color(0)) .setColorBackground(color(70,70,70)) .setColorValue(color(0,0,0)) .setColorActive(color(0,255,255)) ; } void draw() { background(weight_2*2.5,weight_1*2.5,255); stroke(0,weight_1*2.5,weight_2*2.5); strokeWeight(weight_2); //creare a radian step size for angle interval based on 1024 sound samples float radians_step = 2*PI/sound.bufferSize(); for(int i = 0; i < sound.bufferSize()-1; i++){ ////calculate positions to create a line based on a circle float xpos1 = width/2 + (sound.mix.get(i)*weight_2*100+weight_1*3) * cos(i*radians_step); float ypos1 = height/2 + (sound.mix.get(i)*weight_2*100+weight_1*3) * sin(i*radians_step); float xpos2 = width/2 + (sound.mix.get(i)*weight_2*100+weight_1*3) * cos((i+1)*radians_step); float ypos2 = height/2 + (sound.mix.get(i)*weight_2*100+weight_1*3) * sin((i+1)*radians_step); line( xpos1,ypos1,xpos2,ypos2); } }