diff --git a/effects.c b/effects.c index 876debd..8ec944e 100644 --- a/effects.c +++ b/effects.c @@ -440,35 +440,35 @@ static WidgetContainer eq_container[] = { }; static VBoxWidget wah_vbox[] = { - {"Wah", FALSE, set_wah_on_off, wah_container, G_N_ELEMENTS(wah_container)}, + {"Wah", FALSE, WAH_ON_OFF, WAH_POSITION, wah_container, G_N_ELEMENTS(wah_container)}, }; static VBoxWidget comp_vbox[] = { - {"Compressor", FALSE, set_comp_on_off, comp_container, G_N_ELEMENTS(comp_container)}, + {"Compressor", FALSE, COMP_ON_OFF, COMP_POSITION, comp_container, G_N_ELEMENTS(comp_container)}, }; static VBoxWidget dist_vbox[] = { - {"Distortion", FALSE, set_dist_on_off, dist_container, G_N_ELEMENTS(dist_container)}, + {"Distortion", FALSE, DIST_ON_OFF, DIST_POSITION, dist_container, G_N_ELEMENTS(dist_container)}, }; static VBoxWidget noisegate_vbox[] = { - {"Noisegate", FALSE, set_noisegate_on_off, noisegate_container, G_N_ELEMENTS(noisegate_container)}, + {"Noisegate", FALSE, NOISEGATE_ON_OFF, NOISEGATE_POSITION, noisegate_container, G_N_ELEMENTS(noisegate_container)}, }; static VBoxWidget chorusfx_vbox[] = { - {"Chorus/FX", FALSE, set_chorusfx_on_off, chorusfx_container, G_N_ELEMENTS(chorusfx_container)}, + {"Chorus/FX", FALSE, CHORUSFX_ON_OFF, CHORUSFX_POSITION, chorusfx_container, G_N_ELEMENTS(chorusfx_container)}, }; static VBoxWidget delay_vbox[] = { - {"Delay", FALSE, set_delay_on_off, delay_container, G_N_ELEMENTS(delay_container)}, + {"Delay", FALSE, DELAY_ON_OFF, DELAY_POSITION, delay_container, G_N_ELEMENTS(delay_container)}, }; static VBoxWidget reverb_vbox[] = { - {"Reverb", FALSE, set_reverb_on_off, reverb_container, G_N_ELEMENTS(reverb_container)}, + {"Reverb", FALSE, REVERB_ON_OFF, REVERB_POSITION, reverb_container, G_N_ELEMENTS(reverb_container)}, }; static VBoxWidget eq_vbox[] = { - {"EQ", FALSE, set_eq_on_off, eq_container, G_N_ELEMENTS(eq_container)}, + {"EQ", FALSE, EQ_ON_OFF, EQ_POSITION, eq_container, G_N_ELEMENTS(eq_container)}, }; VBoxes vboxes[] = { diff --git a/effects.h b/effects.h index fb96dee..c35905b 100644 --- a/effects.h +++ b/effects.h @@ -36,7 +36,8 @@ typedef struct { typedef struct { char *label; gboolean value; - void (*callback)(gboolean); + guint option; + guint position; WidgetContainer *widgets; gint widgets_amt; } VBoxWidget; diff --git a/gdigi.c b/gdigi.c index afb5ead..a18298b 100644 --- a/gdigi.c +++ b/gdigi.c @@ -154,7 +154,6 @@ void check_preset(struct usb_dev_handle *handle) */ void set_option(guint id, guint position, guint value) { -sleep(3); static char option[] = {0xF0, 0x00, 0x00, 0x10, 0x00, 0x5E, 0x02, 0x41, 0x00, 0x00, 0x00, /* ID */ 0x00, /* position */ @@ -222,16 +221,6 @@ sleep(3); } } -void set_wah_on_off(gboolean val) -{ - set_option(WAH_ON_OFF, WAH_POSITION, (val == TRUE) ? 1 : 0); -} - -void set_comp_on_off(gboolean val) -{ - set_option(COMP_ON_OFF, COMP_POSITION, (val == TRUE) ? 1 : 0); -} - /* x = 0 to 60 */ void switch_user_preset(int x) { @@ -254,47 +243,12 @@ void switch_system_preset(int x) send_data(switch_preset, sizeof(switch_preset)); } -void set_pickup_on_off(gboolean val) -{ - set_option(PICKUP_ON_OFF, PICKUP_POSITION, (val == TRUE) ? 1 : 0); -} - -void set_dist_on_off(gboolean val) -{ - set_option(DIST_ON_OFF, DIST_POSITION, (val == TRUE) ? 1 : 0); -} - /* level = 0 to 99 */ void set_preset_level(int level) { set_option(PRESET_LEVEL, PRESET_POSITION, level); } -void set_eq_on_off(gboolean val) -{ - set_option(EQ_ON_OFF, EQ_POSITION, (val == TRUE) ? 1 : 0); -} - -void set_noisegate_on_off(gboolean val) -{ - set_option(NOISEGATE_ON_OFF, NOISEGATE_POSITION, (val == TRUE) ? 1 : 0); -} - -void set_chorusfx_on_off(gboolean val) -{ - set_option(CHORUSFX_ON_OFF, CHORUSFX_POSITION, (val == TRUE) ? 1 : 0); -} - -void set_delay_on_off(gboolean val) -{ - set_option(DELAY_ON_OFF, DELAY_POSITION, (val == TRUE) ? 1 : 0); -} - -void set_reverb_on_off(gboolean val) -{ - set_option(REVERB_ON_OFF, REVERB_POSITION, (val == TRUE) ? 1 : 0); -} - /* x = 0 to 59 (preset number) */ void set_preset_name(int x, gchar *name) { diff --git a/gdigi.h b/gdigi.h index 03c5ffe..9f9a302 100644 --- a/gdigi.h +++ b/gdigi.h @@ -460,15 +460,6 @@ enum { #define USB_AUDIO_LEVEL 12307 void set_option(guint id, guint position, guint value); -void set_wah_on_off(gboolean val); -void set_comp_on_off(gboolean val); void switch_user_preset(int x); void switch_system_preset(int x); -void set_pickup_on_off(gboolean val); -void set_dist_on_off(gboolean val); void set_preset_level(int level); -void set_eq_on_off(gboolean val); -void set_noisegate_on_off(gboolean val); -void set_chorusfx_on_off(gboolean val); -void set_delay_on_off(gboolean val); -void set_reverb_on_off(gboolean val); diff --git a/gui.c b/gui.c index e63ee62..5a52a97 100644 --- a/gui.c +++ b/gui.c @@ -30,10 +30,12 @@ void value_changed_option_cb(GtkSpinButton *spinbutton, SettingsWidget *setting) set_option(setting->option, setting->position, val); } -void toggled_cb(GtkToggleButton *button, void (*callback)(gboolean)) +void toggled_cb(GtkToggleButton *button, VBoxWidget *widget) { - gboolean val = gtk_toggle_button_get_active(button); - callback(val); + g_return_if_fail(widget != NULL); + + guint val = gtk_toggle_button_get_active(button); + set_option(widget->option, widget->position, val); } GtkWidget *create_table(SettingsWidget *widgets, gint amt) @@ -57,11 +59,11 @@ GtkWidget *create_table(SettingsWidget *widgets, gint amt) return table; } -GtkWidget *create_on_off_button(const gchar *label, gboolean state, void (*callback)(int)) +GtkWidget *create_on_off_button(VBoxWidget *widget) { - GtkWidget *button = gtk_toggle_button_new_with_label(label); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), state); - g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(toggled_cb), callback); + GtkWidget *button = gtk_toggle_button_new_with_label(widget->label); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), widget->value); + g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(toggled_cb), widget); return button; } @@ -169,7 +171,7 @@ GtkWidget *create_vbox(VBoxWidget *widgets, gint amt) gtk_box_set_homogeneous(GTK_BOX(hbox), TRUE); for (x = 0; x