Equalizer -> GST_TYPE_xxx);

I want to install an equalizer, but the question is, how do I get to it?

What needs to go into this line?

GstElement * equalizer = gst_bin_get_by_interface(GST_BIN(pipeline), GST_TYPE_???????);

I’ve already managed to do it with volume as follows.

I think it should work similarly with the equalizer.

// gcc main.c -o main `pkg-config --cflags --libs gstreamer-1.0 gstreamer-audio-1.0`

#include <stdio.h>
#include <gst/gst.h>
#include <gst/audio/streamvolume.h>

int main (int argc, char *argv[]) {
  gst_init (&argc, &argv); 
  GstElement * pipeline = gst_parse_launch("filesrc location=/home/tux/Desk/sound/test.mp3 ! decodebin ! audioconvert ! audioresample ! equalizer-3bands ! equalizer-3bands band1=-6.0 ! volume ! autoaudiosink", NULL);

  GstElement *    volume = gst_bin_get_by_interface(GST_BIN(pipeline), GST_TYPE_STREAM_VOLUME);
  GstElement * equalizer = gst_bin_get_by_interface(GST_BIN(pipeline), GST_TYPE_?????????); // ???

  g_object_set(volume, "volume", 0.2, NULL);
  g_object_set(equalizer, "band1", 6.0, NULL);
 
  gst_element_set_state(pipeline, GST_STATE_PLAYING);

  printf("<CTRL+C> = stop\n");
  while (1) { } 
} 

Give your equalizer a name in the pipeline declaration (like equalizer-3bands name=foo) and then in C, use gst_bin_get_by_name() and don’t forget to gst_object_unref() the return value when no longer needed.

1 Like

The volume is also leaking in that code, you need to unref it when no longer needed.

1 Like