spectrum only aggregate magnitude/phase if user asks for it
authorStefan Kost <ensonic@users.sf.net>
Wed, 11 Aug 2010 12:48:18 +0000 (15:48 +0300)
committerStefan Kost <ensonic@users.sf.net>
Mon, 6 Sep 2010 06:53:00 +0000 (09:53 +0300)
gst/spectrum/gstspectrum.c

index 6e91af8ac80693eb1795991914fceb9b3dc5025c..9e82829aefbc5411795c239e89e9bb054e01a4a7 100644 (file)
@@ -623,21 +623,25 @@ gst_spectrum_transform_ip (GstBaseTransform * trans, GstBuffer * buffer)
       gst_fft_f32_fft (fft_ctx, input_tmp, freqdata);
       spectrum->num_fft++;
 
-      /* Calculate magnitude in db */
-      for (i = 0; i < bands; i++) {
-        gdouble val = 0.0;
-        val = freqdata[i].r * freqdata[i].r;
-        val += freqdata[i].i * freqdata[i].i;
-        val /= nfft * nfft;
-        val = 10.0 * log10 (val);
-        if (val < threshold)
-          val = threshold;
-        spect_magnitude[i] += val;
+      if (spectrum->message_magnitude) {
+        gdouble val;
+        /* Calculate magnitude in db */
+        for (i = 0; i < bands; i++) {
+          val = freqdata[i].r * freqdata[i].r;
+          val += freqdata[i].i * freqdata[i].i;
+          val /= nfft * nfft;
+          val = 10.0 * log10 (val);
+          if (val < threshold)
+            val = threshold;
+          spect_magnitude[i] += val;
+        }
       }
 
-      /* Calculate phase */
-      for (i = 0; i < bands; i++)
-        spect_phase[i] += atan2 (freqdata[i].i, freqdata[i].r);
+      if (spectrum->message_phase) {
+        /* Calculate phase */
+        for (i = 0; i < bands; i++)
+          spect_phase[i] += atan2 (freqdata[i].i, freqdata[i].r);
+      }
     }
 
     /* Do we have the FFTs for one interval? */