import processing.pdf.*; //import pitaru.sonia_v2_9.*; // 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. int timer=0; int[][] loecher = new int[24][120]; //lochkartenformat void setup(){ size(400,2000); Sonia.start(this); // Start Sonia engine. LiveInput.start(256); // Start LiveInput and return 256 FFT frequency bands. smooth(); frameRate(60); } void draw(){ background(255); translate(5,0); timer++; //background(10); // getMeterLevel(); // Show meter-level reading for Left/Right channels. if (timer<120){ getSpectrum(); // Show FFT reading beginRecord(PDF,"TEST4.pdf"); } for (int j=0; j<120; j++){ for (int k=0; k<24; k++){ if (loecher[k][j]==1){ ellipse(k*14,j*14,3,3); } } } if (timer==121){ endRecord (); delay(100); exit(); } } void getSpectrum(){ strokeWeight(0); stroke(0); fill(0); // 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 = 0; i < 240; i+=10){ //line(i*2, height, i*2, height - LiveInput.spectrum[i]/10); if (LiveInput.spectrum[i]>4){ //lautstŠrkemessung 10 //ellipse(i*2,20*timer,10,10); loecher[i/10][timer] =1; } else { loecher[i/10][timer] =0; } } } // Safely close the sound engine upon Browser shutdown. public void stop(){ Sonia.stop(); super.stop(); }