a_recording
YaBB Newbies
Offline
Posts: 2
Re: ESS's FFT averages
Reply #8 - Sep 14th , 2008, 2:23pm
Hi! This is probably a very simple problem (or two problems rather), but I'm a complete beginner with Processing and ESS, and we are trying to make a project to visualise microphone data. Using the FFT code that Dave kindly provided (thank you so much!), we've ran into two issues: 1. Replacing the Audiochannel in the pde with an audioinput produces no visualisation of the sound, but also throws no errors. At the moment the code looks like this, with the only changes being changes from references to the audio channel to the new audioinput, myInput: import krister.Ess.*; AudioInput myInput; FFT fft; FFTOctaveAnalyzer oct; int bufferSize = 1024; int samplingRate = 44100; void setup() { // init p5 size(320,240); frameRate(30); noStroke(); // init ess Ess.start(this); // create a new AudioInput myInput=new AudioInput(); // init fft fft = new FFT(bufferSize*2); fft.limits(); fft.damp(0.5f); // init averages oct = new FFTOctaveAnalyzer(fft, samplingRate, 2); // common things you might want to "tweak" (see code for further comments) oct.peakHoldTime = 15; // hold longer oct.peakDecayRate = 0.95f; // decay slower oct.linearEQIntercept = 0.9f; // reduced gain at lowest frequency oct.linearEQSlope = 0.01f; // increasing gain at higher frequencies } void draw() { // update the fft and averages fft.getSpectrum(myInput); oct.calculate(); // figure out screen size stuff float margin = 16f; float xspan = floor((width - margin * 2f) / (float)(oct.nAverages)); float yspan = height - margin * 2f; // draw all bands: background(0); for (int i=0; i<oct.nAverages; i++) { // draw the average float x1 = margin + (float)(i) * xspan; float y2 = height - margin; fill(color(128,240,32)); rect(x1, y2, xspan-1, -oct.averages[i]*yspan); // draw the peak y2 = height - margin - oct.peaks[i] * yspan; if (oct.peakHoldTimes[i] > 0) fill(color(64,128,192)); // peak color else fill(color(48,96,144)); // decay color rect(x1, y2, xspan-1, -2); } } public void stop() { Ess.stop(); super.stop(); } Can anyone see what I'm doing wrong? Our other problem is that in a seperate experiment when we replace the AIF file in the data folder with one of our own, it plays back 'slowly' (stretched out and lower pitch). We are using AIF files exported in Quicktime as 16 bit Stereo 44100khz files. Trying to use a WAV produces the same result, whereas trying to use an mp3 doesn't even work - Processing says it can't find the mp3. I'm sure that because we are beginners we are getting something very wrong with our fundamental knowledge of how ESS or Processing works. If anyone could help us that would be great! Thank you!