Help - Search - Members - Calendar
Full Version: How to use convolution to equalize/filter playback
Hydrogenaudio Forums > Hydrogenaudio Forum > General Audio
KikeG
This comes from the "s/w equalizer for multiple audio formats" thread, but I decided to start a new thread because I think this can be interesting enough to have its own thread and title:

The advantage of using a convolution plugin for equalization is that it allows to equalize your playback using any equalization you can have access to, including the ones available at wave editors, mastering programs, DirectX/VST plugins, hardware equalizers (both analog or digital), etc.

So, in practice, all this can be achieved on realtime playback using a convolution DSP plugin, such as RealReverb convolution plugin for Winamp. However, this doesn't allow realtime adjustments from the plugin or from Winamp, and requires to generate an adequate impulse respose externally. Still, you can do your real-time adjustments outside Winamp (for example, using any of the eq./filtering possibilites from CoolEdit), and generate an impulse respose that corresponds to the desired equalization, and feed the convolution plugin with it.

How to generate an impulse response? Well, I played with this some time ago, and there can be some details that could be optimized. Still, the basic procedure would be:

- Find the eq. you need/want.
- Pass a "perfect" impulse through this equalization.
- Feed the convolution plugin with the resulting impulse response.

In detail:

1 - First, you have to generate an "perfect" impulse signal. For this, using an audio editor (CEP in this example), generate 0.5 or 1 second of silence, in mono, 32 bit, 44.1 KHz (or the rate your music is recorded at). At the middle of this silence, edit 1 sample and set it to full scale. This is a delta of Dirac impulse signal, it contains all frequencies from 0 to fs/2. you can save it, so that you don't have to repeat this step again.

2 - Now, find the equalization you are going to use. You can use anything you want, from external analog equalizers, or FFT, FIR, IIR, short, long, filters, anything that can accept a signal, equalize it, and ouput the result. For example, in CEP, you could use the built-in graphic equalizer, or any of the other filters it has. Play your music or test signal from CEP, and make your eq. adjustments so that you get the desired response.

3 - Now, you have to generate the impulse response equivalent to this eq. For this, simply apply your equalization to the delta impulse generated at (1), and there you have it. In order to optimize the convolution, edit the impulse removing as much zero samples as possible before and after the impulse. You will have to use the zoom to check this properly. Convert this impulse response to 16 bit, using preferably flat (no noiseshaping) dither with triangular pdf, 1-bit amplitude. Haven't tested what effect would have noiseshaping dither. Save this as a wav file, and you have your desired impulse ready to be used.

4 - Now, just downloadand install the RealReverb Winamp convolution plugin (Google for it), and configure it in Winamp so that it uses as impulse response the one you have generated.

The Winamp output should have the exact equalization you "designed" at CEP.


Now, some things to know:

- Convolution is slow to compute. The shorter the impulse response, the faster it will run.
- RealReverb just accepts 16-bit data, IIRC, although 24-bit or floating point impulse responses would result into less noise at the end.
- RealReverB doesn't dither the result, but in practice this is not much of an issue.
- Using this same procedure you can add reverberation to your music, using a suitable impulse response, including impulse responses recorded at real auditoriums or theatres.
- An convolution DSP plugin for FB2K would be nice wink.gif
tigre
QUOTE (KikeG @ May 6 2003 - 05:16 AM)
This comes from the "s/w equalizer for multiple audio formats" thread, but I decided to start a new thread because I think this can be interesting enough to have its own thread and title:

Great idea. This is fascinating indeed. After reading your other post about it my first thought was: "Headphone plugin!" (sorry about draging this a bit off-topic, but since I listend to some dummy-head recordings, I want everything to sound like this wink.gif )

The way I understand it (from the reading stuff google gave me) the idea behind this kind of dsp is to simulate rooms (i.e. the walls' reflections). This is done by adding several copies of the original signal with different delays and amplifications in a certain pattern that is stored in a impulse response.wav file as you said. The (to me) surprising about this is the way your method "abuses" this time domain manipulation to create changes in frequency domain.

Back to my off-topic headphone plugin thought: My google search gave me many results containing some information about impulse response and dummy-head simulation and similar, but i found nowhere something like
"download this IR .wav, load it into some convolution plugin and your headphones will have the same stereo image as your speakers"
- although I'm pretty sure this is easy to create if you have the equipment. There are lots of IR .wavs to download that are supposed to simulate certain rooms like famous concert halls etc. though. So my question:
Do you know (or anyone else) where I can get a IR .wav like this - or have I missunderstood the whole idea and this won't work?
QUOTE
An convolution DSP plugin for FB2K would be nice wink.gif

Seconded. B)
tacitus10
Check out.............

Accurate surround sound through convolution & standard stereo sources - sounds good as possible feature of Foobar?
http://www.ambiophonics.org/

Various impulses - check out the impulses of the manley massive passive (high end analogue studio eq)
http://www.echochamber.ch/

Free VST convolution Reverb
http://home.t-online.de/home/520073787260-...index_plug.html

Studio impulses of classic studio gear
http://www.geocities.com/beamsonic/studio.htm

Various Impulses
http://www.noisevault.com/
DickD
One Winamp plugin I read about suggested bursting a balloon to generate a very sharp impulse, recording the response to create the convolution function (impulse response) of the room/concert hall.

@tigre: Fourier Transform theory is the basis for using time-domain convolution to manipulate the frequency response and it has a number of very interesting implications.

A multiplication in the frequency domain (such as filtering) is equivalent to a convolution in the time domain. It can also be possible to undo (or deconvolve) the effect of some signal distortions (such as echoes and room reflections) by dividing in the frequency domain, though sometimes noise gets greatly magnified or divide-by-zero errors occur.

(In imaging, such as forensic imaging, this idea can be used to correct for motion blur, for example, if you know the point spread function. It was also used (very slow thanks to the size of the 2D FFT) for correcting the Hubble Space Telescope pictures before the corrective optics were fitted to compensate for the incorrect lens. Pointlike sources of light are sufficiently common in the universe that a point spread function was easy to determine, but the processing load is heavy)
Carlos G
In the link about impulse responses of classic audio gear, posted by tacitus10, you can find the response of several "classic" studio compressors

But is it possible to reproduce the response of a compressor through impulse response convolution? If I get it correctly, dynamics compression is a non-linear operation, so what you get is the EQ/frequency response/colouring of the compressor, but not the compression effect....

Carlos G.
tacitus10
The impulses of studio compressors such as the Joemeek are more to add the sound characteristics in the frequency domain than to act as compressors in themselves. To test them you might first use a vst or Dx plugin compressor on a source file and then process the source file with the impulse afterwards. The colouring results can be worthwhile. I was supprized how well the guitar amp impulses sound once applied to a wav source which has been processed with a standard (non modelled) digital distortion plugin. Usually digital distortion plugins sound awful on guitar files (excluding some recent modelled gear plugins).

The Manley Massive Passive EQ (32 bit float) impulses sound great.
tacitus10
Freeware convolution and DSP.

http://shoko.calarts.edu/~bcassidy/hog
DickD
I agree, Carlos. It's non-linear so the impulse response is not sufficient.

I think I read on that site that you need to apply compression first (which will create harmonic overtones), then apply the impulse response too to obtain the correct coloration.
tigre
I've got some questions about the way convolution works.

1. If I have a stereo input file and a 2 channel IR .wav file, the convolution DSP computes left channel output by "convoluting" left channel input with left channel from IR. wav - and vice versa. Or is there something else I have missed?

2. Convolution is done by simple sample-wise multiplication + addition like this (i=input; o=output; ir=impulse response .wav):
o0=i0*ir0+i-1*ir1+i-2*ir2 ...
- Or is there some "secret", e.g. is the IR file somehow "upsampled" before?

3. Is there a free convolution dsp that uses 4 channel IR information for processing stereo input?
Like this:
Output_Left = Convolute(Input_Left;IR_Left_Left)+Convolute(Input_Right;IR_Right_Left)
Output_Right = Convolute(Input_Right;IR_Right_Right)+Convloute(Input_Left;IR_Left_Right)
In this case the IR .wav file would need 4 channels: IR_Left_Left, IR_Left_Right, IR_Right_Left, IR_Right_Right
tacitus10
You can correctly create 4 channel surround audio from a 2 channel input and a 2 channel impulse response. Traditionally, the audence to a musical performance faces the performers rather thsan sit in the middle of a performance. This means that only reverb would be heard from the rear of you at a concert. Reverb from a two channel impulse response can make up the rear channel sounds to simulate the reverb that the music would make.
tigre
Sorry, If I wasn't able to ask my questions comprehensibly.

I don't want to create 4 channel output using IR, just 2 channel stereo. Like in this picture:
The way I understand it, convolution using 2 channel IR does what red and purple "do" but if you want to add green and blue, two more channels are needed.
KikeG
Tigre, I think that what you want can't be achieved with the simple convolution plugin. Look for Aurora plugins from Angelo Farina at Google, they are a set of advanced plugins for CEP that include convolution, deconvolution, inverse filtering, MLS and IRS measurements, and IIRC allow also cross-channel processing.
DickD
Nice pointer. I found Aurora's website.

Apparently it can create Inverse Impulse Response filters (including Flatten Spectrum).

For the equalization idea it would be possible to play an approximated delta function as described at the top of the thread(caution - don't play it so loud it could damage your speakers) and record it with a good condenser microphone with a trusted wide and flat frequency response in your usual listening position (or even binaural condenser microphones in your ears in your usual position!)

The impulse originally sent through your analog circuitry (e.g. DAC's reconstruction filter + amplifier + tone control + cables + crossover + loudspeaker + room reflections) will have been coloured by the various components and will come out as a broadened impulse with some ripple and delayed, attenuated reflections, probably.

The inverse impulse response when convolved with the delta function will create a signal that when passed through the same system, will reach your listening position pretty-well reconstructed as the same delta function - i.e. it should be "correct" EQ.

Note that any desirable filtering (e.g. 20-22.05 kHz filter to aid Nyquist reconstruction of digital audio - and not too steep, so you prevent temporal ripple) may be counteracted by the IIR, so you should probably filter the IIR you generate to ensure you still prevent aliasing and obey Nyquist's theorem. Perhaps even better would be to FFT filter the delta function to at most, 20.5 kHz in Cool Edit, with a smooth roll-off to your Nyquist limit.

Another more complicated (and difficult) possibility that benefits from more energy in the test signal (so better accuracy) is to send a known broadband (e.g. white) noise, which lasts longer than one sample so has more energy than the Dirac Delta function. A Fourier Transform would calculate the frequencies produced (plus complex information relating also to phase), and could be compared to the Fourier Transform of the original noise signal. Dividing the original FT by the response FT, you'd get the FT of the deconvolution function, and could reconstruct the deconvolution function using an inverse FT. (You could filter this gently from 20-22 kHz to avoid overcoming the DAC's reconstruction filter)

The other approach to using noise for this would be correlation, but that's even more complicated, and possibly less useful in this instance.

If you sit in the same place each time, Aurora can also cancel the crosstalk and allow you to play back binaural recordings with loudspeakers.

The links at the end of the Aurora page include some freeware progs to do some of the same things.
KikeG
Aurora lets you use MLS and IRS signals plus deconvolution for impulse response measurements, in a quite simple way. The advantage of these signals is that they are signals with much more energy than a simple impulse, and thus less problematic when it comes to the SNR of the measurement. IRS measurement is better tham MLS, because is more inmune to nonlinearities of the setup (speakers).

As to measured response, freq. response of soundcard + cables + amp will be despreciable (unless you use very crappy sc or amp) in comparison with freq. response of speakers + room.
Garf
After reading this thread, I programmed a convolution filter for foobar2000: (okay, there was some delay between the two smile.gif)

http://www.hydrogenaudio.org/show.php/act/...ST/f/33/t/10611
KikeG
Good!
mp3chan
If I want to apply 2 convolutions or more, can I just mix several convolution wave files into one file and use it?
ErikS
QUOTE (mp3chan @ Sep 15 2003, 03:15 PM)
If I want to apply 2 convolutions or more, can I just mix several convolution wave files into one file and use it?

If you by "mix" mean "convolve", then it should be possible. f * (g * music) = (f * g) * music, where * is convolution.
Xenion
is it really possible to create impulse responses of tubes ?
do tubes opperate linear ?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.