We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I want to have amplitude values from highpass filtered and from a lowpass filtered audio signal so i can work with both.
import processing.sound.*;
//i made two signal streams to give each filter its own audio signal (which is actually unnecessary i think)
//i did this just to be sure:
Amplitude ampHP;
Amplitude ampLP;
AudioIn inHP;
AudioIn inLP;
LowPass lP;
HighPass hP;
//an index getting increased each frame in draw() function for visual stuff:
int i = 0;
int[][] randArr = new int[3][3];
//variables for containing the volume level value:
int volHP;
int volLP;
void setup(){
size(800, 800);
background(0);
frameRate(30);
//lowpass:
ampLP = new Amplitude(this);
inLP = new AudioIn(this, 0);
lP = new LowPass(this);
inLP.start();
lP.process(inLP, 80);
ampLP.input(inLP);
lP.stop();
//highpass:
ampHP = new Amplitude(this);
inHP = new AudioIn(this, 0);
hP = new HighPass(this);
inHP.start();
hP.process(inHP, 500);
ampHP.input(inHP);
}
void draw(){
//getting the values from the filtered streams:
volHP = int(ampHP.analyze()*500);
volLP = int(ampLP.analyze()*500);
println(volHP, volLP); //for debugging. it looks like nothing at all happens to the audio
//fancy stuff happening below. but not important for my question..
background(0);
translate(height/2, height/2);
noFill();
stroke(255);
for(int j = 0; j < 3; j++){
for(int k = 0; k < 3; k++){
randArr[j][k] = int(random(10, 500)) - 250;
}
}
if(volLP >= 180){
noFill();
strokeWeight(random(2, 50));
for(int j = 0; j < 5; j++){
ellipse(sin(radians(i))*height/5 + randArr[0][0]*0.7, cos(radians(i))*height/5 + randArr[0][1]*0.7, randArr[0][2], randArr[0][2]);
}
}
if(volHP >= 180){
fill(255);
}
strokeWeight(1);
ellipse(0, 0, volHP, volLP);
//sin(radians(i))*height/5
i+=10;
}
Answers
I actuallly just had the idea to simply use an fft and just use the values from the frequency bands i want.. but i am still wondering why my first idea is not working. i would be very thankful if someone could explain that to me