Hello,
I want be able to control echo effect with toggle controller, so I created method echo and after that used controlEvent method, but none of these technique worked for me, I guess I need some kind of setter, but don't know which one, maybe somebody know how to turn off/on echo effect with toggle ?
thanks for help
- import controlP5.*;
- import beads.*;
- ControlP5 cp5;
- AudioContext ac;
- WavePlayer wp;
- Gain g;
- Glide gainGlide;
- Glide frequencyGlide;
- TapIn delayIn;
- TapOut delayOut;
- Gain delayGain;
- void setup()
- {
- size(400, 300);
- cp5 = new ControlP5(this);
- cp5.addToggle("echo")
- .setPosition(40, 250)
- .setSize(50, 20)
- .setValue(true)
- .setMode(ControlP5.SWITCH)
- ;
- ac = new AudioContext();
- gainGlide = new Glide(ac, 0.0, 50);
- frequencyGlide = new Glide(ac, 20, 50);
- wp = new WavePlayer(ac, frequencyGlide, Buffer.SINE);
- g = new Gain(ac, 1, gainGlide);
- g.addInput(wp);
- delayIn = new TapIn(ac, 2000);
- delayIn.addInput(g);
- delayOut = new TapOut(ac, delayIn, 500.0);
- delayGain = new Gain(ac, 1, 0.50);
- delayGain.addInput(delayOut);
- ac.out.addInput(g);
- // the line which controls echo
- ac.out.addInput(delayGain);
- ac.start();
- }
- void draw()
- {
- background(0);
- gainGlide.setValue(mouseX / (float)width);
- frequencyGlide.setValue(mouseY);
- }
- // method to get value of toggle
- void echo (boolean theFlag) {
- if (theFlag==true) {
- // ac.out.addInput(delayGain);
- }
- }
1