I think I reached the effect I wanted to create. Asking for some advices to enhance it, to many people the sound input isn't obvious. I it a good thing? I don't yet, I 've been watching it too long. Being able to stick ones look on its pattern is a good starting point for a screen saver.
// LiveInput example for Processing V90
// Description: Shows FFT spectrum and volume level for the active sound-input on your mahcine.
// For PC: use the 'Sounds & Audio Devices' menu in the control panel to choose your input; Mic, wave, etc.
// For Mac: the current microphone device will be used as input.
// By: Amit Pitaru, July 16th 2005
import pitaru.sonia_v2_9.*; // automcatically added when importing the library from the processing menu.
float x= 0;
void setup(){
size(1200,700);
Sonia.start(this); // Start Sonia engine.
LiveInput.start(256); // Start LiveInput and return 256 FFT frequency bands.
framerate(10);
}
void draw(){
background(20);
// getMeterLevel(); // Show meter-level reading for Left/Right channels.
getSpectrum(); // Show FFT reading
}
void getSpectrum(){
strokeWeight(0.5);
// populate the spectrum array with FFT values.
LiveInput.getSpectrum();
// draw a bar for each of the elements in the spectrum array.
// Note - the current FFT math is done in Java and is very raw. expect optimized alternative soon.
for ( int i = 25; i < 40; i++){
x= x+ 0.05;
smooth();
stroke(255);
beginShape(LINE_STRIP);
curveVertex(0+sin(x), 100 - ( LiveInput.spectrum[i])-sin(x));
curveVertex(0+sin(x), 50 - ( LiveInput.spectrum[i])-sin(x));
curveVertex(1200+sin(x), 150 - ( LiveInput.spectrum[i])-sin(x));
curveVertex(1200+sin(x), 150 - ( LiveInput.spectrum[i])-sin(x) );
endShape();
beginShape(LINE_STRIP);
stroke(100);
curveTightness(-2);
curveVertex(0, 250 +( LiveInput.spectrum[i]));
curveVertex(0, 250 +( LiveInput.spectrum[i]));
curveVertex(600 + (LiveInput.spectrum[i]+8*sin(x)), 150 + 0.5*( LiveInput.spectrum[i])+sin(x));
curveVertex(600 + (LiveInput.spectrum[i]+8*sin(x)), 250 + 0.5*( LiveInput.spectrum[i])+sin(x));
curveVertex(1400 + (LiveInput.spectrum[i]), 250 + 0.5*( LiveInput.spectrum[i])+sin(x));
curveVertex(1400 + (LiveInput.spectrum[i]), 250 + 0.5*( LiveInput.spectrum[i])+sin(x));
endShape();
beginShape(LINE_STRIP);
curveTightness(-1.3);
curveVertex(0, 400 - (LiveInput.spectrum[i]));
curveVertex(0, 400 - (LiveInput.spectrum[i]));
curveVertex(800 + (LiveInput.spectrum[i]+8*cos(x)), 350);
curveVertex(800 + (LiveInput.spectrum[i]+8*cos(x)), 400);
curveVertex(1200, 450 + 0.5*( LiveInput.spectrum[i])+cos(x));
curveVertex(1200, 450 + 0.5*( LiveInput.spectrum[i])+cos(x));
endShape();
beginShape(LINE_STRIP);
curveTightness(-3);
curveVertex(0, 520 + ( LiveInput.spectrum[i]));
curveVertex(0, 520 + ( LiveInput.spectrum[i]));
curveVertex(400 + (LiveInput.spectrum[i]+10*sin(x+1)), 440);
curveVertex(400 + (LiveInput.spectrum[i]+10*sin(x+1)), 590);
curveVertex(1210 + (LiveInput.spectrum[i]+10*sin(x+1)), 540);
curveVertex(1210 + (LiveInput.spectrum[i]), 330);
endShape();
}
}
// Safely close the sound engine upon Browser shutdown.
public void stop(){
Sonia.stop();
super.stop();
}
// LiveInput example for Processing V90
// Description: Shows FFT spectrum and volume level for the active sound-input on your mahcine.
// For PC: use the 'Sounds & Audio Devices' menu in the control panel to choose your input; Mic, wave, etc.
// For Mac: the current microphone device will be used as input.
// By: Amit Pitaru, July 16th 2005
import pitaru.sonia_v2_9.*; // automcatically added when importing the library from the processing menu.
float x= 0;
void setup(){
size(1200,700);
Sonia.start(this); // Start Sonia engine.
LiveInput.start(256); // Start LiveInput and return 256 FFT frequency bands.
framerate(10);
}
void draw(){
background(20);
// getMeterLevel(); // Show meter-level reading for Left/Right channels.
getSpectrum(); // Show FFT reading
}
void getSpectrum(){
strokeWeight(0.5);
// populate the spectrum array with FFT values.
LiveInput.getSpectrum();
// draw a bar for each of the elements in the spectrum array.
// Note - the current FFT math is done in Java and is very raw. expect optimized alternative soon.
for ( int i = 25; i < 40; i++){
x= x+ 0.05;
smooth();
stroke(255);
beginShape(LINE_STRIP);
curveVertex(0+sin(x), 100 - ( LiveInput.spectrum[i])-sin(x));
curveVertex(0+sin(x), 50 - ( LiveInput.spectrum[i])-sin(x));
curveVertex(1200+sin(x), 150 - ( LiveInput.spectrum[i])-sin(x));
curveVertex(1200+sin(x), 150 - ( LiveInput.spectrum[i])-sin(x) );
endShape();
beginShape(LINE_STRIP);
stroke(100);
curveTightness(-2);
curveVertex(0, 250 +( LiveInput.spectrum[i]));
curveVertex(0, 250 +( LiveInput.spectrum[i]));
curveVertex(600 + (LiveInput.spectrum[i]+8*sin(x)), 150 + 0.5*( LiveInput.spectrum[i])+sin(x));
curveVertex(600 + (LiveInput.spectrum[i]+8*sin(x)), 250 + 0.5*( LiveInput.spectrum[i])+sin(x));
curveVertex(1400 + (LiveInput.spectrum[i]), 250 + 0.5*( LiveInput.spectrum[i])+sin(x));
curveVertex(1400 + (LiveInput.spectrum[i]), 250 + 0.5*( LiveInput.spectrum[i])+sin(x));
endShape();
beginShape(LINE_STRIP);
curveTightness(-1.3);
curveVertex(0, 400 - (LiveInput.spectrum[i]));
curveVertex(0, 400 - (LiveInput.spectrum[i]));
curveVertex(800 + (LiveInput.spectrum[i]+8*cos(x)), 350);
curveVertex(800 + (LiveInput.spectrum[i]+8*cos(x)), 400);
curveVertex(1200, 450 + 0.5*( LiveInput.spectrum[i])+cos(x));
curveVertex(1200, 450 + 0.5*( LiveInput.spectrum[i])+cos(x));
endShape();
beginShape(LINE_STRIP);
curveTightness(-3);
curveVertex(0, 520 + ( LiveInput.spectrum[i]));
curveVertex(0, 520 + ( LiveInput.spectrum[i]));
curveVertex(400 + (LiveInput.spectrum[i]+10*sin(x+1)), 440);
curveVertex(400 + (LiveInput.spectrum[i]+10*sin(x+1)), 590);
curveVertex(1210 + (LiveInput.spectrum[i]+10*sin(x+1)), 540);
curveVertex(1210 + (LiveInput.spectrum[i]), 330);
endShape();
}
}
// Safely close the sound engine upon Browser shutdown.
public void stop(){
Sonia.stop();
super.stop();
}
0 Comments:
Post a Comment
<< Home