summaryrefslogtreecommitdiffstats
path: root/gst/equalizer/gstiirequalizer.c
diff options
context:
space:
mode:
authorSebastian Dröge <slomo@circular-chaos.org>2007-10-30 21:37:49 +0000
committerSebastian Dröge <slomo@circular-chaos.org>2007-10-30 21:37:49 +0000
commit0f6e8ea21f39ae041ea0a453cc69985cf137a3cc (patch)
tree40fb56e3c23da96ff0d02dcbbab3e2ac67260754 /gst/equalizer/gstiirequalizer.c
parent3b838968c2a34e1031b8b67ae7b9dc784ec6d209 (diff)
downloadgst-plugins-bad-0f6e8ea21f39ae041ea0a453cc69985cf137a3cc.tar.gz
gst-plugins-bad-0f6e8ea21f39ae041ea0a453cc69985cf137a3cc.tar.bz2
gst-plugins-bad-0f6e8ea21f39ae041ea0a453cc69985cf137a3cc.zip
gst/equalizer/: Add small demo application based on the spectrum demo applications that gets white noise as input, pu...
Original commit message from CVS: * gst/equalizer/Makefile.am: * gst/equalizer/demo.c: (on_window_destroy), (on_configure_event), (on_gain_changed), (on_bandwidth_changed), (on_freq_changed), (draw_spectrum), (message_handler), (main): Add small demo application based on the spectrum demo applications that gets white noise as input, pushes it through an equalizer and paints the spectrum. For every equalizer band it's possible to set gain, bandwidth and frequency. * gst/equalizer/gstiirequalizer.c: (setup_filter): Add some guarding against too large or too small frequencies and bandwidths. Also improve debugging a bit.
Diffstat (limited to 'gst/equalizer/gstiirequalizer.c')
-rw-r--r--gst/equalizer/gstiirequalizer.c39
1 files changed, 27 insertions, 12 deletions
diff --git a/gst/equalizer/gstiirequalizer.c b/gst/equalizer/gstiirequalizer.c
index 8c87a664..25ee6972 100644
--- a/gst/equalizer/gstiirequalizer.c
+++ b/gst/equalizer/gstiirequalizer.c
@@ -1,6 +1,7 @@
/* GStreamer
* Copyright (C) <2004> Benjamin Otte <otte@gnome.org>
* <2007> Stefan Kost <ensonic@users.sf.net>
+ * <2007> Sebastian Dröge <slomo@circular-chaos.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -33,7 +34,6 @@
GST_DEBUG_CATEGORY (equalizer_debug);
#define GST_CAT_DEFAULT equalizer_debug
-
static void gst_iir_equalizer_child_proxy_interface_init (gpointer g_iface,
gpointer iface_data);
@@ -376,17 +376,32 @@ setup_filter (GstIirEqualizer * equ, GstIirEqualizerBand * band)
* - we need shelf-filter for 1st and last band
*/
{
- gdouble gain = arg_to_scale (band->gain);
- gdouble frequency = band->freq / GST_AUDIO_FILTER (equ)->format.rate;
- gdouble omega = 2.0 * M_PI * frequency;
- gdouble bw =
- 2.0 * M_PI * (band->width / GST_AUDIO_FILTER (equ)->format.rate);
+ gdouble gain, omega, bw;
+ gdouble edge_gain, gamma;
+ gdouble alpha, beta;
+
+
+ gain = arg_to_scale (band->gain);
+
+ if (band->freq / GST_AUDIO_FILTER (equ)->format.rate > 0.5)
+ omega = M_PI;
+ else if (band->freq < 0.0)
+ omega = 0.0;
+ else
+ omega = 2.0 * M_PI * (band->freq / GST_AUDIO_FILTER (equ)->format.rate);
+
+ if (band->width / GST_AUDIO_FILTER (equ)->format.rate > 0.5)
+ bw = M_PI;
+ else if (band->width <= 1.0)
+ bw = 2.0 * M_PI * (1.0 / GST_AUDIO_FILTER (equ)->format.rate);
+ else
+ bw = 2.0 * M_PI * (band->width / GST_AUDIO_FILTER (equ)->format.rate);
- gdouble edge_gain = sqrt (gain);
- gdouble gamma = tan (bw / 2.0);
+ edge_gain = sqrt (gain);
+ gamma = tan (bw / 2.0);
- gdouble alpha = gamma * edge_gain;
- gdouble beta = gamma / edge_gain;
+ alpha = gamma * edge_gain;
+ beta = gamma / edge_gain;
band->a0 = (1.0 + alpha) / (1.0 + beta);
band->a1 = (-2.0 * cos (omega)) / (1.0 + beta);
@@ -396,8 +411,8 @@ setup_filter (GstIirEqualizer * equ, GstIirEqualizerBand * band)
GST_INFO
("gain = %7.5g, , bandwidth= %7.5g, frequency = %7.5g, a0 = %7.5g, a1 = %7.5g, a2=%7.5g b1 = %7.5g, b2 = %7.5g",
- gain, band->width, frequency, band->a0, band->a1, band->a2, band->b1,
- band->b2);
+ band->gain, band->width, band->freq, band->a0, band->a1, band->a2,
+ band->b1, band->b2);
}
}