Deconvolution question
Mar 18, 2008 at 3:56am
Deconvolution questionDear all, I’m slowly trying to work out how to convert a room response (sweep tone recorded in a room) into an impulse response. The consensus seems to be that one convolves the reversed original sweep tone with the recorded sweep tone to produce the IR, but one source has told me this type of convolution requires a DFT. The operation is intended to move all the components of the recorded sweep back to a single point in time, like a Dirac function. Is Max/MSP capable of such an operation? fft~ seems more like an STFT… Any wisdom on this matter would be much appreciated! 

Jan 9, 2009 at 2:28pm
Hi demers, I just came upon your post (I know it’s a long time ago) and I was thinking of doing exactly the same thing. So I was wondering if you got it running in the end? I have generated the sweeps and their inverse in matlab and I’ve made a quick patch for playback and recording of the sweeps for one sourcetwo receivers (for stereo RIRs) and now I reached the tricky deconvolution point which becomes convolution in our case.. This operation can be done with patcher objects but what about the zero padding in realtime?? You think it is doable? I’m really dying to achieve that as it would be a native convolution solution for max to play with and also a deconvolution one for various IR measurements. 

Jan 9, 2009 at 4:00pm
> I would be much easier if there was a non realtime fft object operating on 

Jan 9, 2009 at 4:40pm
Quote: deadflagblue@gmail.com wrote on Fri, 09 January 2009 07:28 max v2; Patcher C*~ (complex multiply): max v2; Patcher convsub~ max v2; Patcher conv~ max v2; Suitable for convolutions up to 4096 (2048 impulse response with zero padding). For larger RI sizes, you need to use pfft~ 

Jan 9, 2009 at 8:29pm
Thanx for the quick replies guys! I haven’t got jitter but I’m thinking of upgrading to max 5+jitter soon (with a student license;)), jit.fft would be probably ideal for non realtime operations. Wow Bernier, not one but four convolution patches! I’ll try them as soon as I got home. What are the advantages of using pfft~ over fft~ that allows longer convolutions?? Thanks a ton again 

Jan 9, 2009 at 11:19pm
Quote: deadflagblue@gmail.com wrote on Fri, 09 January 2009 13:29 fft~ has a 4k limit. pfft~ a 64k limit, that is 0.74s at 44.1 for a non circular, zeropadded convolution. 

Jan 10, 2009 at 9:07am
Dear all I am very, very interested in this thread, can you share your thanks pa 

Jan 12, 2009 at 1:14am
Bernier thanks for the patch it’s working fine, I tested it with a perfect impulse and I got my impulse response back:). Tremblap, the deconvolution method depends on the way you are measuring your responses depending on the excitation signal. For the sinesweep technique it becomes a convolution of the recorded signal with the inverse of the test sweepsignal. You can have these signals pregenerated and turn you laptop to an IR measurement box using maxmsp. The problem is that for large spaces you’ll probably have an IR longer than 0.7sec which is the limit for the above patch using pfft~ subpatchers. So it still has to be performed offline (it’s pretty easy with a numerical software like matlab or octave). Unless you use partitioned convolution which breaks and convolves the impulse response in parts. But I have no idea how it’s done at the moment (the info is pretty scarce) and I don’t know if it can be done with max objects. 

Jan 12, 2009 at 9:36am


Jan 14, 2009 at 10:47pm
Quote: deadflagblue@gmail.com wrote on Sun, 11 January 2009 18:14 The pfft~ version is just a bit different, i’ll copy it at the end of this post.I use the fft~ version for crosstalk cancelation or HRTF processing where IR are short. The pfft~ version can do some nice convoverbs but latency is terrible of course. Note that 64k is not enough for sinesweep deconvolution, And convolution is only a step in obtaining inverse IR. Most authors use AURORA plugins for CoolEdit (once a free product, now Adobe Audition). Logic and other studio software now have i.r. processing as an integrated part (see Apple’s Impulse Response Utility). I’ve thinked about a Java extralong FFT (we are not concerned by efficiency here). I’m playing with Octave, an opensource Matlablike, and i think it’s a workable choice. Jeremy Bernstein’s shell, and filewatch objects can help integration with Max, Maybe there’s is a Max/Matlab bridge somewhere. I have tons of links on the subject, let me find them… 

Jan 14, 2009 at 10:53pm
As promised: Patcher pconvsub~ max v2; max v2; max v2; 

Jan 15, 2009 at 5:54pm
I think your pconv~ got pasted twice. 

Jan 16, 2009 at 4:16am
How stupid! Well, it was just a “pconv~ Buffer 65536 32768″ between adc~ and dac~ as a way to illustrate how to invoke the patcher. #3 should always be half of #2. 

Jan 16, 2009 at 12:50pm
————————————————— True, 64K are not enough. There are three convolution externals that I know of that do not have this limitation. One is firbank~ by CNMAT’s suite having an optimised overlapsave conv., the other is tconvolution~ with partitioned convolution and the last is karateconv~ (!!) again with partitioned convolution, I checked quickly the last one with a 2sec IR and I think it sounded quite good. I’ll propose instead of the nonfree audition (shame the excellent aurora plugins are only on audition’s format) either the free ACMus IR acquisition software developed at Sao Paolo University or if you have a linux or OSX machine the excellent Aliki by Fons Andriaensen, another one of the Farina’s team, and one of the Ambisonics experts. Both are doing sinesweep deconvolution and ACMus has also MLS deconvolution. ——————————– There is a pretty good octave/pd bridge and there is a matlab/max bridge by CNMAT but last time I had a look it was only for MACs and I don’t have one (Max/octave would be a killer combo too..) But maybe that’s the best way to go for a max/pd IR acquisition patch,do the synchronous playback/recording in a patch and buffer the recording into a matlab/octave variable and then run the deconvolution script, all automated into the patch. ——————————– Heh glad to hear that, I was doing exactly the same in the university with inverse filtering and crosstalk cancelation but instead of HRTFS I was measuring the actual room response (with the listener inside) with inear microphones including some controlled strong reflections. The most interesting outcome was that while if you invert only the HRTFs, strong reflections destroy totally the crosstalk cancelation performance, if you invert the actual room impulse response up to a length of the significant reflections, the performance was getting close to optimal. So measure you binaural RIRs in front of your desktop get the invert filters and you’ve got an excellent virtual surround system! Though in this case the filters you need hsould be much longer (not more than 32768 though.) and a good SNR in your RIRs. Pheww! that was a long post.. 

Jan 16, 2009 at 1:30pm
> Pheww! that was a long post.. but an amazing one! Aliki is my new friend, will report on this thanks again pa 

Jan 19, 2009 at 3:50am
Thanks a lot deadflagblue. It seems like you’ve filled my roadmap for two monthes (lol). Since my first goal is learning, getting a working system coming second, this will be: 1) Implement Farina’s method for exponential sine sweep deconvolution Some comments on step 1: My starting points are Agelo Farina’s papers 183AES24, 154AES110, AES121 Workshop. I got them being an AES member but you may find them on the internet. Basically, Angelo exposes the maths for exponential sinesweeps and shows how it separates inharmonic content when the driver/speaker behaves non linearly. The system IR can be recovered by convolving the recorded response with the test signal’s inverse filter, being simply itself equalized and timereversed. To cut on time, i use the MATLAB program generate_sinesweeps.m (or the result sinesweeps.wav) given by the RealSimple Project Home Page at the excellent CCRMA. Of course, the sine sweep can be done within Max. http://ccrma.stanford.edu/realsimple/imp_meas/Sine_Sweep_Measurement_Procedure.html Max plays the file and poke~ the response into a buffer. The buffer is written to a file, processed by Octave/Matlab which writes the result into a second file binded to a Max waveform~. http://www2.pescadoo.net/wikimages/max/iMac_ess.png Above is the sine sweep response. Under, the computed IR. The system in use is my iMac speakers and internal mic, obviously not a setup suitable for step 4 but enough for a test. The picture is only of interest when compared to http://www2.pescadoo.net/wikimages/max/iMac_ess_clipped.png where i accidentally overloaded the speakers, producing the harmonics peaks. That’s where exponential sweeps shine: nonlinearities are rejected into negative times. We can just cut them if interested in firstodrer only, or use the Volterra series expansion as descibed in 154AES110 (i won’t do that). Here are the steps for deconvolving:  Read sinesweep and response (same length).  Equalization: As the exponential sine sweep has a 6db/oct emphasis, a 6db/oct roloff filter (simple differentiator) is needed for equalization. In Matlab/Octave, this is filter ([1,1,0],[0,0], sinesweep). In Max, this would be a onepole~ or a biquad~ with [1, 1, 0, 0, 0].  Timereversal: flipud(sinesweep) in Matlab. In max, this would be mxj buf.Op (reverse).  Zeropadding: as my test signal contains TWO sweeps, simply zero the second half of both signals [Matlab: sinesweep(L/2+1:L) = 0; response(L/2+1:L) = 0;] Should the buffers contain only one sweep, they’d have to be extended to twice their size. This ensures we do a linear convolution, not a periodic one.  Convolution: ifft(fft(sinesweep).*fft(response)) in Octave/Matlab. The length of the signal (8 seconds here) would imply a Max external like CNMAT’s firbank~ or zippernoise’s tconvolution~. That’s it. I don’t publish code for now here because it needs to be further validated (it’s easy to get outputs, it’s less easy to get correct outputs) and the Max code is pretty uninteresting, made of buffer~, poke~, waveform~ … The tricky part is the Matlab one (although very short). Some refinements in equalization may be necessary to take in account the bandlimited characteristic of the system. But, who knows, a MaxMSP sine sweep deconvo toolbox may be on the way? Now heading to step2………. 

Jan 19, 2009 at 2:21pm
why build something which already has been built. why not leave deconvolution to the nineties where it belongs and invent a matter transformer instead. 110 

Jan 19, 2009 at 5:35pm
I didn’t know getting impulse responses was so out of fashion!!! But you can transform matter through deconvolution, no? 

Feb 7, 2009 at 10:32pm
Hey folks, I must say I was shocked to see all these responses when I checked back – so long after my original post! I’ll have to trudge through all this now, so I’ll reserve my thoughts for later. For now, I just wanted to confirm that I did in fact learn Octave and wrote a routine there for producing IRs. Still tweaking it but I think I have more of a handle on it now. j.y.bernier, am I correct in assuming that your patches are in fact designed as selfenclosed abstractions? I’ve been trying to figure out how to produce those (SDK?), so if you have any tips I will certainly welcome them. Thank you all for not letting this topic fall into the nether regions… 
You must be logged in to reply to this topic.