DSPRelated.com
Forums

reinventing the 1/3 octave wheel

Started by b.ch...@linkeng.com May 12, 2009
Hi All,

I am a total newbie to this group, a lonmgtime programmer but with no DSP experience. I have been lurking in this group for a little while, trying to get up to speed. Please forgive any stupid questions here...

I'm trying to write some code (in Borland Delphi or MSVC) to process a stream of audio samples from a sound card into 1/3 octave buckets - essentially a spectrum analyzer. I'd like to stick as close to the ANSI standards as possible, as the output of this "analyzer" needs to feed the input of a Zwicker-analysis algorithm.

From what I've been able to discern from posts here, I should be using a set of FIR filters with the proper coefficients, rather than trying to cobble up 1/3 octave bands from fixed width FFT buckets (which I tried to do, but with mixed/poor results).

Now it seems to me that I must be the millionth person trying to do this, and that there is probably a "standard set" of filter coefficients and routines that will do this job (e.g. "given a set of 16-bit samples taken at 48Khz, run them through this routine with this full-scale to get these bands..."). Yet as I google for this information, I don't find anything like this. What I *have* found are references to Matlab code to generate generic filter coefficients, or numerous filter design programs, or analyzers (B&K) that I can purchase.

Are there any "standard" sets of FIR coefficients to use for an ANSI-compliant 1/3 octave filter? Is there any example code out there that illustrates how to do this? Or am I oversimplifying the problem? Surely others have traveled this road many times, and I'd like to avoid re-inventing the wheel if at all possible!

Thanks for any help you can provide!

-bill
Bill,
Given enough coefficients, FIR filters can replicate just about ANY
curve.

But, when creating banks of octave-related (or 1/3 octave) filters,
IIR filters are more naturally suited to the task. By nature, the
rolloff of an IIR falls logarithmically, while FIRs fall off linearly.

If efficient usage of DSP cycles is at all important for this task,
IIRs are MUCH more efficient than FIRs.
And latency through such an IIR filter bank would be relatively short
versus FIR.
Not trying to dissuade you from using FIR for this, just saying IIRs
have some advantages...

Although I don't myself have a set of coefficients for ANSI-compliant
1/3 octave filter sets (FIR or IIR) to offer you, I would imagine
there are a number of people here who could help you.

David Reaves

On Tue May 12, 2009 6:34 pm ((PDT))"b...@linkeng.com" wrote:
>
> Hi All,
>
> I am a total newbie to this group, a lonmgtime programmer but with
> no DSP experience. I have been lurking in this group for a little
> while, trying to get up to speed. Please forgive any stupid
> questions here...
>
> I'm trying to write some code (in Borland Delphi or MSVC) to process
> a stream of audio samples from a sound card into 1/3 octave buckets
> - essentially a spectrum analyzer. I'd like to stick as close to the
> ANSI standards as possible, as the output of this "analyzer" needs
> to feed the input of a Zwicker-analysis algorithm.
>
> From what I've been able to discern from posts here, I should be
> using a set of FIR filters with the proper coefficients, rather than
> trying to cobble up 1/3 octave bands from fixed width FFT buckets
> (which I tried to do, but with mixed/poor results).
>
> Now it seems to me that I must be the millionth person trying to do
> this, and that there is probably a "standard set" of filter
> coefficients and routines that will do this job (e.g. "given a set
> of 16-bit samples taken at 48Khz, run them through this routine with
> this full-scale to get these bands..."). Yet as I google for this
> information, I don't find anything like this. What I *have* found
> are references to Matlab code to generate generic filter
> coefficients, or numerous filter design programs, or analyzers (B&K)
> that I can purchase.
>
> Are there any "standard" sets of FIR coefficients to use for an ANSI-
> compliant 1/3 octave filter? Is there any example code out there
> that illustrates how to do this? Or am I oversimplifying the
> problem? Surely others have traveled this road many times, and I'd
> like to avoid re-inventing the wheel if at all possible!
>
> Thanks for any help you can provide!
>
> -bill
Thanks David.

I appreciate your suggestions - I have no qualms about using IIR vs. FIR - whatever gets the job done is OK with me! This is a post-processing task (I'm reading the samples from a .WAV file, so it's not a realtime task), so CPU cycles are not quite as critical as they might otherwise be.

I was just thinking that this task has probably been done many many times before, and so I was hoping that perhaps someone has developed a "standard" set of filter coefficients and algorithms. I hate to re-invent the wheel if I don't have to.

However, if that doesn't exist (or is not readily available), then I will go down the path of:
1) Learning FIR/IIR filter design
2) Ordering the relevant ANSI standards
3) Obtaining MATLAB or other necessary software
4) Designing the filters
5) Implementing and testing the filters
6) Compare results with an industry standard analyzer (e.g. B&K Pulse unit)

I'm really hoping I can skip steps 1-4. Actually, the final goal is to get Zwicker loudness "SonesGF" values, but to do that, I need the intermediate "1/3 octave" values to feed into the Zwicker algorithm. Fortunately, the Zwicker algorithm has been published, so I am lucky there!

Thanks for your response.

-bill
Hi,
1/3 octave (or 1/10 decade) in audio means (ISO R 266 and ANSI S1.6-1984):
fc[n]*e^(n/10) 15<=n or
fc[k]=2^k/3*1000Hz

Nominal freq: 31.5 40 50 63 80 100 125 160 200 250 315 400 500 630 800 1000 1250 1600 2000 Hz, etc.
The upper and lower band edges are:
fcl=sqrt(fc[k-1]*fc[k])
fch=sqrt(fc[k]*fc[k+1])

In general, you need to implement passband filters with unity gain in the center frequency and certain attenuation in the rejected bands.
With these parameters, you can design the filters. You can use any filter but it is often used IIR butterworth filters.

Matlab may helps you:
http://www.mathworks.com/products/filterdesign/demos.html?file=/products/demos/shipping/filterdesign/octavedemo.html

Regards,
Pablo

Hi All,
>
>I am a total newbie to this group, a lonmgtime programmer but with no DSP experience. I have been lurking in this group for a little while, trying to get up to speed. Please forgive any stupid questions here...
>
>I'm trying to write some code (in Borland Delphi or MSVC) to process a stream of audio samples from a sound card into 1/3 octave buckets - essentially a spectrum analyzer. I'd like to stick as close to the ANSI standards as possible, as the output of this "analyzer" needs to feed the input of a Zwicker-analysis algorithm.
>
>From what I've been able to discern from posts here, I should be using a set of FIR filters with the proper coefficients, rather than trying to cobble up 1/3 octave bands from fixed width FFT buckets (which I tried to do, but with mixed/poor results).
>
>Now it seems to me that I must be the millionth person trying to do this, and that there is probably a "standard set" of filter coefficients and routines that will do this job (e.g. "given a set of 16-bit samples taken at 48Khz, run them through this routine with this full-scale to get these bands..."). Yet as I google for this information, I don't find anything like this. What I *have* found are references to Matlab code to generate generic filter coefficients, or numerous filter design programs, or analyzers (B&K) that I can purchase.
>
>Are there any "standard" sets of FIR coefficients to use for an ANSI-compliant 1/3 octave filter? Is there any example code out there that illustrates how to do this? Or am I oversimplifying the problem? Surely others have traveled this road many times, and I'd like to avoid re-inventing the wheel if at all possible!
>
>Thanks for any help you can provide!
>
>-bill