summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-03-20 19:11:31 +0100
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-03-20 19:11:31 +0100
commit175c96d5246f3bbdb8ddd5c9379191d030a9848b (patch)
treec04a18c2d15c2d80d228853296eef0cb76556c52 /plugins
parenteef7400dc4c55adf166a09142d859900d537c803 (diff)
save/load EQ config
Diffstat (limited to 'plugins')
-rw-r--r--plugins/gtkui/eq.c50
-rw-r--r--plugins/gtkui/eq.h3
-rw-r--r--plugins/gtkui/gtkui.c1
-rw-r--r--plugins/supereq/supereq.c11
4 files changed, 46 insertions, 19 deletions
diff --git a/plugins/gtkui/eq.c b/plugins/gtkui/eq.c
index 48b66f5c..a02b2bc0 100644
--- a/plugins/gtkui/eq.c
+++ b/plugins/gtkui/eq.c
@@ -24,6 +24,7 @@
#include "../supereq/supereq.h"
static GtkWidget *eqwin;
+static GtkWidget *sliders[18];
float
db_to_amp (float dB) {
@@ -60,6 +61,28 @@ eq_init_widgets (GtkWidget *container) {
gtk_widget_show (hbox);
gtk_container_add (GTK_CONTAINER (container), hbox);
+ for (i = 0; i < 18; i++) {
+ GtkWidget *scale = sliders[i] = gtk_vscale_new_with_range (-20, 20, 1);
+ gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_BOTTOM);
+ gtk_scale_set_draw_value (GTK_SCALE (scale), TRUE);
+ gtk_range_set_inverted (GTK_RANGE (scale), TRUE);
+ gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED);
+ g_signal_connect (scale, "value_changed", G_CALLBACK (eq_value_changed), (gpointer)(intptr_t)i);
+ gtk_widget_show (scale);
+ gtk_box_pack_start (GTK_BOX (hbox), scale, FALSE, FALSE, 0);
+ }
+}
+
+void
+eq_window_show (void) {
+ if (!eqwin) {
+ eqwin = gtk_hbox_new (FALSE, 0);
+ gtk_widget_set_size_request (eqwin, -1, 200);
+ eq_init_widgets (eqwin);
+ GtkWidget *cont = lookup_widget (mainwin, "vbox1");
+ gtk_box_pack_start (GTK_BOX (cont), eqwin, FALSE, FALSE, 0);
+ }
+ int i;
DB_supereq_dsp_t *eq = NULL;
DB_dsp_t **plugs = deadbeef->plug_get_dsp_list ();
// find eq plugin
@@ -71,11 +94,7 @@ eq_init_widgets (GtkWidget *container) {
}
for (i = 0; i < 18; i++) {
- GtkWidget *scale = gtk_vscale_new_with_range (-20, 20, 1);
- gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_BOTTOM);
- gtk_scale_set_draw_value (GTK_SCALE (scale), TRUE);
- gtk_range_set_inverted (GTK_RANGE (scale), TRUE);
- gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED);
+ GtkWidget *scale = sliders[i];
if (eq) {
float val = eq->get_band (i);
val = amp_to_db (val);
@@ -87,20 +106,6 @@ eq_init_widgets (GtkWidget *container) {
}
gtk_range_set_value (GTK_RANGE (scale), val);
}
- g_signal_connect (scale, "value_changed", G_CALLBACK (eq_value_changed), (gpointer)(intptr_t)i);
- gtk_widget_show (scale);
- gtk_box_pack_start (GTK_BOX (hbox), scale, FALSE, FALSE, 0);
- }
-}
-
-void
-eq_window_show (void) {
- if (!eqwin) {
- eqwin = gtk_hbox_new (FALSE, 0);
- gtk_widget_set_size_request (eqwin, -1, 200);
- eq_init_widgets (eqwin);
- GtkWidget *cont = lookup_widget (mainwin, "vbox1");
- gtk_box_pack_start (GTK_BOX (cont), eqwin, FALSE, FALSE, 0);
}
gtk_widget_show (eqwin);
}
@@ -111,3 +116,10 @@ eq_window_hide (void) {
gtk_widget_hide (eqwin);
}
}
+
+void
+eq_window_destroy (void) {
+ gtk_widget_destroy (eqwin);
+ eqwin = NULL;
+ memset (sliders, 0, sizeof (sliders));
+}
diff --git a/plugins/gtkui/eq.h b/plugins/gtkui/eq.h
index 1a3f02e5..6f063cb3 100644
--- a/plugins/gtkui/eq.h
+++ b/plugins/gtkui/eq.h
@@ -26,4 +26,7 @@ eq_window_show (void);
void
eq_window_hide (void);
+void
+eq_window_destroy (void);
+
#endif
diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c
index 7c34c967..adeccc7f 100644
--- a/plugins/gtkui/gtkui.c
+++ b/plugins/gtkui/gtkui.c
@@ -797,6 +797,7 @@ gtkui_thread (void *ctx) {
gtk_main ();
cover_art_free ();
+ eq_window_destroy ();
gtk_widget_destroy (mainwin);
gtk_widget_destroy (searchwin);
#if HAVE_NOTIFY
diff --git a/plugins/supereq/supereq.c b/plugins/supereq/supereq.c
index f9f98940..ed9bc43b 100644
--- a/plugins/supereq/supereq.c
+++ b/plugins/supereq/supereq.c
@@ -16,6 +16,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+#include <stdio.h>
#include "../../deadbeef.h"
#include "supereq.h"
@@ -41,6 +42,13 @@ static uintptr_t mutex = 0;
int
supereq_plugin_start (void) {
+ // load bands from config
+ for (int i = 0; i < 18; i++) {
+ char key[100];
+ snprintf (key, sizeof (key), "eq.band%d", i);
+ lbands[i] = rbands[i] = deadbeef->conf_get_float (key, 1);
+ }
+
equ_init (14);
paramsroot = paramlist_alloc ();
last_srate = 44100;
@@ -113,6 +121,9 @@ supereq_set_band (int band, float value) {
lbands[band] = rbands[band] = value;
deadbeef->mutex_unlock (mutex);
params_changed = 1;
+ char key[100];
+ snprintf (key, sizeof (key), "eq.band%d", band);
+ deadbeef->conf_set_float (key, value);
}
static DB_supereq_dsp_t plugin = {