Hi, I've been trying to use controlP5 to manipulate sine waves generated by Ess. It all works fine, but I'm having problems with controlP5. The slider values stay on screen. Here's the code:
As you'll guess from the code, this is my first time trying out processing
Code:import krister.Ess.*;
import controlP5.*;
ControlP5 controlP5;
AudioChannel myChannel;
SineWave myWave;
float volume=0.5;
int pitch=400;
int release=1000;
void setup() {
background(0);
//frameRate(25);
size(256,200);
Ess.start(this);
myChannel=new AudioChannel();
controlP5 = new ControlP5(this);
controlP5.addSlider("Pitch",200,2000,40,10,10,10,100).setId(1);
controlP5.addSlider("Volume",0,2,40,70,10,10,100).setId(2);
controlP5.addSlider("Release",1000,8000,40,120,10,10,100).setId(3);
}
void controlEvent (ControlEvent theEvent) {
switch(theEvent.controller().id()) {
case(1):
pitch = (int)(theEvent.controller().value());
//print("the pitch changed to " + pitch + "\n");
break;
case(2):
volume = (float)(theEvent.controller().value());
//print("the VOLUME changed to " + volume + "\n");
break;
case(3):
release = (int)(theEvent.controller().value());
//print("the note length changed to " + release + "\n");
break;
}
myWave=new SineWave(pitch,volume);
myChannel.initChannel(myChannel.frames(release));
myWave.generate(myChannel,5,myChannel.frames(release));
myChannel.play();
}
void draw() {
controlP5.draw();
}
public void stop() {
Ess.stop();
super.stop();
}