mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
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.
This commit is contained in:
parent
209d6105d7
commit
1407259dbc
4 changed files with 22 additions and 10 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2007-11-06 Sebastian Dröge <slomo@circular-chaos.org>
|
||||||
|
|
||||||
|
* gst/spectrum/demo-audiotest.c: (main):
|
||||||
|
Use autoaudiosink instead of alsasink and use a sine wave.
|
||||||
|
|
||||||
|
* gst/spectrum/gstspectrum.c:
|
||||||
|
Fix the magnitude calculation.
|
||||||
|
|
||||||
2007-11-04 Tim-Philipp Müller <tim at centricular dot net>
|
2007-11-04 Tim-Philipp Müller <tim at centricular dot net>
|
||||||
|
|
||||||
Patch by: Ole André Vadla Ravnås <ole.andre.ravnas@tandberg.com>
|
Patch by: Ole André Vadla Ravnås <ole.andre.ravnas@tandberg.com>
|
||||||
|
|
2
common
2
common
|
@ -1 +1 @@
|
||||||
Subproject commit 34d7d649b972ea4915611a6ed88f01613bf32777
|
Subproject commit 423e2ea96b5f79281f4dd20d734bd968b3d95e89
|
|
@ -28,7 +28,7 @@
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
#define DEFAULT_AUDIOSINK "alsasink"
|
#define DEFAULT_AUDIOSINK "autoaudiosink"
|
||||||
|
|
||||||
static GtkWidget *drawingarea = NULL;
|
static GtkWidget *drawingarea = NULL;
|
||||||
static guint spect_height = 64;
|
static guint spect_height = 64;
|
||||||
|
@ -126,7 +126,7 @@ main (int argc, char *argv[])
|
||||||
bin = gst_pipeline_new ("bin");
|
bin = gst_pipeline_new ("bin");
|
||||||
|
|
||||||
src = gst_element_factory_make ("audiotestsrc", "src");
|
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");
|
spectrum = gst_element_factory_make ("spectrum", "spectrum");
|
||||||
g_object_set (G_OBJECT (spectrum), "bands", spect_bands, "threshold", -80,
|
g_object_set (G_OBJECT (spectrum), "bands", spect_bands, "threshold", -80,
|
||||||
|
|
|
@ -517,10 +517,12 @@ process_s##width (GstSpectrum *spectrum, const gint##width *samples) \
|
||||||
\
|
\
|
||||||
/* Calculate magnitude in db */ \
|
/* Calculate magnitude in db */ \
|
||||||
for (i = 0; i < spectrum->bands; i++) { \
|
for (i = 0; i < spectrum->bands; i++) { \
|
||||||
gdouble val = (gdouble) freqdata[i].r * (gdouble) freqdata[i].r \
|
gdouble val; \
|
||||||
+ (gdouble) freqdata[i].i * (gdouble) freqdata[i].i; \
|
val = (gdouble) freqdata[i].r * (gdouble) freqdata[i].r; \
|
||||||
val = sqrt (val); \
|
val += (gdouble) freqdata[i].i * (gdouble) freqdata[i].i; \
|
||||||
val = 20.0 * log10 (val / max); \
|
val *= nfft; \
|
||||||
|
val /= max*max; \
|
||||||
|
val = 10.0 * log10 (val); \
|
||||||
if (val > spectrum->threshold) \
|
if (val > spectrum->threshold) \
|
||||||
val -= spectrum->threshold; \
|
val -= spectrum->threshold; \
|
||||||
else \
|
else \
|
||||||
|
@ -583,9 +585,11 @@ process_f##width (GstSpectrum *spectrum, const g##type *samples) \
|
||||||
\
|
\
|
||||||
/* Calculate magnitude in db */ \
|
/* Calculate magnitude in db */ \
|
||||||
for (i = 0; i < spectrum->bands; i++) { \
|
for (i = 0; i < spectrum->bands; i++) { \
|
||||||
gdouble val = freqdata[i].r * freqdata[i].r + freqdata[i].i * freqdata[i].i; \
|
gdouble val; \
|
||||||
val = sqrt (val); \
|
val = freqdata[i].r * freqdata[i].r; \
|
||||||
val = 20.0 * log10 (val / nfft); \
|
val += freqdata[i].i * freqdata[i].i; \
|
||||||
|
val /= nfft; \
|
||||||
|
val = 10.0 * log10 (val); \
|
||||||
if (val > spectrum->threshold) \
|
if (val > spectrum->threshold) \
|
||||||
val -= spectrum->threshold; \
|
val -= spectrum->threshold; \
|
||||||
else \
|
else \
|
||||||
|
|
Loading…
Reference in a new issue