Question: How do I add a ControlP5 checkbox/radio button (i.e. a boolean switch) to turn the sound-to-ellipse size function on and off? Here is my code,

How do I add a ControlP5 checkbox/radio button (i.e. a boolean switch) to turn the sound-to-ellipse size function on and off? Here is my code, the button has already been created but clicking it currently does nothing.

//import controlP5 library import controlP5.*;

//New control object ControlP5 cp5;

//import sound library import processing.sound.*;

Amplitude amp; //amplitude control AudioIn in; //audio input float vlm; //volume float scale = 500; //scale of text boolean TurnOff = false;

CallbackListener cb;

void setup() { //canvas size size(800,400); // Create an Input stream which is routed into the Amplitude analyzer amp = new Amplitude(this); //instantiating amp to new Amplitude object in = new AudioIn(this, 0); //instantiating input to new AudioIn object in.start(); amp.input(in); //instantiating the new object cp5 = new ControlP5(this); cp5.addButton("turnOff") .setPosition(150,150) .setValue(1) .setSize(100, 100) ; }

void draw() { background(0); vlm = amp.analyze(); fill(0, 0, 255); ellipse(600, 200, vlm * scale, vlm * scale); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!