GNOME Bugzilla – Bug 771761
GstPlayer: add equalizer support [API]
Last modified: 2018-11-03 13:55:32 UTC
Hi, Below is the draft of proposed equalizer api's to be added in GstPlayer. I would like to open a discussion to finalize this. Please provide inputs on this. typedef enum { GST_PLAYER_EQUALIZER_NONE, GST_PLAYER_EQUALIZER_3BANDS, GST_PLAYER_EQUALIZER_10BANDS, GST_PLAYER_EQUALIZER_NBANDS } GstPlayerEqualizerType; struct _GstPlayer { . . . gboolean is_equalizer_enabled; GstPlayerEqualizerType equalizer_type; }; gboolean gst_player_is_equalizer_enabled( GstPlayer * player); void gst_player_enable_equalizer (GstPlayer * player, GstPlayerEqualizerType type); // passing GST_PLAYER_EUQALIZER_NONE will remove existing equalizer element. int gst_player_get_equalizer_band_count (GstPlayer * player); void gst_player_set_equalizer_band_count ( GstPlayer * player, int band_count); //for nband equalizer. in case of 3 or 10 bands, function will ignore this call double gst_player_get_band_value( GstPlayer * player, int band_num); void gst_player_set_band_value( GstPlayer * player, int band_num, double value); Thanks, Sachin k Chauhan
API-wise, adding the NBANDS equalizer makes it all a bit awkward. You need to have API for setting the number of bands, and also the center frequency and shape of each band then (which you are missing above). I think we should limit ourselves to the 3 and 10 band equalizers here instead. And you want to add API to get the center frequency of each band at least. This should also probably become part of playsink.
OK. We can limit ourselves to 3 and 10 band equalizers for now. These equalizers have their bands at fixed frequency. 3 band @ 100 Hz, 1100 Hz and 11KHz, and 10 band @ 29, 59, 119, 237, 474, 947, 1889, 3770, 7523, 15011 Hz. So its not possible to set the center freq. We can add an API for getting center freq. For 3 band its 1100 Hz, and for 10 bands it will be the average of 5th and 6th bands. Below is the modified interface. typedef enum { GST_PLAYER_EQUALIZER_NONE, GST_PLAYER_EQUALIZER_3BANDS, GST_PLAYER_EQUALIZER_10BANDS, } GstPlayerEqualizerType; struct _GstPlayer { . . . GstPlayerEqualizerType equalizer_type; // default: GST_PLAYER_EQUALIZER_NONE }; /* If GST_PLAYER_EQUALIZER_NONE is returned, there is no equalizer element in pipeline */ GstPlayerEqualizerType gst_player_equalizer_get ( GstPlayer * player); /* passing GST_PLAYER_EQUALIZER_NONE will remove existing equalizer element. */ void gst_player_equalizer_set (GstPlayer * player, GstPlayerEqualizerType type); double gst_player_equalizer_get_band_gain ( GstPlayer * player, int band_index); void gst_player_equalizer_set_band_gain ( GstPlayer * player, int band_index, double gain); int gst_player_equalizer_get_center_freq ( GstPlayer * player); We can set the shape of equalizer by setting gains of each band individually, or use an API like below to set it in one shot. void gst_player_equalizer_set_shape ( GstPlayer * player, int num_bands, double* gains);
(In reply to Sachin Kumar Chauhan from comment #2) > OK. We can limit ourselves to 3 and 10 band equalizers for now. These > equalizers have their bands at fixed frequency. 3 band @ 100 Hz, 1100 Hz and > 11KHz, and 10 band @ 29, 59, 119, 237, 474, 947, 1889, 3770, 7523, 15011 Hz. > So its not possible to set the center freq. With the n-band one it is :) > We can add an API for getting > center freq. For 3 band its 1100 Hz, and for 10 bands it will be the average > of 5th and 6th bands. I meant the center frequency of each band (and the number of bands). > void gst_player_equalizer_set (GstPlayer * player, GstPlayerEqualizerType > type); IMHO this one should just be part of the general settings, not something you can change at any time during playback. See the user agent setting and tick interval setting for example. > double gst_player_equalizer_get_band_gain ( GstPlayer * player, int > band_index); > > void gst_player_equalizer_set_band_gain ( GstPlayer * player, int > band_index, double gain); > > int gst_player_equalizer_get_center_freq ( GstPlayer * player); Need API to get the number of bands, and the per-band center frequency here. Also as the equalizer is just a setting on GstPlayer, I think all functions should be like gst_player_set_equalizer_band_gain() and not the other way around. > We can set the shape of equalizer by setting gains of each band > individually, or use an API like below to set it in one shot. > > void gst_player_equalizer_set_shape ( GstPlayer * player, int num_bands, > double* gains); You can only do that with the n-band equalizer though, which makes the API awkward. I would ignore that for now.
-- GitLab Migration Automatic Message -- This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/426.