[Csnd] pvsfilter behaviour
Date | 2013-11-08 00:42 |
From | peiman khosravi |
Subject | [Csnd] pvsfilter behaviour |
One of my UDOs is misbehaving in csound 6 and I'v narrowed the problem down to this. I can't quite figure out what is causing it but for some reason 'pvsfilter' is returning 204770 samples out of range. Have I done something wrong? All the bin amplitudes in 'fsig2' are set to zero, so the multiplication of pvsfilter should return the original values of fsig1, right?
Many Thanks
Peiman To avoid a nasty accident MUTE your sound before running the csd. I've commented out the 'out' opcode to be safe.
<CsoundSynthesizer>
<CsOptions> -odac -d ;-o test.aif -d -A -3 </CsOptions> ; ==============================================
<CsInstruments> sr = 96000
ksmps = 10 nchnls = 1
0dbfs = 1 instr 1
ifftsize = 2048 ihop = 256 iwindow = 4096 iwindtype = 1 iNumBins = ifftsize/2 + 1
ain1 noise .02, 0 fsig1 pvsanal ain1, ifftsize, ihop, iwindow, iwindtype
fsig2 pvsinit ifftsize, ihop, iwindow, iwindtype ;;;;; itable ftgen 0, 0, iNumBins, 2, 1 kflag1 pvsftw fsig2, itable if (kflag1 == 1) then ; only proc when frame is ready
kndex = 0 loop: tablew 1, kndex, itable kndex = kndex+1
if (kndex<iNumBins) kgoto loop pvsftr fsig2, itable endif
fsigout pvsfilter fsig1, fsig2, 1 aout pvsynth fsigout ;out aout
endin </CsInstruments> ; ============================================== <CsScore>
i1 0 10 </CsScore> </CsoundSynthesizer> |
Date | 2013-11-08 00:47 |
From | peiman khosravi |
Subject | [Csnd] Re: pvsfilter behaviour |
Sorry, that should read: "All the bin amplitudes in 'fsig2' are set to one"
On 8 November 2013 00:42, peiman khosravi <peimankhosravi@gmail.com> wrote:
|
Date | 2013-11-08 11:19 |
From | Richard Dobson |
Subject | Re: [Csnd] Re: pvsfilter behaviour |
I don't know the internals of pvsfilter, but seting each bin amplitude to 1, where 0dBFS=1, is rather a lot. The total signal level of a frame, represented (at cost of some simplification here) by the sum of all bin amplitudes, must sum to the level of the resynthesised signal. In effect, each frame is normalised. We see how this works just analysing a sinusoid with a window - even if the input signal is at 0dB, leakage spreads that energy around all bins, and the measured level at the peak will be less than 0dB, sometimes significantly so. We could say as a simple rule of thumb that to resynthesize without overflow, all bin amplitudes must sum to 1.0 or below. Put another way: if I write a value not of 1 but (say) 1.0/ifftsize to each bin in the table loop, the output is comparable to the input level. Which leads me to assume that pvsfilter is not simply using fsig2 as a bin scale factor (which is what pvsmaska does, using a table). Richard Dobson On 08/11/2013 00:47, peiman khosravi wrote: > Sorry, that should read: "All the bin amplitudes in 'fsig2' are set to > *one*" > > |
Date | 2013-11-08 11:26 |
From | peiman khosravi |
Subject | Re: [Csnd] Re: pvsfilter behaviour |
Thanks Richard,
Your theory correlates with my experience. Though It's strange that this wasn't happening in csound 5 as far as I can tell - although I haven't done an A/B comparison. I can't use pvsmaska for this task because the table needs to be dynamically altered on a window-by-window basis. The table values are defined based on an amplitude threshold analysis of the input fsig. So I will do the multiplication inside the loop block and report back.
Thanks for the explanation.
Best, Peiman
On 8 November 2013 11:19, Richard Dobson <richarddobson@blueyonder.co.uk> wrote: I don't know the internals of pvsfilter, but seting each bin amplitude to 1, where 0dBFS=1, is rather a lot. The total signal level of a frame, represented (at cost of some simplification here) by the sum of all bin amplitudes, must sum to the level of the resynthesised signal. In effect, each frame is normalised. We see how this works just analysing a sinusoid with a window - even if the input signal is at 0dB, leakage spreads that energy around all bins, and the measured level at the peak will be less than 0dB, sometimes significantly so. We could say as a simple rule of thumb that to resynthesize without overflow, all bin amplitudes must sum to 1.0 or below. |
Date | 2013-11-08 11:29 |
From | peiman khosravi |
Subject | Re: [Csnd] Re: pvsfilter behaviour |
The reason I was using pvsfilter, rather than doing it inside the loop block was because I'm subjecting the fsig to smoothing (with pvsmooth) before the multiplication for a 'legato' effect. So I will need to write two loop blocks now, which is not very efficient. But let's see how it performs.
Also, maybe this should go in the manual page of pvsfilter?
On 8 November 2013 11:26, peiman khosravi <peimankhosravi@gmail.com> wrote:
|