Adding two audio-filter plug-ins to playbin3 in C++

Hi,
In my c++ application I use playbin3, and have added the “spectrum” plug-in audio-filter (using gst.spectrum = gst_element_factory_make("spectrum", "spectrum") and then g_object_set(gst.playbin, "audio-filter", gst.spectrum, nullptr);).

But I also want to add the audio “level” plug-in as well (gst.level = gst_element_factory_make("level", "level") and then g_object_set(gst.playbin, "audio-filter", gst.level, nullptr).

However, only the last plug-in I add of the two seems to work, so it looks like the second over-rides the first, and only one is supported. Is there a way to add two audio-filters to playbin3?

Thanks,
Mike

You can make a bin with the two elements inside and set that as the filter, e.g. with

GstElement *filter_bin;

filter_bin = gst_parse_bin_from_description ("spectrum ! level", TRUE, NULL);

(or build it manually)

Hi,

thanks for the quick reply, much appreciated.

A couple more questions - how do I set the spectrum and level parameters for this combined filter bin? When I created them separately, I used : g_object_set(gst.spectrum, "interval", interval, "bands", NUM_SUB_BANDS, "threshold", spectrum_analyser_threshold, "multi-channel", true, nullptr); and g_object_set(gst.level, "interval", interval, nullptr); for the individual GSTElements, but how do I reference the spectrum and level elements separately to define their parameters?
Also, when handling their GST_MESSAGE_ELEMENT messages, can I just use the “spectrum” and “level” message labels as before (i.e. switch (GST_MESSAGE_TYPE(msg)) { case GST_MESSAGE_ELEMENT: strct = gst_message_get_structure (msg); if (gst_structure_has_name(strct, "spectrum")) { ... }

Thanks,
Mike