We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › SoniaHelper Equivalent for Minim
Page Index Toggle Pages: 1
SoniaHelper Equivalent for Minim (Read 1433 times)
SoniaHelper Equivalent for Minim
Apr 9th, 2010, 6:18pm
 
Does a SoniaHelper equivalent exist for the Minim Library?
Re: SoniaHelper Equivalent for Minim
Reply #1 - Apr 10th, 2010, 10:14am
 
There is an example on Marius Watz's site Code + Form:

http://code.google.com/p/codeandform/downloads/detail?name=2007.1119%20Cimatics%...

Titled "av_sound_input_ffthelper." This is still for Sonia, but it looks pretty easy to switch out Sonia's spectrum for Minim's. More later.
Re: SoniaHelper Equivalent for Minim
Reply #2 - Apr 12th, 2010, 6:26pm
 
Update:
Yes, it seems that FFT Average is only a fraction of what SoniaHelper provides. I had a tough time finding a method that returns a float[] for an FFT object or AudioInput object. Anyone more familiar with this library know of a way to get float[] returned

getBand() returns float
AudioInput.left or right returns an Audio Buffer



Looking through the documentation further. Is Minim's FFT Average Transformation the same thing that SoniaHelper does

FFT Average:
http://code.compartmental.net/tools/minim/manual-fft/

FFT also has methods that allow you to request the creation of an average spectrum. An average spectrum is simply a spectrum with fewer bands than the full spectrum where each average band is the average of the amplitudes of some number of contiguous frequency bands in the full spectrum.

SoniaHelper:
http://workshop.evolutionzone.com/2006/05/10/soniahelper-library/

I’ve put together a hack for normalizing the FFT analysis values produced by Sonia’s LiveInput.getSpectrum(). It looks at the maximum values produced, and scales them according to the most recent maximum values. That way, quiet sections will produce relative differences according to the current maximum value, so that both quiet and loud sections give dynamic results.

Averaging is different from Normalizing, right
Re: SoniaHelper Equivalent for Minim
Reply #3 - May 1st, 2010, 9:56pm
 
Alright here's a preliminary of the code — it works! I feel like Minim probably has this natively, but I just couldn't figure it out. If it's not, where could I go to possibly request an addition? Is it on github or something?

The values are all out of whack and completely dissimilar from Sonia, but the Helper works.

Hope it can go to good use. I know I'll be using it!  Grin

Code:

import ddf.minim.*;
import ddf.minim.analysis.*;
import SoniaHelper.*;

Minim minim;
AudioInput in;
FFT f;

float l, d;
int s = 256,
   n = 8;
float[] spectrum = new float[s];
SoniaHelper fft;

void setup() {
 size(512,400);
 
 int s = 256;
 int n = 8;
 
 minim   = new Minim(this);
 in  = minim.getLineIn(Minim.STEREO, s);
 f  = new FFT(in.bufferSize(), in.sampleRate());

 minim.debugOn();
 
 fft = new SoniaHelper(s, n, false);
 fft.setMaxLimits(0,256);
 
 d   = 0.02;
 fft.setDamper(d);

}

void draw() {
 background(0);
 
 noStroke();
 fill(255,255,0);
 
 doSoundInput();
 
 for(int i = 0; i < in.bufferSize(); i++) {

   rect( i * (width/256), height, width/256, - width/256 - 250*(fft.spectrum[i]*fft.spectrum[i]) );
 }
}

public void doSoundInput() {
 f.forward(in.left);
 for(int i = 0; i < in.bufferSize(); i++) {
   spectrum[i] = 100*f.getBand(i);
 }
 fft.update(spectrum);
}

void stop() {
 in.close();
 minim.stop();
 super.stop();
}

Page Index Toggle Pages: 1