• ### Deconvolution for RT spectral "stamping" of violin

Yop,

this thesis (http://www.tesisenred.net/bitstream/handle/10803/7264/TAPC.pdf?sequence=1) explains a method for reconstructing a body impulse response (BIR) characterizing the passage from a piezo pickup on a violin to the sound recorded from a mic in an anechoic chamber of the same violin. A slow and long glissando is recorded in parallel from pickup and microphone, and the BIR is calculated. The violin pickup sound can then been convoluted to render a more realistic sound, simulating the miking. Hear samples here : http://www.dtic.upf.edu/~aperez/JASAradiation/

I already started trying to make it with Pd, but I'm not sure it will be possible (besides maximum buffer length discussed in topics like http://puredata.hurleur.com/sujet-4189-swept-sine-deconvolution ). Once the real and complex parts from [rfft~] are stored in buffers, I guess it will be possible to make the weighted sum and other calculations. Should be easier to do that in C or something! Another concern is that I'm not sure to fully understand what does mean (page 96(114)) "An important issue for computing the average is that, since we are working in a bin-by-bin estimation, we must take into account the effects of the window applied to the signals. This fact led us to weight each bin estimation by the energy contribution of the corresponding bin in the input signal spectrum, so that frames for which the energy is low for the bin under estimation (more likely to be affected by window sidelobes) give less influence to the average".
I think that implies to define a relative energy seen from the frame point of view, am I right ? If it's not the case, I'd say that (if a and b are the real and imaginary parts of [rfft~]) magnitude would be the square root of energy (sqrt(a²+b²)), but this energy is not seen as a relative value but absolute.
What do you think of it all?

Of course this topic is not only related to violin, as this procedure is adapted from other works with guitars. See This thesis (http://www.google.be/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0CC0QFjAA&url=http%3A%2F%2Fmtg.upf.edu%2Fsystem%2Ffiles%2Fpublications%2FBuccci-Andres-Master-thesis-2011_0.pdf&ei=bNBZUvvCBPON0wWyi4D4DA&usg=AFQjCNHwZ0JDaVCOcIOZZvzINL3rBMw5RA&bvm=bv.53899372,d.d2k). I stumbled upon this material following shawnb links in this topic (http://puredata.hurleur.com/sujet-9637-guitar-effects-designing-hardware), thank you again. Look at the videos on http://www.futureguitarnow.com/forum/index.php?topic=1945.0 . These guys use some softs to get impulse responses playing riffs along their beloved guitar hero and convolve their guitar, even with an arduino ! Inspiring. As is this : http://www.weinreichlabs.com/

Sorry for the long post,
Thanx,

Nau

• Posts 53 | Views 25665
• Yop,

I gave a break to the zeropadding prospectives, and tried the least square method for "system identification" (useful keywords).

I found the page http://eeweb.poly.edu/iselesni/lecture_notes/least_squares/ and played with the Matlab scripts under Octave. Made two 1000samples-long IRs, one using 30000 samples of the glissando (Toeplitz1), the other using the first 100000 samples of tune2 (Toeplitz_jungle). They "play" rather less "precise" or "open" than the IRs obtained with the pd patch discussed earlier, and have heavier tails (I didn't bother to fade them out), but they are still doing a substantial part of the job.

Longer data vectors and IRs will soon lead to an memory overflow, so the job has to be done with shorter data, that's the reason why I used tune2 to make a test, wondering if it would add "liveliness" through liver input than the classical glissando for such a short data length. I personally do prefer IR_Toeplitz_jungle to IR_Toeplitz1.

The data waves are opened into Pd, than saved to ascii files easily handled by Octave. Once the IR is calculated (in single precision) it is saved into an ascii file in order to be read by Pd and finally converted to wav. This workflow should be modified in order to preserve data precision, I guess. I imagine that Octave can handle wav files with the corresponding package.

To be continued...

Nau

http://www.pdpatchrepo.info/hurleur/least_squares_nau.zip

• Interesting method, it seems that all sorts of dsp matters can be solved with least squares. I never understood how it is done, and still don't understand after reading the article. Anyway if Octave can do it, that's nice. And it seems to sound OK. One thing I noticed when looking at the IR plots, is that the energy is concentrated in the left side, but they are not as minimum-phase as could be. You could still try to rearrange phases in these IR's to minimize the sudden cut at the right side.

By the way I tried to work out an upsample-and-zeropadding test routine, and found that the plots within the upsampled patch do not graph the actual array content. This is very confusing as it is hard to check if things happen as intended. Looking at the array list however, it gives the correct result. See attached patch (or skip if you give up on zeropadding).

There's another thing to reckon with when doing fast convolution with Pd's fft (unless it is magnitude-only): phases are not processed as if time zero is centered in the fft frame, with phases ranging from -pi to pi, but rather it assumes phase 0 to 2pi. When doing complex multiplications (or divisions, for inverse filtering), this is not a useful range. There are tricks to get it right, like rotating time domain samples within the frame, or alternating phases in frequency domain before processing.

Katja

• Thanks Katjav. I'll check this out.

• Yop,

@katjav said:

By the way I tried to work out an upsample-and-zeropadding test routine, and found that the plots within the upsampled patch do not graph the actual array content. This is very confusing as it is hard to check if things happen as intended. Looking at the array list however, it gives the correct result. See attached patch (or skip if you give up on zeropadding).
Katja

Here's a small patch that allows comparison between various frame sizes and with or without zeropadding. It loosely follows the Bitweenie article cited above.

Any suggestion ? The "normalizing" factors used in the fft magplots could maybe be refined, for example...

Nau

• That is a great demo indeed. The comparison clearly illustrates that zero padding does not give better spectral resolution, while increasing input frame size does. With zero padding you get better interpolation in the spectrum, which is interesting if you want to calculate frequencies of harmonic peaks. But the most common purpose for zero padding is to get reduced phase angles so you can manipulate phases in frequency domain without circular convolution effect.

It seems to me that factor 2 zero padding (N samples + N zeroes) would always be sufficient to avoid circular convolution. Multiplication of two complex numbers each with a phase within range -pi/2 till pi/2 will avoid wrapping, which is exactly what you want. Would be nice to have a demo of that too. Unfortunately Pd's fft objects give phases in the range 0 till 2pi so this would require more reorganisation of the input samples (swapping the input frame halves).

There is by the way a frequency domain equivalent of zero padding a signal: upsample a signal by zero padding it's spectrum. In Pd this would only work if the spectrum is written to arrays in one subpatch, and read and ifft'ed in another subpatch with larger block size for a larger zero padded fft.

When using hann windowing for fft and ifft you need 4 times overlap. This is missing in your patch, Nau. Therefore the reconstruction of subpatches fft-analysis1024 and fft-analysis8192 sound weird.

Katja

• Thanks Katjav !

I made the changes in the two non-zeropadded subpatches and it works fine. But I can't explain why this doesn't work/isn't needed in zeropadded subpatches (sounds weird and more than 3/2 times greater in fft values than without overlapping).

In my impulse response calculation patch I got good results without zeropadding and without overlapping, but with Hann windowing. I made an overlapped version and discarded it, because it was difficult to decide which one was the best from my very subjective point of view, even though they were prettty different. I do prefer without overlapping, it seems to have "more body" to me. So now I know now the overlapped one is theorically the best one and I will try to educate my ears.

Here are two IRs, the first one Hann windowed but not overlapped (neither zeropadded), the second one Hann windowed, 4 times overlapped, not zeropadded.
convol5.pd allows to make a listening test, providing you have the previously uploaded material.

I will make a zeropadded version of my IR calculation patch and share results.

My understanding of fft processing seems cursed to be eternally shallow...

Nau

http://www.pdpatchrepo.info/hurleur/IR_wood1.wav

• Thanks Katjav !

I made the changes in the two non-zeropadded subpatches and it works fine. But I can't explain why this doesn't work/isn't needed in zeropadded subpatches (sounds weird and more than 3/2 times greater in fft values than without overlapping).

In my impulse response calculation patch I got good results without zeropadding and without overlapping, but with Hann windowing. I made an overlapped version and discarded it, because it was difficult to decide which one was the best from my very subjective point of view, even though they were prettty different. I do prefer without overlapping, it seems to have "more body" to me. So now I know now the overlapped one is theorically the best one and I will try to educate my ears.

Here are two IRs, the first one Hann windowed but not overlapped (neither zeropadded), the second one Hann windowed, 4 times overlapped, not zeropadded.
convol5.pd allows to make a listening test, providing you have the previously uploaded material.

I will make a zeropadded version of my IR calculation patch and share results.

My understanding of fft processing seems cursed to be eternally shallow...

Nau

http://www.pdpatchrepo.info/hurleur/IR_wood1.wav

• Thanks Katjav !

I made the changes in the two non-zeropadded subpatches and it works fine. But I can't explain why this doesn't work/isn't needed in zeropadded subpatches (sounds weird and more than 3/2 times greater in fft values than without overlapping).

In my impulse response calculation patch I got good results without zeropadding and without overlapping, but with Hann windowing. I made an overlapped version and discarded it, because it was difficult to decide which one was the best from my very subjective point of view, even though they were prettty different. I do prefer without overlapping, it seems to have "more body" to me. So now I know now the overlapped one is theorically the best one and I will try to educate my ears.

Here are two IRs, the first one Hann windowed but not overlapped (neither zeropadded), the second one Hann windowed, 4 times overlapped, not zeropadded.
convol5.pd allows to make a listening test, providing you have the previously uploaded material.

I will make a zeropadded version of my IR calculation patch and share results.

My understanding of fft processing seems cursed to be eternally shallow...

Nau

http://www.pdpatchrepo.info/hurleur/IR_wood1.wav

• Hi there,

here is a naive spectrum-tweaking patch.

Open a magnitude spectrum saved in a txt file (here it is an asymmetric one, 32768 samples, coming from my previous "system identification" aka microphone simulation patch).

Open a test tune as a wav file. (left:piezo, right:dpa4099)

Then use Maelstorm's rslider to create a parabola (of course other windows could be implemented, this is the first one I wanted to try) mask in order to make a selection region. (take a look at the four modes of hrslider). Only the left part of the spectrum is used for selection, though the modifications occur in a mirror fashion between left and right parts of the mag spectrum.

Then, using the knob, amplify or attenuate the selected region (region is multiplied by a factor (1+knob*parabola)).

Then bang the minimum phase impulse response calculator.

Finally, bang the listening test and browse between piezo, simulated microphone and dpa 4099 microphone sounds. Simulation is done by convolving the piezo track with the impulse response computed by the patch. Later on it is always possible to edit the spectrum and bang the IR calculation on-the-fly to hear directly the spectral changes (simu selected on the hadio), or, from time to time, restore the original spectrum reloading the spectrum.txt file.

This patch is maybe a bit naive as is, but may also suit someone's needs. It's still a bit buggy with artefacts at the boundaries of selection regions, and could gain resolution using the same space in order to visualize only the left part of the spectrum (left both here because I wanted to be more self-explanatory).

Nau

Posts 53 | Views 25665
Internal error.

Oops! Looks like something went wrong!