DSPRelated.com
Forums

Convolution of 2 different sized arrays of data?

Started by Fleabag November 22, 2005
in article 1132687099.077758.227910@g49g2000cwa.googlegroups.com, dbell at
dbell@niitek.com wrote on 11/22/2005 14:18:

> Actually I was asking because of a practical problem. If the OP plans > to hook this to his instrument, using an FFT to implement a reverb with > a 100K sample data requirement would mean a 2+ second delay at 44.1 > Ksps to accumulate enough data to generate FFT outputs. Playing a > guitar with the sound out delayed by 2+ seconds could be rather > confusing. If he was looking to integrate this with his instrument he > should do a time domain implementation to avoid the data accumulation > delay.
you're absolutely right, Dirk. my apologies. i only wanted to point out that the computational complexity issues can apply in both cases where one input to the convolution is arbitrarily long and the other input (the impulse response) is a definite finite length. one thing that this brings to mind, is that there *is* a sorta fast convolution with little or no additional delay (compared to the straight time-domain FIR) that Bill Gardner had written about (in JAES and his Ph.D. thesis) and Lake DSP had patented (i think to Bill's chagrin). computationally, it costs more than the optimal fast convolution, but you *can* get very little delay. you can check out what i mean at http://alumni.media.mit.edu/~billg/ . -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
jeremyscerri@gmail.com wrote:

> another option is to convolve in the time domain i.e. no need to do an > fft on both the impulse response and the signal, if you have matlab it > is as simple as importing the signal from a wave file
...
> ab=conv(a,b);
If you check out the help file, then you'll find that the "conv" function is implemented in frequency domain.
robert bristow-johnson wrote:
> in article mrOdnSFQSfEN1x7enZ2dnUVZ_t6dnZ2d@rcn.net, Jerry Avins at > jya@ieee.org wrote on 11/22/2005 11:42: > > >>If the impulse response isn't very long, a transversal FIR will be >>simpler. If the IR is short enough, the FIR will be faster as well. >>Conversion to and from the frequency domain allows multiplication to >>replace convolution, but it isn't worth driving ten miles out of ones >>way to buy gas a penny cheaper. > > > that's a good point, Jerry. this sounded so familiar to me that i looked up > in Google groups where we had talked about this recently on comp.dsp. i > tried to define the issue here: > > http://groups.google.com/group/comp.dsp/msg/f4db8236019f395d > > it depends on how your FFT cost function is, but there is a tradeoff. back > in the early 80's, when we ignored everything other than the cost of > multiplication, i seem to remember that the tradeoff happened at about an > FIR length of 8.
There's more to consider than execution time. For an off-line one-off, time to get the code working dominates by far. Even for streaming real-time use, the simpler code is good enough if executes fast enough. "Improve the recorded ... sound" seems to imply plenty of time to process, so I imagine that Fleabag will get to listen to his results sooner with a time-domain FIR, even if the room's impulse response is a couple of seconds. Later, if he wants, he can write a faster routine to do the same job, but he'll have something to compare against (it should match bit for bit if everything is fixed point) and to use while he gets it working. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
robert bristow-johnson wrote:

> in article AcGdnXGrcfb43x7enZ2dnUVZ_v-dnZ2d@web-ster.com, Tim Wescott at > tim@seemywebsite.com wrote on 11/22/2005 11:08: > > >>What are you trying to do again? > > > actually, i needed to review the OP and probably, unless he is doing reverb > emulation of a very large room, i don't think that fast convolution will > help at all. > > >>If you're applying an essentially linear effect like reverb you _either_ >>do a point-by-point multiply the FFT of the sound with the FFT of the >>filter response then do an inverse FFT, or you convolve the time-domain >>signal (i.e. you implement a plain old FIR filter). >> >>Pure convolution in the FFT domain is equivalent to pure point-by-point >>multiplication by a time-varying signal in the time domain. > > > dunno what you mean by "pure", Tim, but i usually think it might mean > "linear convolution" and "linear" means in time, not the "L" of "LTI". > anyway, the FFT method (which is a component of what i would normally call > "fast convolution") does not do linear convolution. it does "circular > convolution." > > >>For reverb I suspect that you could get close with an IIR with a high >>delay; I don't know if "close" would be "ick", "close but still cheezy", >>"wow! good reverb!" or better than analog. > > > a good reverb, whether you're trying to emulate a real room with a real > impulse response, or just trying to create a good reverb of a fictional or > hypothetical room, is *very* difficult. a "good" reverb will have an > impulse response with reflections happening at mutually random times > eventually (toward the "tail" of the impulse response) sounding like > exponentially decaying white noise. a kinda "cushhhhhhhh....." sound. >
I was assuming the OP wanted reverb like guitar effect reverb, with springs and transducers and stuff. I can easily accept that it would also be *very* difficult, however. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
in article Le6dnQMgr5tVXR7enZ2dnUVZ_sWdnZ2d@web-ster.com, Tim Wescott at
tim@seemywebsite.com wrote on 11/22/2005 20:07:

> robert bristow-johnson wrote:
...
>> >> a good reverb, whether you're trying to emulate a real room with a real >> impulse response, or just trying to create a good reverb of a fictional or >> hypothetical room, is *very* difficult. a "good" reverb will have an >> impulse response with reflections happening at mutually random times >> eventually (toward the "tail" of the impulse response) sounding like >> exponentially decaying white noise. a kinda "cushhhhhhhh....." sound. >> > I was assuming the OP wanted reverb like guitar effect reverb, with > springs and transducers and stuff. > > I can easily accept that it would also be *very* difficult, however.
emulating a spring reverb might not be so bad, a plate reverb might be a little harder, but the Schroder kinda reverb is hard. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
Wow!!!

First of all, a massive "Thank You" to everyone who has responded so
quickly to my post. All your information is very gratefully received! I
will be following up the ideas and links posted and reassessing the
direction I need to take...

To answer a few points raised:

1) Yes, the intention was real-time use of this, not offline. As one
respondee rightly pointed out, playing a guitar with a 2 second delay
before hearing any sound would be very difficult. In fact, anything above
a few tens of milliseconds becomes progressively harder. And in the case
of amplifier modelling, an electric guitar sound is so affected by the
amplifier and speaker sound (particularly in rock/heavy metal), that one's
playing style is fundamentally modified by the new sound one hears, so
unless one is a really good guitarist it is not really workable to play
the guitar "pure" then process it offline to get the rock sound.

2) Ultimately I really want to focus on the amplifier/speaker modelling,
not the reverberation, BUT since I already have a free plugin for my music
software which implements a "convolution" reverb with a realtime delay of
8960 samples, I thought that I could best assess my mathematical progress
in implementing such designs by comparing with this "known good one".

This free reverb, for use with the Cubase SX sequencer program and other
compatible hosts, is at http://www.knufinke.de/sir/index_en.html for your
interest.

You can load any length of room impulse response you like, even a 12
second cathedral tail, and the reverb still runs at its 8960 sample delay
and sounds absolutely superb in terms of quality. The way I understand it,
the convolution of the audio and impulse waveforms results in a waveform
which sounds like the instrument really was played in that "real" space in
the first place.

3) Maybe I got hung up on needing to FFT because I remembered that
convolution in the frequency domain is simply multiplication. I didn't
think about doing it in the time domain!

Thanks again

David Parrott
Fleabag wrote:
...
> 2) Ultimately I really want to focus on the amplifier/speaker modelling, > not the reverberation, BUT since I already have a free plugin for my music > software which implements a "convolution" reverb with a realtime delay of > 8960 samples, I thought that I could best assess my mathematical progress > in implementing such designs by comparing with this "known good one".
David, if your ultimate goal is amplifier / speaker modeling, then filtering is the wrong technique (or rather, just part of a more extensive processing chain). You need a non-linear element to generate the harmonics. The amplifier / speaker modeling topic has been beaten to death in several places, for example here: http://www.harmony-central.com/ http://www.musicdsp.org/ You might also want to search comp.dsp archive, we've discussed this topicas well. Regards, Andor
>David, > >if your ultimate goal is amplifier / speaker modeling, then filtering >is the wrong technique (or rather, just part of a more extensive >processing chain). You need a non-linear element to generate the >harmonics. >
Hi Andor Thanks for those links. That's a good point actually, which I'd overlooked. I was thinking the filtering would provide that non-linearity, in that for a given amp setting captured by an impulse response the guitar signal passed through that filter would take on the right characteristics. But of course that is taken at only one signal level (from the level of the transient used for the impulse response), whereas the expected response does need to vary according to the signal level. Ooops, my bad! Do you think that for non-rock bass guitar, though, where I don't want deliberate non-linearity and distorion, just a model of the frequency response of the amplifier and the loudspeaker, that a digital filter (implemented by convolution or any other method) would suffice? I'm guessing that the speaker cabinet is going to approximate to a slightly resonant low pass filter of some sort. Regards David
Fleabag wrote:
...
> Do you think that for non-rock bass guitar, though, where I don't want > deliberate non-linearity and distorion, just a model of the frequency > response of the amplifier and the loudspeaker, that a digital filter > (implemented by convolution or any other method) would suffice?
Sure, if you just want to copy the frequency response, then a filter is fine. You might be disappointed at the result however, because it might not sound like your trusted amp at all. The dynamics are missing. There is actually a unit that implements what one might call "dynamic convolution", aimed at modeling non-linear audio gear. There is a paper available on the website showing how this is implemented: http://www.sintefex.com/ Regards, Andor