We are about to switch to a new forum software. Until then we have removed the registration on this forum.
hey guys, I know its really simple but I was wondering why my text doesn't show up in the display, my images show but my text doesn't. also I wanted to know what else I could do to improve my code. here it is:
import ddf.minim.spi.*;
import ddf.minim.signals.*;
import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.ugens.*;
import ddf.minim.effects.*;
Minim minim;
//this is the audio signal that the program will output
AudioOutput sineout;
SineWave sine;
LowPassSP lpf;
HighPassSP hpf;
BandPass bpf;
PImage img1;
PImage img2;
PImage img3;
boolean dispimg1;
boolean dispimg2;
boolean dispimg3;
void setup(){
size(500,500);
img1 = loadImage("LPF.png");
img2 = loadImage("HPF.png");
img3 = loadImage("BPF.png");
minim = new Minim(this);
sineout = minim.getLineOut();
sine = new SineWave(500, 1, 44100);
lpf = new LowPassSP(325, 44100);
hpf = new HighPassSP(550, 44100);
bpf = new BandPass(350, 200, 44100);
sineout.addSignal(sine);
}
void draw(){
background(200);
for(int i= 0; i < sineout.bufferSize() - 1; i++){
stroke(#F20C0C);
line(i, 300 + sineout.left.get(i)*20, i+1, 300 + sineout.left.get(i+1)*20);
}
if(dispimg1){
fill(0, 40, 60);
text("low pass filter", width/2, 30);
image(img1, width/2, height/2);
}
if(dispimg2){
fill(0, 40, 60);
text("high pass filter", width/2, height/2+30);
image(img2, width/2, height/2);
}
if(dispimg3){
fill(0, 40, 60);
text("band pass filter", width/2, height/2+30);
image(img3, width/2, height/2);
}
}
void mouseMoved() {
sine.setFreq(220+mouseX);
sine.setFreq(150+mouseY);
}
void keyPressed(){
if (key == 'q') {
toggleEffect(lpf);
dispimg1 = true;
dispimg2 = false;
dispimg3 = false;
// image(img1, width/2, height/2);
}
else if (key == 'w'){
toggleEffect(hpf);
dispimg2 = true;
dispimg1 = false;
dispimg3 = false;
// image(img2, width/2, height/2);
}
else if (key == 'e'){
toggleEffect(bpf);
dispimg3 = true;
dispimg1 = false;
dispimg2 = false;
// image(img3, width/2, height/2);
}
}
void toggleEffect(AudioEffect effect){
if (sineout.hasEffect(effect)){
sineout.removeEffect(effect);
} else {
sineout.addEffect(effect);
}
}
help would be greatly appreciated
Answers
http://forum.processing.org/two/discussion/8045/how-to-format-code-and-text
It depends on the size of the images, but apparently you first draw text, then you draw image over it... Invert the order of the calls.