gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Audio > spectrum analysis

#16606 - johnny_north - Fri Feb 20, 2004 7:47 pm

What approach (if any) is feasable for doing real-time audio spectral analysis on the GBA. I was wondering if visual output of the results is feasable on the platorm.

My guess if that the analysis would need to be performed on the mixed sound buffer. My research turns up some info on the FFT, but several of the code examples I've found use at least one common log operation.

Any input is appreciated.

#16611 - tepples - Fri Feb 20, 2004 10:50 pm

The common logs in FFT examples are used mainly to convert spectral values to decibel values. You can approximate those with a lookup table. If you just want to make a set of pretty analyzer bars for your game's "Sound Test" screen, you can do those more efficiently with a wavelet transform (I'd suggest Daubechies 4-tap as a good compromise between speed and accuracy) than with a Fourier transform.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#16619 - johnny_north - Sat Feb 21, 2004 7:00 am

That's exactly what I want to accomplish. Do you know of any C sources for the Daubechies 4-tap? I'm unable to translate the matematical formulas that google returns - also the code refs I've found are not in C and contain inexplicable method calls.

Thanks.

#16633 - tepples - Sat Feb 21, 2004 6:02 pm

Do you know what a "convolution" is in digital signal processing? If not, please read everything up through "filters" in this introduction to DSP.

Approximation of the Daubechies wavelet, expressed as FIR filters:
Low pass: {11, 19, 5, -3}/32
High pass: {-3, -5, 19, -11}/32
(In orthogonal wavelets, the high-pass filter is the low-pass filter, turned end to end, with odd-numbered samples negated.)
Code:
To do wavelet analysis:
  Let signal High be the convolution of the signal with the chosen high pass filter, keeping only even numbered samples.
  Take the energy of High (sum of the squares of the samples).
  Take an approximate logarithm of the energy.
  Draw an analyzer band whose height is linearly related to this logarithm.
  Let signal Low be the convolution of the signal with the chosen low pass filter, keeping only even numbered samples.
  If you have not drawn the desired number of bands, do wavelet analysis on Low.

_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.