Tags: ess, fft, ffthelper, library, processing.org, sonia, soniahelper, Sound, visuals, vj
Update: SoniaHelper should be renamed FFTHelper and integrated into unlekkerLib, but that hasn’t happened yet. The best way to use it right now is to download the code examples from the VJ workshop I did at Cimatics 2007. That has the code you need as well as some examples of practical usage.
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.
It also allows you to dampen the values so that the rate of change in values can be controlled. This can be used to make the values change appropriately according to the quality of the music, making it easier to use them for visuals that match the music.
You initialize SoniaHelper like this:
// SoniaHelper(int _n, int _nbands,boolean doAvg)
// Start up Sonia
LiveInput.start(spectrumLength);
// ...or start up Ess
Ess.start(this);
myChannel=new Channel("hello.aiff");
myChannel.setupFFT(512);
// init SoniaHelper
ffthelper=new SoniaHelper(spectrumLength,32,false);
ffthelper.setMaxLimits(200,2000);
damperval=0.1f;
ffthelper.setDamper(damperval);
Update SoniaHelper inside draw() by passing spectral values from Sonia or Ess:
void draw() {
...
LiveInput.getSpectrum();
ffthelper.update(LiveInput.spectrum);
// Ess equivalent
myChannel.loadSpectrum();
ffthelper.update(myChannel.spectrum);
for(int i=0; i< spectrumLength; i++)
ellipse(i,height/2,
100*ffthelper.spectrum[i], 100*ffthelper.spectrum[i]);
...
}
See the sample code in the ZIP file for more code examples.





Very helpful. Thanks Marius.
Hi Marius, is there a reference to understand better the methods of SoniaHelper?
Thanks and gr8 work!
Hi Claudio, unfortunately I haven’t really had time to document it very well. The examples show how the library is intended to be used. Basically you use the spectrum[] array from the SoniaHelper instead of the one provided by Sonia. The relevant parameter for SoniaHelper is the damper value set by setDamper(). When set close to 0 this slows down the rate of change in the data, closer to 1 it changes the values immediately.
[...] One is ESS and the other one is Sonia. I tried Sonia first but I found out that it reads the signal but has no maximum value, so you can’t really measure the percentage of the volume or of the peaks of a certain frequency band because you don’t have any fixed point to compare your values against. There is an addition to this library which is called Sonia Helper. [...]
[...] The visuals were built with Processing, using Sonia and my own SoniaHelper for sound input and analysis. My laptop lost its ability to output to an external monitor before the show, which added an extra bit of tension but allowed me to experiment with running Windows on a Mac. Someone lent me a MacBook running Bootcamp and Windows XP, and it turned out that simply exporting my files using Fat Jar and copying them over to the MacBook was all it took to migrate. [...]
Hi,
I’ve been playing around with the SoniaHelperVisualTest sketch, its really nice. I want to use a .wav file instead of a line in or mic input, but I couldn’t manage to do that. I somehow couldn’t convert the sketch to use ESS rather than Sonia, and I couldn’t make the connectLiveInput() function of the Sonia library work for this purpose.
Would you care giving some simple advice and pointing a direction for a beginner in processing?
Thanks a lot.
Hi Emre, SoniaHelper doesn’t actually deal with how the spectrum is generated, i.e. whether it’s coming from a live input or a WAV. All you need to do is use the appropriate array of FFT values generated by Sonia or ESS.
I’ve never used ESS myself, but the FFT example should get you going with how to get a FFT from a sound file. Then you just pass FFT.spectrum array to SoniaHelper.update(), and you should get the same effect as you would by passing in Sonia’s LiveInput.spectrum.
Hi,
I think I’m going to use Minim, the new sound library for processing. It is quite simple and I managed to do a couple of things really easily, compared to ESS and Sonia. I don’t think there will be a big problem incorporating soniahelper’s functions into sketches using minim library. I’ll let you know how far I can get.
Thanks,
Emre.
thanks marius
[...] which is not part of the regular Sonia library. The SoniaHelper library can be downloaded here:http://workshop.evolutionzone.com/2006/05/10/soniahelper-library/“ – Thanks [...]