DSPRelated.com
Forums

Techniques behind arbitrary response or "drawable" equalizers?

Started by Unknown June 14, 2016
On Tuesday, June 21, 2016 at 8:18:48 AM UTC-4, Bob Masta wrote:
> > Yes, mine is the 3rd edition. Section 13.10 is "Fast FIR > Filtering Using The FFT", pages 688 to 694. OLA and OLS each > have separate descriptions, with half-page block diagrams > and a full page of detailed step-by-step instructions for > each. > > For both methods, variable N is the FFT length, P is the > filter input sequence length, Q is the impulse response > length, and M is the unpadded part of N, equal to N-(Q-1) > since the input block is padded with Q-1 zeroes. >
dunno why both P and M are necessary. they appear to be the same thing. the constraint that must be satisfied (to prevent time-domain aliasing): N >= P + Q - 1 so M = N - (Q-1) = P or at least it's M >= P r b-j
On 6/14/16 8:47 AM, Marcel Mueller wrote:
> > I implemented similar things several years ago for an 32 band audio > equalizer plug-in with group delay equalization. > http://maazl.de/project/pm123/manual/realeq/index.html > The source code is still available as part of the PM123 package > http://maazl.de/project/pm123/pm123-1.41b3-src.zip > Well adjusted the result sounds rather impressive, quite close to > digital room correction.
hi Marcel, i took a look at your realeq page (which shows 32 1/3 octave bands and sliders) and downloaded the pm123... zip file and only *started* snooping around in it. i would rather not reverse engineer your source code, there are over a dozen directories of different code, and i am not sure where to find the code that would answer my question. so is your 32-band equalizer done with FFT and overlap-add or overlap-save FIR? and is the frequency response (and FIR coefficients), is that designed with the Parks-McClellan alg? and, if that's the case, then is it linear phase? just curious. BTW, the utility C code you have for WAV and AIFF file I/O appears to me to be nice and very useful. maybe even the FFT. may i make use of it? -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
On Tue, 21 Jun 2016 12:35:20 -0700 (PDT), robert
bristow-johnson <rbj@audioimagination.com> wrote:

>On Tuesday, June 21, 2016 at 8:18:48 AM UTC-4, Bob Masta wrote: >> >> Yes, mine is the 3rd edition. Section 13.10 is "Fast FIR >> Filtering Using The FFT", pages 688 to 694. OLA and OLS each >> have separate descriptions, with half-page block diagrams >> and a full page of detailed step-by-step instructions for >> each. >> >> For both methods, variable N is the FFT length, P is the >> filter input sequence length, Q is the impulse response >> length, and M is the unpadded part of N, equal to N-(Q-1) >> since the input block is padded with Q-1 zeroes. >> >dunno why both P and M are necessary. they appear to be the same thing. the constraint that must be satisfied (to prevent time-domain aliasing): > > N >= P + Q - 1 > >so M = N - (Q-1) = P or at least it's M >= P > >r b-j
In Rick's description, P is the overall length of the input, which is typically much longer than N and hence is the reason OLA or OLS is needed in the first place, since you have to process the total input in chunks. Best regards, Bob Masta DAQARTA v9.20 Data AcQuisition And Real-Time Analysis www.daqarta.com Scope, Spectrum, Spectrogram, Sound Level Meter Frequency Counter, Pitch Track, Pitch-to-MIDI FREE 8-channel Signal Generator, DaqMusiq generator Science with your sound card!
On 21.06.16 23.45, robert bristow-johnson wrote:
> hi Marcel, i took a look at your realeq page (which shows 32 1/3 octave > bands and sliders) and downloaded the pm123... zip file and only > *started* snooping around in it. > > i would rather not reverse engineer your source code, there are over a > dozen directories of different code, and i am not sure where to find the > code that would answer my question.
You only need to look at the realeq directory. ;-)
> so is your 32-band equalizer done with FFT and overlap-add or > overlap-save FIR?
Exactly.
> and is the frequency response (and FIR coefficients), > is that designed with the Parks-McClellan alg?
Never heard about that, but most likely no. I use a cosine interpolation between the slider positions, but at a logarithmic scale.
> and, if that's the case, > then is it linear phase?
No. There are another 32 sliders to adjust the group delay for each frequency, i.e. dPhi/dOmega. This gives significant improvements to stereo playback and compensates for delays of room resonances and vented enclosures if used appropriately. It would be straight forward to use even more taps to design the target response or maybe any other data source. Just the GUI can't hold with that. And probably even an audio engineer cannot adjust 256 sliders with reasonable effort.
> BTW, the utility C code you have for WAV and AIFF file I/O appears to me > to be nice and very useful. maybe even the FFT. may i make use of it?
The code is originally not from me. PM123 has been a commercial product around Y2k. It is released with a BSD like license at the end of product lifetime by the original manufacturer. Later Glassman and I did major changes to the code. E.g. I replaced the amazingly bad calculation of the target response from the slider positions in realeq. The code with BSD license is no big deal. You can use it for commercial and non commercial purpose. But some open source libraries have been added to the code. They are mostly LGPL or maybe even GPL. This restricts commercial use. However, the AIFF code you mentioned probably turns out to be just an OS/2 port of libsndfile which is part of almost any Linux distribution. (The OS/2 kernel cannot deal with shared libraries with more than 8 characters, so the library has been renamed.) Marcel
On Wednesday, June 22, 2016 at 4:38:49 PM UTC-4, Marcel Mueller wrote:
> On 21.06.16 23.45, robert bristow-johnson wrote: >
...
> > so is your 32-band equalizer done with FFT and overlap-add or > > overlap-save FIR? > > Exactly.
okay, one of the two, anyway.
> > > and is the frequency response (and FIR coefficients), > > is that designed with the Parks-McClellan alg? > > Never heard about that,
sometimes called "Remez Exchange Algorithm".
> but most likely no. > > I use a cosine interpolation between the slider positions, but at a > logarithmic scale.
okay, that makes good sense.
> > > and, if that's the case, > > then is it linear phase? > > No. There are another 32 sliders to adjust the group delay for each > frequency, i.e. dPhi/dOmega. > This gives significant improvements to stereo playback and compensates > for delays of room resonances and vented enclosures if used appropriately.
okay, well you can't do any less delay than what you would get with a minimum-phase filter.
> It would be straight forward to use even more taps to design the target > response or maybe any other data source. Just the GUI can't hold with > that. And probably even an audio engineer cannot adjust 256 sliders with > reasonable effort.
so are you essentially designing the FIR with the windowing method? Kaiser window? if so, with the arbitrary settings of gain and group delay, do you delay the result of the iFFT enough to make it close to causal? then window it? just curious. r b-j
On 23.06.16 05.26, robert bristow-johnson wrote:
> On Wednesday, June 22, 2016 at 4:38:49 PM UTC-4, Marcel Mueller wrote: >> On 21.06.16 23.45, robert bristow-johnson wrote: >> > ... >>> so is your 32-band equalizer done with FFT and overlap-add or >>> overlap-save FIR? >> >> Exactly. > > okay, one of the two, anyway.
I am not sure. This part of the algorithm has been there before. I think it is overlap-add.
>>> and is the frequency response (and FIR coefficients), >>> is that designed with the Parks-McClellan alg? >> >> Never heard about that, > > sometimes called "Remez Exchange Algorithm".
Ah, OK, I heard of that. I didn't really understand the algorithm and decided that it is not suitable for this purpose since the idea is not to reproduce the response at the data points as exact as possible and ignore the anything else. For audio processing properties should not change fast over frequency to avoid audible artifacts.
>>> and, if that's the case, >>> then is it linear phase? >> >> No. There are another 32 sliders to adjust the group delay for each >> frequency, i.e. dPhi/dOmega. >> This gives significant improvements to stereo playback and compensates >> for delays of room resonances and vented enclosures if used appropriately. > > okay, well you can't do any less delay than what you would get with a minimum-phase filter.
That's right in theory. And with FFT convolution you can not even touch the minimum latency. In practice it is a plug-in of an digital audio player. And digital audio players use buffers for decoupling of the pipeline stages. There is no audible delay at all. The engine just takes the required samples for convolution a bit earlier out of the pipeline. Of course, the buffers need to be discarded when the sound source changes abruptly, e.g. in case of a seek operation. But unless your hardware is very slow you will not get any noticeable delay. Without this trick FIR orders of up to 16k (@44 or 48k/s) were not reasonably usable.
>> It would be straight forward to use even more taps to design the target >> response or maybe any other data source. Just the GUI can't hold with >> that. And probably even an audio engineer cannot adjust 256 sliders with >> reasonable effort. > > so are you essentially designing the FIR with the windowing method? Kaiser window?
No. See below. (OK, the FIR order is in fact a rectangular window.)
> if so, with the arbitrary settings of gain and group delay, do you delay the result of the iFFT enough to make it close to causal?
Since this application is not very sensitive to latency I just use symmetric filters (unless the group delay sliders are used). And the delay sliders just move the sinc elementary functions around some milliseconds. OK, the first FIRorder/2 samples of the output are dropped, if this answers your question.
> then window it?
Because of the nature of the cosine interpolation there is no window function required. The effect of this interpolation is quite similar to a window function. But the result is more smooth in the frequency domain. Comb filter effects would impact spatial resolution. I did several simulations in Mathematica and it turned out that an additional window function always /worsen/ the result. The idea behind this is: if you don't request impossible results you will not need a window function. One should keep in mind than an equalizer does not need more than 24 dB stopband attenuation. And the filter selectivity is also restricted by the distance of the first two sliders. Of course, selecting an entirely different target response (e.g. a line frequency notch) changes the required algorithm. But beware of audible artifacts. They are likely to come with high selectivity filters. Using FIR filters for equalizers is quite uncommon. Mainly because of the required latency. But it is by far more complex to design a custom IIR filter for a given response than just to do an IFFT. Most digital EQs are just a sequence of biquads. But they cannot really compensate for group delays, although there would be some options with all-pass biquads. In theory they could compensate for group delay by using pole zero cancellation unless there are zeros in the positive half-plane. But usually you only have the first part of the step response and the Z transform is complicated and the resulting filter might be numerically unstable. So in practice you end up with a parametric EQ, again with a series of biquads. The FIR EQ with delay equalization in contrast can significantly reduce the step response of speakers and room without too many artifacts. The effect is close to digital room correction. (The technique in fact too.) Marcel
On 6/22/16 8:22 AM, Bob Masta wrote:
> On Tue, 21 Jun 2016 12:35:20 -0700 (PDT), robert > bristow-johnson<rbj@audioimagination.com> wrote: > >> On Tuesday, June 21, 2016 at 8:18:48 AM UTC-4, Bob Masta wrote: >>> >>> Yes, mine is the 3rd edition. Section 13.10 is "Fast FIR >>> Filtering Using The FFT", pages 688 to 694. OLA and OLS each >>> have separate descriptions, with half-page block diagrams >>> and a full page of detailed step-by-step instructions for >>> each. >>> >>> For both methods, variable N is the FFT length, P is the >>> filter input sequence length, Q is the impulse response >>> length, and M is the unpadded part of N, equal to N-(Q-1) >>> since the input block is padded with Q-1 zeroes. >>> >> dunno why both P and M are necessary. they appear to be the same thing. the constraint that must be satisfied (to prevent time-domain aliasing): >> >> N >= P + Q - 1 >> >> so M = N - (Q-1) = P or at least it's M >= P >> >> r b-j > > In Rick's description, P is the overall length of the input, > which is typically much longer than N and hence is the > reason OLA or OLS is needed in the first place, > since you have to process the total input in chunks. >
okay so P can be infinity. it's a number that doesn't have a function because this OLA or OLS thing can run continuously and forever in real time. the number of samples per chunk processed is, evidently M and it's Q + M - 1 <= N for OLS there are no padded zeros in the chunk of input that goes to the FFT. and in OLA, there are Q-1 padded zeros in the chunk of input that goes to the FFT. in both cases there are M legit output samples. in OLS you "scrap" Q-1 samples that are invalid because of circular aliasing from the convolution. in OLA, you have to overlap and add Q-1 samples from the previous chunk and output the earliest M samples. the latter remaining Q-1 samples are saved for overlapping and adding to the beginning of the following chunk. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
On Fri, 24 Jun 2016 00:43:58 -0400, robert bristow-johnson
<rbj@audioimagination.com> wrote:

>On 6/22/16 8:22 AM, Bob Masta wrote: >> On Tue, 21 Jun 2016 12:35:20 -0700 (PDT), robert >> bristow-johnson<rbj@audioimagination.com> wrote: >> >>> On Tuesday, June 21, 2016 at 8:18:48 AM UTC-4, Bob Masta wrote: >>>> >>>> Yes, mine is the 3rd edition. Section 13.10 is "Fast FIR >>>> Filtering Using The FFT", pages 688 to 694. OLA and OLS each >>>> have separate descriptions, with half-page block diagrams >>>> and a full page of detailed step-by-step instructions for >>>> each. >>>> >>>> For both methods, variable N is the FFT length, P is the >>>> filter input sequence length, Q is the impulse response >>>> length, and M is the unpadded part of N, equal to N-(Q-1) >>>> since the input block is padded with Q-1 zeroes. >>>> >>> dunno why both P and M are necessary. they appear to be the same thing. the constraint that must be satisfied (to prevent time-domain aliasing): >>> >>> N >= P + Q - 1 >>> >>> so M = N - (Q-1) = P or at least it's M >= P >>> >>> r b-j >> >> In Rick's description, P is the overall length of the input, >> which is typically much longer than N and hence is the >> reason OLA or OLS is needed in the first place, >> since you have to process the total input in chunks. >> > >okay so P can be infinity. it's a number that doesn't have a function >because this OLA or OLS thing can run continuously and forever in real >time. the number of samples per chunk processed is, evidently M and it's > > Q + M - 1 <= N
Rick uses P earlier, along with Q, in determining whether you need OLS/OLA. You can avoid it if N => Q + P - 1.
>for OLS there are no padded zeros in the chunk of input that goes to the >FFT. and in OLA, there are Q-1 padded zeros in the chunk of input that >goes to the FFT.
Rick prepends Q-1 zeros for OLS, and appends them for OLA. In both cases the input chunk is N = M + Q - 1 samples.
>in both cases there are M legit output samples. in OLS you "scrap" Q-1 >samples that are invalid because of circular aliasing from the >convolution. in OLA, you have to overlap and add Q-1 samples from the >previous chunk and output the earliest M samples. the latter remaining >Q-1 samples are saved for overlapping and adding to the beginning of the >following chunk.
Yep, that's the way Rick explains it. Best regards, Bob Masta DAQARTA v9.20 Data AcQuisition And Real-Time Analysis www.daqarta.com Scope, Spectrum, Spectrogram, Sound Level Meter Frequency Counter, Pitch Track, Pitch-to-MIDI FREE 8-channel Signal Generator, DaqMusiq generator Science with your sound card!
How can the FIR be designed in OLA or OLS filtering method?
On Wednesday, June 29, 2016 at 6:52:06 AM UTC-4, Matti Viljamaa wrote:
> How can the FIR be designed in OLA or OLS filtering method?
the same you design an FIR that is not OLA or OLS. depends on what you're trying to do. are you trying to emulate the reverberation of a real room? then the FIR is measured as an impulse response of the room. (you might use maximum-length sequences or swept sinusoids as the driving signal, and you have to simultaneously be recording the sound in the reverberant room.) usually the other methods we use for designing FIRs, Parks-McClellan, Least-Square error, inverse DFT and windowing the result, these are often for shorter FIRs that are implemented more directly rather than OLS or OLA. r b-j