| At 11:55 AM +0930 4/28/98, Peter wrote:
>Being a bit of a convolution fan I have also often wondered how I would go
>about making one of those " single infinitely-narrow spike " as it might be
>fun to set one off in various accoustic environments to record the impulse
>response for use with convolution. Im sure it's simple enough to do in Csound
>but I dont have any ideas on where to start. Any help would be truly great.
A bit of nomenclature and such: Sounds are continuous signals, meaning that
they exist or have values at all possible values of time. Csound in
particular (and computers in general) deals with discrete signals, meaning
that they exist or have values ONLY at fixed times (the sample times). The
continuous-time impulse is that funny infinitely-narrow
infinitesimally-thin unit-area thing. The discrete-time impulse is a single
sample of value 1 (one) surrounded by zeros.
Within Csound you can measure the impulse response of a Csound ugen with
something like:
;Orc
sr = 44100
kr = 44100 ;avoid problems with impulse generation
ksmps = 1
nchnls = 1
;-----------------------------------------------------------
instr 6
idur1 = 7/sr ;read the table once
idur2 = 1/sr
ifreq = sr/8 ;read the table at 1 point per sample
a1 linseg ifreq,idur1,ifreq,idur2,0,1,0
a2 oscil 1,a1,1
a3 reson a2,sr/10,sr/200 ;the system under test
out a3
display a1,p3 ;display the impulse response
dispfft a3,p3,4096,0,1 ;frequency response
endin
;Sco
f1 0 8 2 0 1 0 0 0 0 0 0
;create a table with an impulse in the second position
;------------------------------------------------------
i6 0 0.185759637 ;create 2^14 (8192) samples
If you send out a2 instead of a3, you will hear the impulse-response of
your A-to-D converter - amplifier - speaker system. As mentioned by someone
else earlier, the total energy in that output would be very small, even if
you scaled it to 32767 or -32768. If you tried to record the room response
to that impulse response, you'd have a horrible S/N ratio. As also
mentioned, some people do use spark gaps as approximate sonic impulse
generators.
As also mentioned earlier (although perhaps just a touch lacking in detail)
since the frequency response is just the Fourier transform of the impulse
response, and the impulse response is just the inverse Fourier transform of
the frequency response, you can measure the frequency response of the room
and take the inverse Fourier transform to get the impulse response. There
are lots of neat tricks you can use (involving auto-correlation,
cross-correlation, and energy spectral density) to increase the S/N and
reject uncorrelated noise, but the basic idea is to measure the room
frequency response to get at the impulse response.
You can calculate the impulse response directly using auto- and
cross-correlation but using FFT's and the spectral density is usually
orders of magnitude faster. In either case the input is usually several
seconds of pseudo-random noise.
Oops! As usual I've given a verbose answer to a short question.
-------------------------------------------------------------------------------
Erik Spjut (rhymes with cute) - Acting Director,The Center for Design Education
and/or Associate Professor of Engineering
Harvey Mudd College, Claremont, CA 91711 USA
Erik_Spjut@hmc.edu Ph & Voice mail (909) 607-3890 Fax (909) 621-8967
|