diff options
author | Sebastian Dröge <slomo@circular-chaos.org> | 2007-11-06 12:23:35 +0000 |
---|---|---|
committer | Sebastian Dröge <slomo@circular-chaos.org> | 2007-11-06 12:23:35 +0000 |
commit | 1407259dbc44b0cf23c9e72770c990e5f8cac680 (patch) | |
tree | b9dd5dd88cf2b3f51dc6353b9b713eb60ebc7605 /gst | |
parent | 209d6105d73bcdb01f20432035fc58436caa26b7 (diff) | |
download | gst-plugins-bad-1407259dbc44b0cf23c9e72770c990e5f8cac680.tar.gz gst-plugins-bad-1407259dbc44b0cf23c9e72770c990e5f8cac680.tar.bz2 gst-plugins-bad-1407259dbc44b0cf23c9e72770c990e5f8cac680.zip |
gst/spectrum/demo-audiotest.c: Use autoaudiosink instead of alsasink and use a sine wave.
Original commit message from CVS:
* gst/spectrum/demo-audiotest.c: (main):
Use autoaudiosink instead of alsasink and use a sine wave.
* gst/spectrum/gstspectrum.c:
Fix the magnitude calculation.
Diffstat (limited to 'gst')
-rw-r--r-- | gst/spectrum/demo-audiotest.c | 4 | ||||
-rw-r--r-- | gst/spectrum/gstspectrum.c | 18 |
2 files changed, 13 insertions, 9 deletions
diff --git a/gst/spectrum/demo-audiotest.c b/gst/spectrum/demo-audiotest.c index 8cc8201f..05c9f886 100644 --- a/gst/spectrum/demo-audiotest.c +++ b/gst/spectrum/demo-audiotest.c @@ -28,7 +28,7 @@ #include <gst/gst.h> #include <gtk/gtk.h> -#define DEFAULT_AUDIOSINK "alsasink" +#define DEFAULT_AUDIOSINK "autoaudiosink" static GtkWidget *drawingarea = NULL; static guint spect_height = 64; @@ -126,7 +126,7 @@ main (int argc, char *argv[]) bin = gst_pipeline_new ("bin"); src = gst_element_factory_make ("audiotestsrc", "src"); - g_object_set (G_OBJECT (src), "wave", 1, NULL); + g_object_set (G_OBJECT (src), "wave", 0, NULL); spectrum = gst_element_factory_make ("spectrum", "spectrum"); g_object_set (G_OBJECT (spectrum), "bands", spect_bands, "threshold", -80, diff --git a/gst/spectrum/gstspectrum.c b/gst/spectrum/gstspectrum.c index d9899b49..f2f654a6 100644 --- a/gst/spectrum/gstspectrum.c +++ b/gst/spectrum/gstspectrum.c @@ -517,10 +517,12 @@ process_s##width (GstSpectrum *spectrum, const gint##width *samples) \ \ /* Calculate magnitude in db */ \ for (i = 0; i < spectrum->bands; i++) { \ - gdouble val = (gdouble) freqdata[i].r * (gdouble) freqdata[i].r \ - + (gdouble) freqdata[i].i * (gdouble) freqdata[i].i; \ - val = sqrt (val); \ - val = 20.0 * log10 (val / max); \ + gdouble val; \ + 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) \ val -= spectrum->threshold; \ else \ @@ -583,9 +585,11 @@ process_f##width (GstSpectrum *spectrum, const g##type *samples) \ \ /* Calculate magnitude in db */ \ for (i = 0; i < spectrum->bands; i++) { \ - gdouble val = freqdata[i].r * freqdata[i].r + freqdata[i].i * freqdata[i].i; \ - val = sqrt (val); \ - val = 20.0 * log10 (val / nfft); \ + gdouble val; \ + val = freqdata[i].r * freqdata[i].r; \ + val += freqdata[i].i * freqdata[i].i; \ + val /= nfft; \ + val = 10.0 * log10 (val); \ if (val > spectrum->threshold) \ val -= spectrum->threshold; \ else \ |