summaryrefslogtreecommitdiffstats
path: root/gst
diff options
context:
space:
mode:
authorSebastian Dröge <slomo@circular-chaos.org>2007-11-09 17:27:00 +0000
committerSebastian Dröge <slomo@circular-chaos.org>2007-11-09 17:27:00 +0000
commitee25c44f938942d94d36fe96bcdc1daf0828a28d (patch)
tree91f93617dc73a2704629911d8aa9bbf1f6b07f06 /gst
parent912538f37aa4eb656d3b6099a758c9e3320549ec (diff)
downloadgst-plugins-bad-ee25c44f938942d94d36fe96bcdc1daf0828a28d.tar.gz
gst-plugins-bad-ee25c44f938942d94d36fe96bcdc1daf0828a28d.tar.bz2
gst-plugins-bad-ee25c44f938942d94d36fe96bcdc1daf0828a28d.zip
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.
Diffstat (limited to 'gst')
-rw-r--r--gst/spectrum/gstspectrum.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/gst/spectrum/gstspectrum.c b/gst/spectrum/gstspectrum.c
index f2f654a6..3b2f19fc 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; \