slightly ot: room impulse response and inverse impulse response
Martin Czech
martin.czech at intermetall.de
Tue Dec 21 15:05:52 CET 1999
Caution: This is a long one. It may pay to read it to
the end, however.
A couple of weeks ago I kicked off a thread about room impulse response,
measuring that, and convolution. Time to knitt a bit further.
One question was, if I have a nonideal impulse source (pistol etc.),
will I be able to compute a actual working reconstruction filter, ie. a
filter that will make the nonideal impulse ideal (maybe delayed) and thus
the nonideal room impulse response to be he ideal room impulse response.
After some hundred lines of C-code the anser is yes, and no...
Yes, I was able to compute a FIR filter with the desired property:
H(z) * F(z) = UI(z)
with: H(z) pistol spectrum
F(z) reconstruction filter spectrum
UI(z) unit impulse response spectrum
at least with a couple of synthetic test functions h(n), eg. exponential
decay sinusoids.
(Btw.: Pistol. I'm trying to get a device that uses compressed air.
No fumes (this might upset the church keepers!). Another idea is to uses
a spring driven plate, crashing into a fixed plate. Another idea was
the kind of starting device for the 100m dash... I guess large rooms
will enable me to seperate direct sound from reverb, about 6ms/m if the
nearest wall is considered. In this case an electronic gate could prevent
overload during the first wave front. The pseudo noise generator idea
is nice, but I think a generator with reasonable output would require
large speakers... which is impossible to carry in a briefcase.)
Sometimes the resulting filter impulse response f(n) is longer than
allowed for use in circular convolution. What does this mean? Eg. I
use a window of 256 samples. h(n) has only 50 samples,
I compute H(z) via FFT (256 points z=unit circle). Then I compute an
ideal impulse response ui(n), this is simply a single "1" at the same
place of the maximum of h(n) (this way I hope that the reconstruction
filter has less work to do, ie. the results will be better).
Now I compute F(z)=UI(z)/H(z) (again z is on unit circle, at 256
locations).
This enforces H(z)*F(z)=UI(z).
Here we have the first possible problem: division by zero. This may happen,
and it did indeed happen. In this case I modified h(n) a little bit, this
means manipulationg the pistol sample with eg. Cool Edit, plucking a sample
here and there. I have no other solution for this rather seldom problem.
If you think about noise floor in real samples, this might really never
happen. No real problem, I think.
Now backtransform F(z) to f(n) via inverse FFT.
Now the real trouble starts. We want:
h(n) ** f(n) = ui(n) (**: convolution)
The above described algorithm works, the convolution yields a unit impulse
(may be delayed). So we're finished? No!!
We have to keep in mind that we only can compute a circular convolution
via DFT or FFT, or in other terms: only circular convolution corresponds
to DFT. You know, circular convolution mixes up future and past of
a wave , at least from the perspective of normal convolution.
In other terms: The required filter may be unrealizeable.
So the above described algorithm insures an ideal impulse response
reconstruction filter, but unfortunately one that works with circular
convolution. Of course we need normal convolution. It is not guaranteed
that f(n) will work with normal convolution.
When does circular convolution match normal convolution? When the result
is shorter or as long as the chosen window length. So the trouble starts
when f(n) is very long. If h(n) has N samples and f(n) has M samples,
then the normal convolution result has N+M-1 samples. Clearly some f(n)
were by far to long, so that no unit impulse sequence appeared after
normal convolution, but something completely different.
Remedy:
I have the feeling that increasing the window length does not solve the
problem. f(n) will simply get longer, too.
Pistol like sounds ( a pistol makes "snapppp", not "booouuummm" like
you hear it in cinema and tv sound effects) look much like sharpe
impulses, test signals like this behaved well.
Some f(n) have many zeros, some peaks for low n, and a few peaks for the
last n. This means we could delay f(n) in a circular manner, so that
the peaks for large n are now at n=0 and a bit higher. Since most of
the samples are zero, we can manage it so that the tail of the shiftet
f(n) is all zeros, ie. the effective lenght is reduced considerably
so that circular convolution and normal convolution match again.
This manipulation only means further delay for the unit impulse sequence,
which is no porblem.
Conclusion:
I hope by the experience of the examples that I computed that most, if not
all practical "pistol" impulse responses can be filtered via convolution
with complete restauration of the unit impulse shape. If this works I
can take samples of room responses and convert them into ideal impulse
room responses, and these in turn can be used to virtually place any
sound into the measured acoustic environment.
Voice from the off: "This has nothing to do with synth diy".
I aggree, my friend. Partly. But we all need some kind of reverb, when
it comes to actuall recording. Wouldn't it be nice to have natural room
responses in your studio, that will cost you nothing?
I'll try to finish my fast convolver C-source. I hopefully will put it
on my web site, and also DOS executeable.
I'll try to record some impulse responses during Christmas vacations.
I know at least one church where they wouldn't arrest me for firing
a pistol (no, not during service...)
Later on I'll put the impulse responses there. And I will put all the
impulse responses of my XXX and YYY reverb effects there.
No, I'm not stupid. I'm doing this because I have trouble in getting
real 16 bit audio resolution when using external effects like this
via ADC/DAC conversion. This is extremely harmfull to "thin" sounds,
like sparsely placed impulses, like piano etc. Of course, the recorded
impulse responses are noisy, too. But this is froozen noise, this froozen
noise has lost all of it's randomness, it's simply a part of the impulse
response and it will only add to the perception of diffuseness, not to
noise, after my experiments.
So , I'm doing this for myself, to solve some problems, putting it on
the web is no real trouble.
Off course, computing convolution with long impulse responses is time
consuming. And it is not possible to get an instant real time output,
even with a GHz cpu. But I think the results justify the amount of time.
Note that the output is a signal that is called "effect" on most
machines, ie. without the direct signal. The most important parameter
is the direct/effect ratio, this can be manipulated in realtime, it is
simply a track mixdown on your HDR.
And it is mono based, ie. a mono source is taken and processed with a
single impulse response. Use another, slighly different impulse response
for the other channel. Or an impulse response taken 20 m away (very long
baseline stereophony ;-.>>>).
Since it is command line driven, it can be run as batch job @ night.
I have only a 100MHz machine, but it is reasonable fats for most cases.
Now: what do the gurus say to my results? Any theoretical hints?
Any failures? Any pitfalls?
And: who would like to share impulse responses with me? Also of your
effects? (Please respond NOT to the list, private).
m.c.
(in the domes of reverb) (enjoy x-mas)
More information about the Synth-diy
mailing list