gst/: Change the meaning of the magnitude values given in the

Original commit message from CVS:
* gst/equalizer/demo.c: (draw_spectrum):
* gst/spectrum/demo-audiotest.c: (draw_spectrum):
* gst/spectrum/demo-osssrc.c: (draw_spectrum):
* gst/spectrum/gstspectrum.c: (gst_spectrum_class_init):
Change the meaning of the magnitude values given in the
GstMessages by spectrum to decibel instead of
decibel+threshold.
This commit is contained in:
Sebastian Dröge 2007-11-11 21:12:10 +00:00
parent 0ada8ac415
commit 015dc9060f
5 changed files with 24 additions and 18 deletions

View file

@ -1,3 +1,13 @@
2007-11-11 Sebastian Dröge <slomo@circular-chaos.org>
* gst/equalizer/demo.c: (draw_spectrum):
* gst/spectrum/demo-audiotest.c: (draw_spectrum):
* gst/spectrum/demo-osssrc.c: (draw_spectrum):
* gst/spectrum/gstspectrum.c: (gst_spectrum_class_init):
Change the meaning of the magnitude values given in the
GstMessages by spectrum to decibel instead of
decibel+threshold.
2007-11-11 Sebastian Dröge <slomo@circular-chaos.org> 2007-11-11 Sebastian Dröge <slomo@circular-chaos.org>
* gst/equalizer/gstiirequalizer10bands.c: * gst/equalizer/gstiirequalizer10bands.c:

View file

@ -88,7 +88,7 @@ draw_spectrum (gfloat * data)
TRUE, 0, 0, spect_bands, spect_height); TRUE, 0, 0, spect_bands, spect_height);
for (i = 0; i < spect_bands; i++) { for (i = 0; i < spect_bands; i++) {
gdk_draw_rectangle (drawingarea->window, drawingarea->style->white_gc, gdk_draw_rectangle (drawingarea->window, drawingarea->style->white_gc,
TRUE, i, spect_height - data[i], 1, data[i]); TRUE, i, -data[i], 1, spect_height + data[i]);
} }
gdk_window_end_paint (drawingarea->window); gdk_window_end_paint (drawingarea->window);
} }
@ -134,7 +134,7 @@ main (int argc, char *argv[])
/* White noise */ /* White noise */
src = gst_element_factory_make ("audiotestsrc", "src"); src = gst_element_factory_make ("audiotestsrc", "src");
g_object_set (G_OBJECT (src), "wave", 5, "volume", 0.5, NULL); g_object_set (G_OBJECT (src), "wave", 5, "volume", 0.8, NULL);
/* Force float32 samples */ /* Force float32 samples */
capsfilter = gst_element_factory_make ("capsfilter", "capsfilter"); capsfilter = gst_element_factory_make ("capsfilter", "capsfilter");

View file

@ -82,7 +82,7 @@ draw_spectrum (gfloat * data)
TRUE, 0, 0, spect_bands, spect_height); TRUE, 0, 0, spect_bands, spect_height);
for (i = 0; i < spect_bands; i++) { for (i = 0; i < spect_bands; i++) {
gdk_draw_rectangle (drawingarea->window, drawingarea->style->white_gc, gdk_draw_rectangle (drawingarea->window, drawingarea->style->white_gc,
TRUE, i, spect_height - data[i], 1, data[i]); TRUE, i, -data[i], 1, spect_height + data[i]);
} }
gdk_window_end_paint (drawingarea->window); gdk_window_end_paint (drawingarea->window);
} }

View file

@ -71,7 +71,7 @@ draw_spectrum (gfloat * data)
TRUE, 0, 0, spect_bands, spect_height); TRUE, 0, 0, spect_bands, spect_height);
for (i = 0; i < spect_bands; i++) { for (i = 0; i < spect_bands; i++) {
gdk_draw_rectangle (drawingarea->window, drawingarea->style->white_gc, gdk_draw_rectangle (drawingarea->window, drawingarea->style->white_gc,
TRUE, i, spect_height - data[i], 1, data[i]); TRUE, i, -data[i], 1, spect_height + data[i]);
} }
gdk_window_end_paint (drawingarea->window); gdk_window_end_paint (drawingarea->window);
} }

View file

@ -40,9 +40,9 @@
* <para> * <para>
* #GstValueList of #gfloat * #GstValueList of #gfloat
* <classname>&quot;magnitude&quot;</classname>: * <classname>&quot;magnitude&quot;</classname>:
* the level for each frequency band. A value of 0 maps to the * the level for each frequency band in dB. All values below the value of the
* db value given by the * <link linkend="GstSpectrum--threshold">threshold property</link> will
* <link linkend="GstSpectrum--threshold">threshold property.</link>. * be set to the threshold.
* </para> * </para>
* </listitem> * </listitem>
* <listitem> * <listitem>
@ -57,7 +57,7 @@
* This element cannot be used with the gst-launch command in a sensible way. * This element cannot be used with the gst-launch command in a sensible way.
* The included demo shows how to use it in an application. * The included demo shows how to use it in an application.
* *
* Last reviewed on 2007-08-18 (0.10.5) * Last reviewed on 2007-11-11 (0.10.6)
* </refsect2> * </refsect2>
*/ */
@ -212,8 +212,8 @@ gst_spectrum_class_init (GstSpectrumClass * klass)
g_object_class_install_property (gobject_class, PROP_THRESHOLD, g_object_class_install_property (gobject_class, PROP_THRESHOLD,
g_param_spec_int ("threshold", "Threshold", g_param_spec_int ("threshold", "Threshold",
"db threshold for result, maps to 0", G_MININT, 0, DEFAULT_THRESHOLD, "dB threshold for result. All lower values will be set to this",
G_PARAM_READWRITE)); G_MININT, 0, DEFAULT_THRESHOLD, G_PARAM_READWRITE));
GST_DEBUG_CATEGORY_INIT (gst_spectrum_debug, "spectrum", 0, GST_DEBUG_CATEGORY_INIT (gst_spectrum_debug, "spectrum", 0,
"audio spectrum analyser element"); "audio spectrum analyser element");
@ -522,10 +522,8 @@ process_s##width (GstSpectrum *spectrum, const gint##width *samples) \
val += (gdouble) freqdata[i].i * (gdouble) freqdata[i].i; \ val += (gdouble) freqdata[i].i * (gdouble) freqdata[i].i; \
val /= max*max; \ val /= max*max; \
val = 10.0 * log10 (val); \ val = 10.0 * log10 (val); \
if (val > spectrum->threshold) \ if (val < spectrum->threshold) \
val -= spectrum->threshold; \ val = spectrum->threshold; \
else \
val = 0.0; \
spect_magnitude[i] += val; \ spect_magnitude[i] += val; \
} \ } \
\ \
@ -589,10 +587,8 @@ process_f##width (GstSpectrum *spectrum, const g##type *samples) \
val += freqdata[i].i * freqdata[i].i; \ val += freqdata[i].i * freqdata[i].i; \
val /= nfft*nfft; \ val /= nfft*nfft; \
val = 10.0 * log10 (val); \ val = 10.0 * log10 (val); \
if (val > spectrum->threshold) \ if (val < spectrum->threshold) \
val -= spectrum->threshold; \ val = spectrum->threshold; \
else \
val = 0.0; \
spect_magnitude[i] += val; \ spect_magnitude[i] += val; \
} \ } \
\ \