diff options
-rw-r--r-- | plugins/gtkui/eq.c | 40 | ||||
-rw-r--r-- | plugins/supereq/supereq.c | 51 | ||||
-rw-r--r-- | plugins/supereq/supereq.h | 31 |
3 files changed, 40 insertions, 82 deletions
diff --git a/plugins/gtkui/eq.c b/plugins/gtkui/eq.c index c7a82dea..bed2f970 100644 --- a/plugins/gtkui/eq.c +++ b/plugins/gtkui/eq.c @@ -22,7 +22,6 @@ #include <stdlib.h> #include "gtkui.h" #include "support.h" -#include "../supereq/supereq.h" #include "ddbequalizer.h" static GtkWidget *eqcont; @@ -58,11 +57,10 @@ eq_value_changed (DdbEqualizer *widget) { DB_dsp_instance_t *eq = get_supereq (); if (eq) { - DB_supereq_dsp_t *plugin = (DB_supereq_dsp_t *)eq->plugin; for (int i = 0; i < 18; i++) { - plugin->set_band (eq, i, db_to_amp (ddb_equalizer_get_band (widget, i))); + eq->plugin->set_param (eq, i+1, db_to_amp (ddb_equalizer_get_band (widget, i))); } - plugin->set_preamp (eq, db_to_amp (ddb_equalizer_get_preamp (widget))); + eq->plugin->set_param (eq, 0, db_to_amp (ddb_equalizer_get_preamp (widget))); } } @@ -71,8 +69,7 @@ on_enable_toggled (GtkToggleButton *togglebutton, gpointer user_data) { DB_dsp_instance_t *eq = get_supereq (); if (eq) { - DB_supereq_dsp_t *plugin = (DB_supereq_dsp_t *)eq->plugin; - plugin->dsp.enable (eq, gtk_toggle_button_get_active (togglebutton) ? 1 : 0); + eq->plugin->enable (eq, gtk_toggle_button_get_active (togglebutton) ? 1 : 0); } } @@ -82,12 +79,11 @@ on_zero_all_clicked (GtkButton *button, if (eqwin) { DB_dsp_instance_t *eq = get_supereq (); if (eq) { - DB_supereq_dsp_t *plugin = (DB_supereq_dsp_t *)eq->plugin; - plugin->set_preamp (eq, 1); + eq->plugin->set_param (eq, 0, 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); - plugin->set_band (eq, i, 1); + eq->plugin->set_param (eq, i+1, 1); } gdk_window_invalidate_rect (eqwin->window, NULL, FALSE); } @@ -100,8 +96,7 @@ on_zero_preamp_clicked (GtkButton *button, if (eqwin) { DB_dsp_instance_t *eq = get_supereq (); if (eq) { - DB_supereq_dsp_t *plugin = (DB_supereq_dsp_t *)eq->plugin; - plugin->set_preamp (eq, 1); + eq->plugin->set_param (eq, 0, 1); ddb_equalizer_set_preamp (DDB_EQUALIZER (eqwin), 0); gdk_window_invalidate_rect (eqwin->window, NULL, FALSE); } @@ -114,10 +109,9 @@ on_zero_bands_clicked (GtkButton *button, if (eqwin) { DB_dsp_instance_t *eq = get_supereq (); if (eq) { - DB_supereq_dsp_t *plugin = (DB_supereq_dsp_t *)eq->plugin; for (int i = 0; i < 18; i++) { ddb_equalizer_set_band (DDB_EQUALIZER (eqwin), i, 0); - plugin->set_band (eq, i, 1); + eq->plugin->set_param (eq, i+1, 1); } gdk_window_invalidate_rect (eqwin->window, NULL, FALSE); } @@ -149,11 +143,10 @@ on_save_preset_clicked (GtkButton *button, if (fp) { DB_dsp_instance_t *eq = get_supereq (); if (eq) { - DB_supereq_dsp_t *plugin = (DB_supereq_dsp_t *)eq->plugin; for (int i = 0; i < 18; i++) { - fprintf (fp, "%f\n", amp_to_db (plugin->get_band (eq, i))); + fprintf (fp, "%f\n", amp_to_db (eq->plugin->get_param (eq, i+1))); } - fprintf (fp, "%f\n", amp_to_db (plugin->get_preamp (eq))); + fprintf (fp, "%f\n", amp_to_db (eq->plugin->get_param (eq, 0))); } fclose (fp); } @@ -208,12 +201,11 @@ on_load_preset_clicked (GtkButton *button, // apply and save config DB_dsp_instance_t *eq = get_supereq (); if (eq) { - DB_supereq_dsp_t *plugin = (DB_supereq_dsp_t *)eq->plugin; - plugin->set_preamp (eq, db_to_amp (vals[18])); + eq->plugin->set_param (eq, 0, db_to_amp (vals[18])); ddb_equalizer_set_preamp (DDB_EQUALIZER (eqwin), vals[18]); for (int i = 0; i < 18; i++) { ddb_equalizer_set_band (DDB_EQUALIZER (eqwin), i, vals[i]); - plugin->set_band (eq, i, db_to_amp (vals[i])); + eq->plugin->set_param (eq, i+1, db_to_amp (vals[i])); } gdk_window_invalidate_rect (eqwin->window, NULL, FALSE); deadbeef->conf_save (); @@ -272,12 +264,11 @@ on_import_fb2k_preset_clicked (GtkButton *button, // apply and save config DB_dsp_instance_t *eq = get_supereq (); if (eq) { - DB_supereq_dsp_t *plugin = (DB_supereq_dsp_t *)eq->plugin; - plugin->set_preamp (eq, 1); + eq->plugin->set_param (eq, 0, 1); ddb_equalizer_set_preamp (DDB_EQUALIZER (eqwin), 0); for (int i = 0; i < 18; i++) { ddb_equalizer_set_band (DDB_EQUALIZER (eqwin), i, vals[i]); - plugin->set_band (eq, i, db_to_amp (vals[i])); + eq->plugin->set_param (eq, i+1, db_to_amp (vals[i])); } gdk_window_invalidate_rect (eqwin->window, NULL, FALSE); deadbeef->conf_save (); @@ -363,11 +354,10 @@ eq_window_show (void) { gtk_widget_set_size_request (eqwin, -1, 200); if (eq) { - DB_supereq_dsp_t *plugin = (DB_supereq_dsp_t *)eq->plugin; - ddb_equalizer_set_preamp (DDB_EQUALIZER (eqwin), amp_to_db (plugin->get_preamp (eq))); + ddb_equalizer_set_preamp (DDB_EQUALIZER (eqwin), amp_to_db (eq->plugin->get_param (eq, 0))); for (int i = 0; i < 18; i++) { if (eq) { - float val = plugin->get_band (eq, i); + float val = eq->plugin->get_param (eq, i+1); ddb_equalizer_set_band (DDB_EQUALIZER (eqwin), i, amp_to_db (val)); } } diff --git a/plugins/supereq/supereq.c b/plugins/supereq/supereq.c index 9ce7b9f8..e7cfa6cb 100644 --- a/plugins/supereq/supereq.c +++ b/plugins/supereq/supereq.c @@ -20,11 +20,10 @@ #include <string.h> #include <stdlib.h> #include "../../deadbeef.h" -#include "supereq.h" #include "Equ.h" static DB_functions_t *deadbeef; -static DB_supereq_dsp_t plugin; +static DB_dsp_t plugin; typedef struct { DB_dsp_instance_t inst; @@ -221,7 +220,7 @@ supereq_get_param (DB_dsp_instance_t *inst, int p) { DB_dsp_instance_t* supereq_open (void) { ddb_supereq_instance_t *supereq = malloc (sizeof (ddb_supereq_instance_t)); - DDB_INIT_DSP_INSTANCE (supereq,ddb_supereq_instance_t,&plugin.dsp); + DDB_INIT_DSP_INSTANCE (supereq,ddb_supereq_instance_t,&plugin); equ_init (&supereq->state, 14); supereq->paramsroot = paramlist_alloc (); @@ -252,29 +251,29 @@ supereq_close (DB_dsp_instance_t *inst) { free (inst); } -static DB_supereq_dsp_t plugin = { - .dsp.plugin.api_vmajor = DB_API_VERSION_MAJOR, - .dsp.plugin.api_vminor = DB_API_VERSION_MINOR, - .dsp.plugin.version_major = 1, - .dsp.plugin.version_minor = 0, - .dsp.plugin.type = DB_PLUGIN_DSP, - .dsp.plugin.id = "supereq", - .dsp.plugin.name = "SuperEQ", - .dsp.plugin.descr = "equalizer plugin using SuperEQ library by Naoki Shibata", - .dsp.plugin.author = "Alexey Yakovenko", - .dsp.plugin.email = "waker@users.sourceforge.net", - .dsp.plugin.website = "http://deadbeef.sf.net", - .dsp.plugin.start = supereq_plugin_start, - .dsp.plugin.stop = supereq_plugin_stop, - .dsp.open = supereq_open, - .dsp.close = supereq_close, - .dsp.process = supereq_process, - .dsp.reset = supereq_reset, - .dsp.enable = supereq_enable, - .dsp.num_params = supereq_num_params, - .dsp.get_param_name = supereq_get_param_name, - .dsp.set_param = supereq_set_param, - .dsp.get_param = supereq_get_param, +static DB_dsp_t plugin = { + .plugin.api_vmajor = DB_API_VERSION_MAJOR, + .plugin.api_vminor = DB_API_VERSION_MINOR, + .plugin.version_major = 1, + .plugin.version_minor = 0, + .plugin.type = DB_PLUGIN_DSP, + .plugin.id = "supereq", + .plugin.name = "SuperEQ", + .plugin.descr = "equalizer plugin using SuperEQ library by Naoki Shibata", + .plugin.author = "Alexey Yakovenko", + .plugin.email = "waker@users.sourceforge.net", + .plugin.website = "http://deadbeef.sf.net", + .plugin.start = supereq_plugin_start, + .plugin.stop = supereq_plugin_stop, + .open = supereq_open, + .close = supereq_close, + .process = supereq_process, + .reset = supereq_reset, + .enable = supereq_enable, + .num_params = supereq_num_params, + .get_param_name = supereq_get_param_name, + .set_param = supereq_set_param, + .get_param = supereq_get_param, }; DB_plugin_t * diff --git a/plugins/supereq/supereq.h b/plugins/supereq/supereq.h deleted file mode 100644 index 2588df91..00000000 --- a/plugins/supereq/supereq.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - DeaDBeeF - ultimate music player for GNU/Linux systems with X11 - Copyright (C) 2009-2010 Alexey Yakovenko <waker@users.sourceforge.net> - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#ifndef __SUPEREQ_H -#define __SUPEREQ_H - -typedef struct DB_supereq_dsp_s { - DB_dsp_t dsp; - float (*get_band) (DB_dsp_instance_t *inst, int band); - void (*set_band) (DB_dsp_instance_t *inst, int band, float value); - float (*get_preamp) (DB_dsp_instance_t *inst); - void (*set_preamp) (DB_dsp_instance_t *inst, float value); -} DB_supereq_dsp_t; - -#endif |