Sure. Try moving the keyPressed code into a custom swap function. if your OSC signal is tested to true, then call the swap function.
import ddf.minim.*;
import ddf.minim.ugens.*;
import ddf.minim.effects.*;
Minim minim;
AudioOutput out;
Oscil wave;
BandPass filt1;
float freq1;
float amp = .5;
int thresh = 8;
int fps = 60;
boolean bandOn;
void setup() {
size(960, 540);
frameRate(fps);
background(0);
rectMode(CENTER);
minim = new Minim(this);
out = minim.getLineOut();
filt1 = new BandPass(440, 20, out.sampleRate());
wave = new Oscil( 440, 0.5f, Waves.SQUARE );
wave.patch(filt1).patch( out );
bandOn = true;
}
void draw() {
if (bandOn) {
background (#64C6A6);
} else {
background (#C6A664);
}
boolean fakeOSCsignal = random(1.00)<0.01;
if (fakeOSCsignal) {
bandSwapper();
}
float passBand = map(mouseX, 0, width, 300, 2000);
filt1.setFreq(passBand);
float bandWidth = map(mouseY, 0, height, 300, 600);
filt1.setBandWidth(bandWidth);
float ellipseSize = height*.6;
stroke(255);
strokeWeight(4);
float margin = 10;
float waveAmp = 30;
pushMatrix();
translate(0, height/2);
for (int i = 0; i < out.bufferSize() - 1; i++) {
if (i> (width/2)-(ellipseSize/2)+margin && i< (width/2)+(ellipseSize/2)-margin) {
line( i, - out.left.get(i)*waveAmp, i+1, - out.left.get(i+1)*waveAmp );
}
}
popMatrix();
}
void bandSwapper() {
if (bandOn) {
filt1.unpatch(out);
wave.unpatch(filt1);
wave.patch(out);
bandOn = false;
} else {
wave.unpatch(out);
wave.patch(filt1);
filt1.patch(out);
bandOn = true;
}
}