From: Paul Brossier Date: Wed, 6 Mar 2013 20:30:55 +0000 (-0500) Subject: src/mathutils.c: freqtobin and bintofreq to not produce negative values X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c965b3370fa327e0f4bebba6f7d2304f55411691;p=aubio.git src/mathutils.c: freqtobin and bintofreq to not produce negative values --- diff --git a/src/mathutils.c b/src/mathutils.c index 74063a27..b0a958b9 100644 --- a/src/mathutils.c +++ b/src/mathutils.c @@ -421,7 +421,7 @@ smpl_t aubio_bintofreq (smpl_t bin, smpl_t samplerate, smpl_t fftsize) { smpl_t freq = samplerate / fftsize; - return freq * bin; + return freq * MAX(bin, 0); } smpl_t @@ -435,7 +435,7 @@ smpl_t aubio_freqtobin (smpl_t freq, smpl_t samplerate, smpl_t fftsize) { smpl_t bin = fftsize / samplerate; - return freq * bin; + return MAX(freq, 0) * bin; } smpl_t