2015-04-15 16:32:37 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 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
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
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.
2007-10-30 21:37:49 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <gst/gst.h>
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#define NBANDS 10
|
|
|
|
|
|
|
|
static GtkWidget *drawingarea = NULL;
|
|
|
|
static guint spect_height = 128;
|
|
|
|
static guint spect_bands = 256;
|
|
|
|
static gfloat height_scale = 2.0;
|
|
|
|
|
|
|
|
static void
|
2010-10-12 09:37:40 +00:00
|
|
|
on_window_destroy (GObject * object, gpointer user_data)
|
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.
2007-10-30 21:37:49 +00:00
|
|
|
{
|
|
|
|
drawingarea = NULL;
|
|
|
|
gtk_main_quit ();
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
on_configure_event (GtkWidget * widget, GdkEventConfigure * event,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GstElement *spectrum = GST_ELEMENT (user_data);
|
|
|
|
|
|
|
|
/*GST_INFO ("%d x %d", event->width, event->height); */
|
|
|
|
spect_height = event->height;
|
|
|
|
height_scale = event->height / 64.0;
|
|
|
|
spect_bands = event->width;
|
|
|
|
|
|
|
|
g_object_set (G_OBJECT (spectrum), "bands", spect_bands, NULL);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* control gains */
|
|
|
|
static void
|
|
|
|
on_gain_changed (GtkRange * range, gpointer user_data)
|
|
|
|
{
|
|
|
|
GstObject *band = GST_OBJECT (user_data);
|
|
|
|
gdouble value = gtk_range_get_value (range);
|
|
|
|
|
|
|
|
g_object_set (band, "gain", value, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* control bandwidths */
|
|
|
|
static void
|
|
|
|
on_bandwidth_changed (GtkRange * range, gpointer user_data)
|
|
|
|
{
|
|
|
|
GstObject *band = GST_OBJECT (user_data);
|
|
|
|
gdouble value = gtk_range_get_value (range);
|
|
|
|
|
|
|
|
g_object_set (band, "bandwidth", value, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* control frequency */
|
|
|
|
static void
|
|
|
|
on_freq_changed (GtkRange * range, gpointer user_data)
|
|
|
|
{
|
|
|
|
GstObject *band = GST_OBJECT (user_data);
|
|
|
|
gdouble value = gtk_range_get_value (range);
|
|
|
|
|
|
|
|
/* hbox */
|
|
|
|
GtkWidget *parent = gtk_widget_get_parent (GTK_WIDGET (range));
|
|
|
|
|
|
|
|
/* frame */
|
|
|
|
GtkWidget *parent_parent = gtk_widget_get_parent (parent);
|
|
|
|
gchar *label = g_strdup_printf ("%d Hz", (int) (value + 0.5));
|
|
|
|
|
|
|
|
gtk_frame_set_label (GTK_FRAME (parent_parent), label);
|
|
|
|
g_free (label);
|
|
|
|
|
|
|
|
g_object_set (band, "freq", value, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* draw frequency spectrum as a bunch of bars */
|
|
|
|
static void
|
|
|
|
draw_spectrum (gfloat * data)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
GdkRectangle rect = { 0, 0, spect_bands, spect_height };
|
2010-07-24 08:19:37 +00:00
|
|
|
cairo_t *cr;
|
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.
2007-10-30 21:37:49 +00:00
|
|
|
|
|
|
|
if (!drawingarea)
|
|
|
|
return;
|
|
|
|
|
2010-06-26 18:12:25 +00:00
|
|
|
gdk_window_begin_paint_rect (gtk_widget_get_window (drawingarea), &rect);
|
2010-07-24 08:19:37 +00:00
|
|
|
cr = gdk_cairo_create (gtk_widget_get_window (drawingarea));
|
|
|
|
|
|
|
|
cairo_set_source_rgb (cr, 0, 0, 0);
|
|
|
|
cairo_rectangle (cr, 0, 0, spect_bands, spect_height);
|
|
|
|
cairo_fill (cr);
|
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.
2007-10-30 21:37:49 +00:00
|
|
|
for (i = 0; i < spect_bands; i++) {
|
2010-07-24 08:19:37 +00:00
|
|
|
cairo_set_source_rgb (cr, 1, 1, 1);
|
|
|
|
cairo_rectangle (cr, i, -data[i], 1, spect_height + data[i]);
|
|
|
|
cairo_fill (cr);
|
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.
2007-10-30 21:37:49 +00:00
|
|
|
}
|
2010-07-24 08:29:01 +00:00
|
|
|
cairo_destroy (cr);
|
|
|
|
|
2010-06-26 18:12:25 +00:00
|
|
|
gdk_window_end_paint (gtk_widget_get_window (drawingarea));
|
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.
2007-10-30 21:37:49 +00:00
|
|
|
}
|
|
|
|
|
2015-04-16 15:01:50 +00:00
|
|
|
static void
|
|
|
|
dynamic_link (GstPadTemplate * templ, GstPad * newpad, gpointer user_data)
|
|
|
|
{
|
|
|
|
GstPad *target = GST_PAD (user_data);
|
|
|
|
|
|
|
|
gst_pad_link (newpad, target);
|
|
|
|
gst_object_unref (target);
|
|
|
|
}
|
|
|
|
|
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.
2007-10-30 21:37:49 +00:00
|
|
|
/* receive spectral data from element message */
|
2010-03-17 17:23:00 +00:00
|
|
|
static gboolean
|
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.
2007-10-30 21:37:49 +00:00
|
|
|
message_handler (GstBus * bus, GstMessage * message, gpointer data)
|
|
|
|
{
|
|
|
|
if (message->type == GST_MESSAGE_ELEMENT) {
|
|
|
|
const GstStructure *s = gst_message_get_structure (message);
|
|
|
|
const gchar *name = gst_structure_get_name (s);
|
|
|
|
|
|
|
|
if (strcmp (name, "spectrum") == 0) {
|
2008-07-08 12:51:34 +00:00
|
|
|
gfloat *spect = g_new (gfloat, spect_bands);
|
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.
2007-10-30 21:37:49 +00:00
|
|
|
const GValue *list;
|
|
|
|
const GValue *value;
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
list = gst_structure_get_value (s, "magnitude");
|
|
|
|
for (i = 0; i < spect_bands; ++i) {
|
|
|
|
value = gst_value_list_get_value (list, i);
|
|
|
|
spect[i] = height_scale * g_value_get_float (value);
|
|
|
|
}
|
|
|
|
draw_spectrum (spect);
|
2008-07-08 12:51:34 +00:00
|
|
|
g_free (spect);
|
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.
2007-10-30 21:37:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char *argv[])
|
|
|
|
{
|
|
|
|
GstElement *bin;
|
2015-04-16 15:01:50 +00:00
|
|
|
GstElement *decodebin, *decconvert;
|
|
|
|
GstElement *capsfilter, *equalizer, *spectrum, *sinkconvert, *sink;
|
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.
2007-10-30 21:37:49 +00:00
|
|
|
GstCaps *caps;
|
|
|
|
GstBus *bus;
|
2015-04-16 10:17:38 +00:00
|
|
|
GtkWidget *appwindow, *vbox, *hbox, *scale;
|
2015-04-16 15:33:44 +00:00
|
|
|
int i, num_bands = NBANDS;
|
|
|
|
|
|
|
|
GOptionEntry options[] = {
|
|
|
|
{"bands", 'b', 0, G_OPTION_ARG_INT, &num_bands,
|
|
|
|
"Number of bands", NULL},
|
|
|
|
{NULL}
|
|
|
|
};
|
|
|
|
GOptionContext *ctx;
|
|
|
|
GError *err = NULL;
|
|
|
|
|
|
|
|
ctx = g_option_context_new ("- demo of audio equalizer");
|
|
|
|
g_option_context_add_main_entries (ctx, options, NULL);
|
|
|
|
g_option_context_add_group (ctx, gst_init_get_option_group ());
|
|
|
|
g_option_context_add_group (ctx, gtk_get_option_group (TRUE));
|
|
|
|
|
|
|
|
if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
|
|
|
|
g_print ("Error initializing: %s\n", err->message);
|
|
|
|
exit (1);
|
|
|
|
}
|
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.
2007-10-30 21:37:49 +00:00
|
|
|
|
2015-04-16 15:01:50 +00:00
|
|
|
if (argc < 2) {
|
|
|
|
g_print ("Usage: %s <uri to play>\n", argv[0]);
|
2015-04-16 15:33:44 +00:00
|
|
|
g_print (" For optional arguments: --help\n");
|
2015-04-16 15:01:50 +00:00
|
|
|
exit (-1);
|
|
|
|
}
|
|
|
|
|
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.
2007-10-30 21:37:49 +00:00
|
|
|
gst_init (&argc, &argv);
|
|
|
|
gtk_init (&argc, &argv);
|
|
|
|
|
|
|
|
bin = gst_pipeline_new ("bin");
|
|
|
|
|
2015-04-16 15:01:50 +00:00
|
|
|
/* Uri decoding */
|
|
|
|
decodebin = gst_element_factory_make ("uridecodebin", "decoder");
|
|
|
|
g_object_set (G_OBJECT (decodebin), "uri", argv[1], NULL);
|
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.
2007-10-30 21:37:49 +00:00
|
|
|
|
|
|
|
/* Force float32 samples */
|
2015-04-16 15:01:50 +00:00
|
|
|
decconvert = gst_element_factory_make ("audioconvert", "decconvert");
|
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.
2007-10-30 21:37:49 +00:00
|
|
|
capsfilter = gst_element_factory_make ("capsfilter", "capsfilter");
|
|
|
|
caps =
|
2012-09-14 11:30:37 +00:00
|
|
|
gst_caps_new_simple ("audio/x-raw", "format", G_TYPE_STRING, "F32LE",
|
|
|
|
NULL);
|
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.
2007-10-30 21:37:49 +00:00
|
|
|
g_object_set (capsfilter, "caps", caps, NULL);
|
|
|
|
|
|
|
|
equalizer = gst_element_factory_make ("equalizer-nbands", "equalizer");
|
2015-04-16 15:33:44 +00:00
|
|
|
g_object_set (G_OBJECT (equalizer), "num-bands", num_bands, NULL);
|
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.
2007-10-30 21:37:49 +00:00
|
|
|
|
|
|
|
spectrum = gst_element_factory_make ("spectrum", "spectrum");
|
|
|
|
g_object_set (G_OBJECT (spectrum), "bands", spect_bands, "threshold", -80,
|
2014-08-18 05:03:48 +00:00
|
|
|
"post-messages", TRUE, "interval", 500 * GST_MSECOND, NULL);
|
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.
2007-10-30 21:37:49 +00:00
|
|
|
|
2015-04-16 15:01:50 +00:00
|
|
|
sinkconvert = gst_element_factory_make ("audioconvert", "sinkconvert");
|
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.
2007-10-30 21:37:49 +00:00
|
|
|
|
|
|
|
sink = gst_element_factory_make ("autoaudiosink", "sink");
|
|
|
|
|
2015-04-16 15:01:50 +00:00
|
|
|
gst_bin_add_many (GST_BIN (bin), decodebin, decconvert, capsfilter, equalizer,
|
|
|
|
spectrum, sinkconvert, sink, NULL);
|
|
|
|
if (!gst_element_link_many (decconvert, capsfilter, equalizer, spectrum,
|
|
|
|
sinkconvert, sink, NULL)) {
|
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.
2007-10-30 21:37:49 +00:00
|
|
|
fprintf (stderr, "can't link elements\n");
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
|
2015-04-16 15:01:50 +00:00
|
|
|
/* Handle dynamic pads */
|
|
|
|
g_signal_connect (G_OBJECT (decodebin), "pad-added",
|
|
|
|
G_CALLBACK (dynamic_link), gst_element_get_static_pad (decconvert,
|
|
|
|
"sink"));
|
|
|
|
|
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.
2007-10-30 21:37:49 +00:00
|
|
|
bus = gst_element_get_bus (bin);
|
|
|
|
gst_bus_add_watch (bus, message_handler, NULL);
|
|
|
|
gst_object_unref (bus);
|
|
|
|
|
|
|
|
appwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
2015-04-16 10:17:38 +00:00
|
|
|
gtk_window_set_title (GTK_WINDOW (appwindow), "Equalizer Demo");
|
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.
2007-10-30 21:37:49 +00:00
|
|
|
g_signal_connect (G_OBJECT (appwindow), "destroy",
|
|
|
|
G_CALLBACK (on_window_destroy), NULL);
|
2012-07-03 03:47:58 +00:00
|
|
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
|
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.
2007-10-30 21:37:49 +00:00
|
|
|
|
|
|
|
drawingarea = gtk_drawing_area_new ();
|
|
|
|
gtk_widget_set_size_request (drawingarea, spect_bands, spect_height);
|
|
|
|
g_signal_connect (G_OBJECT (drawingarea), "configure-event",
|
|
|
|
G_CALLBACK (on_configure_event), (gpointer) spectrum);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), drawingarea, TRUE, TRUE, 0);
|
|
|
|
|
2012-07-03 03:47:58 +00:00
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 20);
|
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.
2007-10-30 21:37:49 +00:00
|
|
|
|
2015-04-16 15:33:44 +00:00
|
|
|
for (i = 0; i < num_bands; i++) {
|
2012-03-31 13:43:49 +00:00
|
|
|
GObject *band;
|
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.
2007-10-30 21:37:49 +00:00
|
|
|
gdouble freq;
|
|
|
|
gdouble bw;
|
|
|
|
gdouble gain;
|
|
|
|
gchar *label;
|
|
|
|
GtkWidget *frame, *scales_hbox;
|
|
|
|
|
|
|
|
band = gst_child_proxy_get_child_by_index (GST_CHILD_PROXY (equalizer), i);
|
|
|
|
g_assert (band != NULL);
|
2012-03-31 13:43:49 +00:00
|
|
|
g_object_get (band, "freq", &freq, NULL);
|
|
|
|
g_object_get (band, "bandwidth", &bw, NULL);
|
|
|
|
g_object_get (band, "gain", &gain, NULL);
|
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.
2007-10-30 21:37:49 +00:00
|
|
|
|
|
|
|
label = g_strdup_printf ("%d Hz", (int) (freq + 0.5));
|
|
|
|
frame = gtk_frame_new (label);
|
|
|
|
g_free (label);
|
|
|
|
|
2012-07-03 03:47:58 +00:00
|
|
|
scales_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
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.
2007-10-30 21:37:49 +00:00
|
|
|
|
2015-04-16 10:17:38 +00:00
|
|
|
/* Create gain scale */
|
|
|
|
scale = gtk_scale_new_with_range (GTK_ORIENTATION_VERTICAL,
|
2012-07-03 03:47:58 +00:00
|
|
|
-24.0, 12.0, 0.5);
|
2015-04-16 10:17:38 +00:00
|
|
|
gtk_scale_set_draw_value (GTK_SCALE (scale), TRUE);
|
|
|
|
gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP);
|
|
|
|
gtk_range_set_value (GTK_RANGE (scale), gain);
|
|
|
|
gtk_widget_set_size_request (scale, 35, 150);
|
|
|
|
g_signal_connect (G_OBJECT (scale), "value-changed",
|
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.
2007-10-30 21:37:49 +00:00
|
|
|
G_CALLBACK (on_gain_changed), (gpointer) band);
|
2015-04-16 10:17:38 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (scales_hbox), scale, FALSE, FALSE, 0);
|
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.
2007-10-30 21:37:49 +00:00
|
|
|
|
2015-04-16 10:17:38 +00:00
|
|
|
/* Create bandwidth scale */
|
|
|
|
scale = gtk_scale_new_with_range (GTK_ORIENTATION_VERTICAL,
|
2012-07-03 03:47:58 +00:00
|
|
|
0.0, 20000.0, 5.0);
|
2015-04-16 10:17:38 +00:00
|
|
|
gtk_scale_set_draw_value (GTK_SCALE (scale), TRUE);
|
|
|
|
gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP);
|
|
|
|
gtk_range_set_value (GTK_RANGE (scale), bw);
|
|
|
|
gtk_widget_set_size_request (scale, 45, 150);
|
|
|
|
g_signal_connect (G_OBJECT (scale), "value-changed",
|
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.
2007-10-30 21:37:49 +00:00
|
|
|
G_CALLBACK (on_bandwidth_changed), (gpointer) band);
|
2015-04-16 10:17:38 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (scales_hbox), scale, TRUE, TRUE, 0);
|
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.
2007-10-30 21:37:49 +00:00
|
|
|
|
2015-04-16 10:17:38 +00:00
|
|
|
/* Create frequency scale */
|
|
|
|
scale = gtk_scale_new_with_range (GTK_ORIENTATION_VERTICAL,
|
2012-07-03 03:47:58 +00:00
|
|
|
20.0, 20000.0, 5.0);
|
2015-04-16 10:17:38 +00:00
|
|
|
gtk_scale_set_draw_value (GTK_SCALE (scale), TRUE);
|
|
|
|
gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP);
|
|
|
|
gtk_range_set_value (GTK_RANGE (scale), freq);
|
|
|
|
gtk_widget_set_size_request (scale, 45, 150);
|
|
|
|
g_signal_connect (G_OBJECT (scale), "value-changed",
|
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.
2007-10-30 21:37:49 +00:00
|
|
|
G_CALLBACK (on_freq_changed), (gpointer) band);
|
2015-04-16 10:17:38 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (scales_hbox), scale, TRUE, TRUE, 0);
|
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.
2007-10-30 21:37:49 +00:00
|
|
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), scales_hbox);
|
|
|
|
|
2007-11-08 15:56:46 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
|
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.
2007-10-30 21:37:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
|
|
|
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (appwindow), vbox);
|
|
|
|
gtk_widget_show_all (appwindow);
|
|
|
|
|
|
|
|
gst_element_set_state (bin, GST_STATE_PLAYING);
|
|
|
|
gtk_main ();
|
|
|
|
gst_element_set_state (bin, GST_STATE_NULL);
|
|
|
|
|
|
|
|
gst_object_unref (bin);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|