Csound Csound-dev Csound-tekno Search About

[Cs-dev] ftconv bug report and fix

Date2013-08-20 20:56
FromTito Latini
Subject[Cs-dev] ftconv bug report and fix
AttachmentsNone  

Date2013-08-20 21:10
FromVictor Lazzarini
SubjectRe: [Cs-dev] ftconv bug report and fix
Thanks. Fixed in GIT.
On 20 Aug 2013, at 20:56, Tito Latini wrote:

> Hi,
> 
> I have discovered a subtle bug in ftconv during a comparison with a
> convolver that I'm writing from scratch in lisp.
> 
> The last two bins of the output buffer in `multiply_fft_buffers'
> (ftconv.c:52) are always incremented (never zeroed) because
> 
>    memset(outBuf, 0, sizeof(MYFLT)*(partSize - 2));
>                                    ^^^^^^^^^^^^^^
> 
> but at the end of the function, after the while loop:
> 
>    ...
>    while (outBufPtr < outBufEndPm2) {
>      ...
>    }
>    outBufPtr[0] += re;
>    outBufPtr[1] += im;
>    ...
> 
> The fix is trivial, the correct size for memset is
> 
>    memset(outBuf, 0, sizeof(MYFLT)*partSize);
> 
> Here is an example to "hear" the bug:
> 
> 
> 
> -odac
> 
> 
> 
> sr     = 48000
> ksmps  = 64
> nchnls = 1
> 0dbfs  = 1
> 
> instr 1
> 
> iplen = 32
> idel = iplen/sr
> 
> ;; Input
> ain rand 1
> 
> ;; Direct convolution
> adirect dconv ain, 64, 1
> adirect delay adirect, idel
> 
> ;; Partitioned convolution
> apart ftconv ain, 1, iplen
> 
> ;; Silence after the fix
> out (adirect - apart)*40
> 
> endin
> 
> 
> 
> f1 0 64 21 6
> i1 0 $INF
> e
> 
> 
> 
> 
> tito
> 
> ------------------------------------------------------------------------------
> Introducing Performance Central, a new site from SourceForge and 
> AppDynamics. Performance Central is your source for news, insights, 
> analysis and resources for efficient Application Performance Management. 
> Visit us today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel

Dr Victor Lazzarini
Senior Lecturer
Dept. of Music
NUI Maynooth Ireland
tel.: +353 1 708 3545
Victor dot Lazzarini AT nuim dot ie




------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and 
AppDynamics. Performance Central is your source for news, insights, 
analysis and resources for efficient Application Performance Management. 
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net