From d4085d9387e96b2c26d423378b065f4e9ca67d02 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 9 Nov 2007 17:27:00 +0000 Subject: [PATCH] gst/spectrum/gstspectrum.c: Now do the scaling right for real. Also initialize a previously uninitialized variable. Original commit message from CVS: * gst/spectrum/gstspectrum.c: Now do the scaling right for real. Also initialize a previously uninitialized variable. --- gst/spectrum/gstspectrum.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/gst/spectrum/gstspectrum.c b/gst/spectrum/gstspectrum.c index f2f654a..3b2f19f 100644 --- a/gst/spectrum/gstspectrum.c +++ b/gst/spectrum/gstspectrum.c @@ -517,10 +517,9 @@ process_s##width (GstSpectrum *spectrum, const gint##width *samples) \ \ /* Calculate magnitude in db */ \ for (i = 0; i < spectrum->bands; i++) { \ - gdouble val; \ + gdouble val = 0.0; \ val = (gdouble) freqdata[i].r * (gdouble) freqdata[i].r; \ val += (gdouble) freqdata[i].i * (gdouble) freqdata[i].i; \ - val *= nfft; \ val /= max*max; \ val = 10.0 * log10 (val); \ if (val > spectrum->threshold) \ @@ -585,10 +584,10 @@ process_f##width (GstSpectrum *spectrum, const g##type *samples) \ \ /* Calculate magnitude in db */ \ for (i = 0; i < spectrum->bands; i++) { \ - gdouble val; \ + gdouble val = 0.0; \ val = freqdata[i].r * freqdata[i].r; \ val += freqdata[i].i * freqdata[i].i; \ - val /= nfft; \ + val /= nfft*nfft; \ val = 10.0 * log10 (val); \ if (val > spectrum->threshold) \ val -= spectrum->threshold; \ -- 2.7.4