summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/gtkui/ddbequalizer.c4
-rw-r--r--plugins/gtkui/ddbequalizer.vala4
-rw-r--r--plugins/gtkui/eq.c132
-rw-r--r--plugins/supereq/supereq.c11
4 files changed, 112 insertions, 39 deletions
diff --git a/plugins/gtkui/ddbequalizer.c b/plugins/gtkui/ddbequalizer.c
index c1bdfeb8..db97cd45 100644
--- a/plugins/gtkui/ddbequalizer.c
+++ b/plugins/gtkui/ddbequalizer.c
@@ -407,6 +407,8 @@ static gboolean ddb_equalizer_real_button_press_event (GtkWidget* base, GdkEvent
if (ddb_equalizer_in_curve_area (self, (double) ((gint) (*event).x), (double) ((gint) (*event).y))) {
self->priv->curve_hook = TRUE;
ddb_equalizer_update_eq_drag (self, (double) ((gint) (*event).x), (double) ((gint) (*event).y));
+ self->priv->mouse_y = (gint) (*event).y;
+ gtk_widget_queue_draw ((GtkWidget*) self);
result = FALSE;
return result;
}
@@ -429,6 +431,8 @@ static gboolean ddb_equalizer_real_button_press_event (GtkWidget* base, GdkEvent
self->priv->preamp = (*event).y / ((double) (((GtkWidget*) self)->allocation.height - self->priv->margin_bottom));
g_signal_emit_by_name (self, "on-changed");
self->priv->preamp_hook = TRUE;
+ self->priv->mouse_y = (gint) (*event).y;
+ gtk_widget_queue_draw ((GtkWidget*) self);
}
result = FALSE;
return result;
diff --git a/plugins/gtkui/ddbequalizer.vala b/plugins/gtkui/ddbequalizer.vala
index adf10c71..f7912cfc 100644
--- a/plugins/gtkui/ddbequalizer.vala
+++ b/plugins/gtkui/ddbequalizer.vala
@@ -228,6 +228,8 @@ namespace Ddb {
{
curve_hook = true;
update_eq_drag ((int)event.x, (int)event.y);
+ mouse_y = (int)event.y;
+ queue_draw ();
return false;
}
@@ -240,6 +242,8 @@ namespace Ddb {
preamp = event.y / (double)(allocation.height - margin_bottom);
on_changed ();
preamp_hook = true;
+ mouse_y = (int)event.y;
+ queue_draw ();
}
return false;
diff --git a/plugins/gtkui/eq.c b/plugins/gtkui/eq.c
index e9f8ffb3..fda0a888 100644
--- a/plugins/gtkui/eq.c
+++ b/plugins/gtkui/eq.c
@@ -24,59 +24,124 @@
#include "../supereq/supereq.h"
#include "ddbequalizer.h"
+static GtkWidget *eqcont;
static GtkWidget *eqwin;
+static GtkWidget *eqenablebtn;
-float
+static inline float
db_to_amp (float dB) {
const float ln10=2.3025850929940002f;
return exp(ln10*dB/20.f);
}
-float
+static inline float
amp_to_db (float amp) {
return 20*log10 (amp);
}
-void
-graphic_value_changed (DdbEqualizer *widget)
-{
- printf ("graphic_value_changed\n");
- DB_supereq_dsp_t *eq = NULL;
+static DB_supereq_dsp_t *
+get_supereq_plugin (void) {
DB_dsp_t **plugs = deadbeef->plug_get_dsp_list ();
-
for (int i = 0; plugs[i]; i++) {
if (plugs[i]->plugin.id && !strcmp (plugs[i]->plugin.id, "supereq")) {
- eq = (DB_supereq_dsp_t *)plugs[i];
- for (int ii = 0; ii < 18; ii++) {
- eq->set_band (ii, db_to_amp (ddb_equalizer_get_band (widget, ii)));
- }
- eq->set_preamp (db_to_amp (ddb_equalizer_get_preamp (widget)));
- break;
+ return (DB_supereq_dsp_t *)plugs[i];
+ }
+ }
+ return NULL;
+}
+
+void
+eq_value_changed (DdbEqualizer *widget)
+{
+ DB_supereq_dsp_t *eq = get_supereq_plugin ();
+ for (int i = 0; i < 18; i++) {
+ eq->set_band (i, db_to_amp (ddb_equalizer_get_band (widget, i)));
+ }
+ eq->set_preamp (db_to_amp (ddb_equalizer_get_preamp (widget)));
+}
+
+void
+on_enable_toggled (GtkToggleButton *togglebutton,
+ gpointer user_data) {
+ DB_supereq_dsp_t *eq = get_supereq_plugin ();
+ eq->dsp.enable (gtk_toggle_button_get_active (togglebutton));
+}
+
+void
+on_zero_all_clicked (GtkButton *button,
+ gpointer user_data) {
+ if (eqwin) {
+ DB_supereq_dsp_t *eq = get_supereq_plugin ();
+ eq->set_preamp (1);
+ ddb_equalizer_set_preamp (DDB_EQUALIZER (eqwin), 0);
+ for (int i = 0; i < 18; i++) {
+ ddb_equalizer_set_band (DDB_EQUALIZER (eqwin), i, 0);
+ eq->set_band (i, 1);
}
+ gdk_window_invalidate_rect (eqwin->window, NULL, FALSE);
}
}
void
+on_save_preset_clicked (GtkButton *button,
+ gpointer user_data) {
+}
+
+void
+on_load_preset_clicked (GtkButton *button,
+ gpointer user_data) {
+}
+
+void
eq_window_show (void) {
- if (!eqwin) {
+ if (!eqcont) {
+ eqcont = gtk_vbox_new (FALSE, 8);
+ GtkWidget *parent= lookup_widget (mainwin, "plugins_bottom_vbox");
+ gtk_box_pack_start (GTK_BOX (parent), eqcont, FALSE, FALSE, 0);
+
+ GtkWidget *buttons = gtk_hbox_new (FALSE, 8);
+ gtk_container_set_border_width (GTK_CONTAINER (buttons), 3);
+ gtk_widget_show (buttons);
+ gtk_box_pack_start (GTK_BOX (eqcont), buttons, FALSE, FALSE, 0);
+
+ GtkWidget *button;
+
+ eqenablebtn = button = gtk_check_button_new_with_label ("Enable");
+ gtk_widget_show (button);
+ gtk_box_pack_start (GTK_BOX (buttons), button, FALSE, FALSE, 0);
+ g_signal_connect ((gpointer) button, "toggled",
+ G_CALLBACK (on_enable_toggled),
+ NULL);
+
+ button = gtk_button_new_with_label ("Zero All");
+ gtk_widget_show (button);
+ gtk_box_pack_start (GTK_BOX (buttons), button, FALSE, FALSE, 0);
+ g_signal_connect ((gpointer) button, "clicked",
+ G_CALLBACK (on_zero_all_clicked),
+ NULL);
+
+ button = gtk_button_new_with_label ("Save Preset");
+ gtk_widget_show (button);
+ gtk_box_pack_start (GTK_BOX (buttons), button, FALSE, FALSE, 0);
+ g_signal_connect ((gpointer) button, "clicked",
+ G_CALLBACK (on_save_preset_clicked),
+ NULL);
+
+ button = gtk_button_new_with_label ("Load Preset");
+ gtk_widget_show (button);
+ gtk_box_pack_start (GTK_BOX (buttons), button, FALSE, FALSE, 0);
+ g_signal_connect ((gpointer) button, "clicked",
+ G_CALLBACK (on_load_preset_clicked),
+ NULL);
+
eqwin = GTK_WIDGET (ddb_equalizer_new());
- g_signal_connect (eqwin, "on_changed", G_CALLBACK (graphic_value_changed), 0);
+ g_signal_connect (eqwin, "on_changed", G_CALLBACK (eq_value_changed), 0);
gtk_widget_set_size_request (eqwin, -1, 200);
- int i;
- DB_supereq_dsp_t *eq = NULL;
- DB_dsp_t **plugs = deadbeef->plug_get_dsp_list ();
- // find eq plugin
- for (i = 0; plugs[i]; i++) {
- if (plugs[i]->plugin.id && !strcmp (plugs[i]->plugin.id, "supereq")) {
- eq = (DB_supereq_dsp_t *)plugs[i];
- break;
- }
- }
+ DB_supereq_dsp_t *eq = get_supereq_plugin ();
- printf ("init eq widget\n");
ddb_equalizer_set_preamp (DDB_EQUALIZER (eqwin), amp_to_db (eq->get_preamp ()));
- for (i = 0; i < 18; i++) {
+ for (int i = 0; i < 18; i++) {
if (eq) {
float val = eq->get_band (i);
ddb_equalizer_set_band (DDB_EQUALIZER (eqwin), i, amp_to_db (val));
@@ -84,17 +149,16 @@ eq_window_show (void) {
}
gtk_widget_show (eqwin);
-
- GtkWidget *cont = lookup_widget (mainwin, "plugins_bottom_vbox");
- gtk_box_pack_start (GTK_BOX (cont), eqwin, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (eqcont), eqwin, TRUE, TRUE, 0);
}
- gtk_widget_show (eqwin);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (eqenablebtn), deadbeef->conf_get_int ("supereq.enable", 0));
+ gtk_widget_show (eqcont);
}
void
eq_window_hide (void) {
- if (eqwin) {
- gtk_widget_hide (eqwin);
+ if (eqcont) {
+ gtk_widget_hide (eqcont);
}
}
diff --git a/plugins/supereq/supereq.c b/plugins/supereq/supereq.c
index 6184a307..972c1798 100644
--- a/plugins/supereq/supereq.c
+++ b/plugins/supereq/supereq.c
@@ -192,12 +192,13 @@ supereq_reset (void) {
void
supereq_enable (int e) {
- deadbeef->conf_set_int ("supereq.enable", e);
-
- if (e && !enabled) {
- supereq_reset ();
+ if (e != enabled) {
+ deadbeef->conf_set_int ("supereq.enable", e);
+ if (e && !enabled) {
+ supereq_reset ();
+ }
+ enabled = e;
}
- enabled = e;
}
int