From 225383310502e2c2a601a0801a29bf40eb9efab1 Mon Sep 17 00:00:00 2001 From: Tim LaBerge Date: Sun, 26 Feb 2012 08:37:51 -0800 Subject: [PATCH] Add retrieval of global settings. Start LFO. --- effects.c | 72 ++++++++++++++++++++++++++++++++++++++++++---------- gdigi.c | 48 +++++++++++++++++++++++++++++++++++ gdigi.h | 6 ++++- gui.c | 11 ++++++-- preset_xml.c | 8 +----- 5 files changed, 121 insertions(+), 24 deletions(-) diff --git a/effects.c b/effects.c index 8a4be38..50ffd13 100644 --- a/effects.c +++ b/effects.c @@ -305,6 +305,14 @@ static EffectValues values_0_to_99 = { .min = 0.0, .max = 99.0, .type = VALUE_TYPE_PLAIN, }; +static EffectValues values_0_to_255 = { + .min = 0.0, .max = 255.0, .type = VALUE_TYPE_PLAIN, +}; + +static EffectValues values_0_to_29 = { + .min = 0.0, .max = 29.0, .type = VALUE_TYPE_PLAIN, +}; + static EffectValues values_1_to_4 = { .min = 0.0, .max = 3.0, .type = VALUE_TYPE_OFFSET, @@ -708,9 +716,14 @@ static EffectValues values_rp_mix = { .min = 0.0, .max = 100.0, .type = VALUE_TYPE_PLAIN, }; -static EffectSettings usb_settings[] = { - {"USB/RP Mix", USB_AUDIO_PLAYBACK_MIX, USB_POSITION, &values_rp_mix}, - {"USB Level", USB_AUDIO_LEVEL, USB_POSITION, &values_m12_to_24}, +static EffectSettings global_settings[] = { + {"USB/RP Mix", USB_AUDIO_PLAYBACK_MIX, GLOBAL_POSITION, &values_rp_mix}, + {"USB Level", USB_AUDIO_LEVEL, GLOBAL_POSITION, &values_m12_to_24}, + {"GUI Mode", GUI_MODE_ON_OFF, GLOBAL_POSITION, &values_on_off}, + {"Tuning Reference", TUNING_REFERENCE, GLOBAL_POSITION, &values_0_to_29}, + {"Pedal Position", EXP_PEDAL_LEVEL, USB_POSITION, &values_0_to_255}, + {"Stomp", STOMP_MODE, GLOBAL_POSITION, &values_on_off}, + {"Wah Pedal Position", WAH_PEDAL_POSITION, WAH_POSITION, &values_0_to_99}, }; static EffectSettings misc_settings[] = { @@ -1556,6 +1569,20 @@ static EffectSettings gnx3k_reverb_settings[] = { {"Level", REVERB_LEVEL, REVERB_POSITION, &values_0_to_99}, }; +static EffectSettings lfo1_settings[] = { + {"Heel", LFO_MIN, LFO1_POSITION, &values_0_to_99}, + {"Toe", LFO_MAX, LFO1_POSITION, &values_0_to_99}, + {"Waveform", LFO_WAVEFORM, LFO1_POSITION, &values_waveform}, + {"Speed(HZ)", LFO_SPEED, LFO1_POSITION, &values_lfo_speed}, +}; + +static EffectSettings lfo2_settings[] = { + {"Heel", LFO_MIN, REVERB_POSITION, &values_0_to_99}, + {"Toe", LFO_MAX, REVERB_POSITION, &values_0_to_99}, + {"Waveform", LFO_WAVEFORM, REVERB_POSITION, &values_waveform}, + {"Speed(HZ)", LFO_SPEED, REVERB_POSITION, &values_lfo_speed}, +}; + static EffectSettings reverb_lex_settings[] = { {"Predelay", REVERB_PREDELAY, REVERB_POSITION, &values_0_to_15}, {"Decay", REVERB_DECAY, REVERB_POSITION, &values_0_to_99}, @@ -1592,8 +1619,8 @@ static EffectGroup gnx3k_amp_channel_group[] = { }; /** \todo it's not part of Preset, but should appear in GUI */ -static EffectGroup usb_group[] = { - {-1, NULL, usb_settings, G_N_ELEMENTS(usb_settings)}, +static EffectGroup global_group[] = { + {-1, NULL, global_settings, G_N_ELEMENTS(global_settings)}, }; static EffectGroup misc_group[] = { @@ -1915,6 +1942,19 @@ static EffectGroup rp355_chorusfx_group[] = { {CHORUS_TYPE_OCTAVER, "Octaver", chorusfx_octaver_settings, G_N_ELEMENTS(chorusfx_octaver_settings)}, }; +#define LFO_POSID_TO_TYPE(_a, _b) ((_a << 16) | (_b)) +static EffectGroup rp355_lfo1_group[] = { + {LFO_POSID_TO_TYPE(CHORUSFX_POSITION, CHORUS_LEVEL), "Chorus Level", lfo1_settings, G_N_ELEMENTS(lfo1_settings)}, + {LFO_POSID_TO_TYPE(DIST_POSITION, DIST_ON_OFF), "Distortion On/Off", lfo1_settings, G_N_ELEMENTS(lfo1_settings)}, + {LFO_POSID_TO_TYPE(DIST_POSITION, DIST_SCREAMER_DRIVE), "Distortion Screamer Drive", lfo1_settings, G_N_ELEMENTS(lfo1_settings)}, + {LFO_POSID_TO_TYPE(DIST_POSITION, DIST_SCREAMER_TONE), "Distortion Screamer Tone", lfo1_settings, G_N_ELEMENTS(lfo1_settings)}, + {LFO_POSID_TO_TYPE(DIST_POSITION, DIST_SCREAMER_LVL), "Distortion Screamer Level", lfo1_settings, G_N_ELEMENTS(lfo1_settings)}, + {LFO_POSID_TO_TYPE(DIST_POSITION, DIST_808_OVERDRIVE), "Distortion 808 Overdrive", lfo1_settings, G_N_ELEMENTS(lfo1_settings)}, + {LFO_POSID_TO_TYPE(DIST_POSITION, DIST_808_TONE), "Distortion 808 Tone", lfo1_settings, G_N_ELEMENTS(lfo1_settings)}, + {LFO_POSID_TO_TYPE(DIST_POSITION, DIST_808_LVL), "Distortion 808 Level", lfo1_settings, G_N_ELEMENTS(lfo1_settings)}, + }; + + static EffectGroup rp500_chorusfx_group[] = { {CHORUS_TYPE_CE, "CE Chorus", chorusfx_ce_settings, G_N_ELEMENTS(chorusfx_ce_settings)}, {CHORUS_TYPE_TC, "TC Chorus", chorusfx_tc_settings, G_N_ELEMENTS(chorusfx_tc_settings)}, @@ -2784,6 +2824,10 @@ static Effect rp355_chorusfx_effect[] = { {NULL, CHORUSFX_ON_OFF,CHORUSFX_TYPE, CHORUSFX_POSITION, rp355_chorusfx_group, G_N_ELEMENTS(rp355_chorusfx_group)}, }; +static Effect rp355_lfo1_effect[] = { + {NULL, -1, LFO_TYPE, LFO1_POSITION, rp355_lfo1_group, G_N_ELEMENTS(rp355_lfo1_group)}, +}; + static Effect rp500_chorusfx_effect[] = { {NULL, CHORUSFX_ON_OFF, CHORUSFX_TYPE, CHORUSFX_POSITION, rp500_chorusfx_group, G_N_ELEMENTS(rp500_chorusfx_group)}, }; @@ -2899,8 +2943,8 @@ static Effect rp500_eq_effect[] = { {"Enable Equalizer", EQ_ENABLE, -1, EQ_A_POSITION, rp500_eq_group, G_N_ELEMENTS(rp500_eq_group)}, }; -static Effect usb_effect[] = { - {NULL, -1, USB_AUDIO_LEVEL, USB_POSITION, usb_group, G_N_ELEMENTS(usb_group)}, +static Effect global_effect[] = { + {NULL, -1, USB_AUDIO_LEVEL, USB_POSITION, global_group, G_N_ELEMENTS(global_group)}, }; static Effect pickup_misc_effect[] = { @@ -2986,7 +3030,8 @@ static EffectList rp355_effects[] = { {"Chorus/FX", rp355_chorusfx_effect, G_N_ELEMENTS(rp355_chorusfx_effect)}, {"Delay", rp355_delay_effect, G_N_ELEMENTS(rp355_delay_effect)}, {"Reverb", reverb_effect, G_N_ELEMENTS(reverb_effect)}, - {"USB settings", usb_effect, G_N_ELEMENTS(usb_effect)}, + {"Global Settings", global_effect, G_N_ELEMENTS(global_effect)}, + {"LFO1", rp355_lfo1_effect, G_N_ELEMENTS(rp355_lfo1_effect)}, }; static EffectList rp500_effects[] = { @@ -3078,7 +3123,7 @@ static EffectPage rp255_pages[] = { }; static EffectPage rp355_pages[] = { - {"Effects", rp355_effects, G_N_ELEMENTS(rp355_effects), 2}, + {"Effects", rp355_effects, G_N_ELEMENTS(rp355_effects), 3}, }; static EffectPage rp500_pages[] = { @@ -4087,17 +4132,15 @@ static void effect_settings_free(EffectSettings *settings) * * \return ModifierGroup which must be freed using modifier_group_free. **/ -ModifierGroup *modifier_linkable_list() +ModifierGroup *modifier_linkable_list(GString *msg) { guint group_id; guint count; guint i; - send_message(REQUEST_MODIFIER_LINKABLE_LIST, "\x00\x01", 2); + //send_message(REQUEST_MODIFIER_LINKABLE_LIST, "\x00\x01", 2); - GString *data = get_message_by_id(RECEIVE_MODIFIER_LINKABLE_LIST); - - unsigned char *str = (unsigned char*)data->str; + unsigned char *str = (unsigned char*)msg->str; group_id = (str[8] << 8) | str[9]; count = (str[10] << 8) | str[11]; @@ -4135,6 +4178,7 @@ ModifierGroup *modifier_linkable_list() modifier_group->group = group; modifier_group->group_amt = count; + return modifier_group; } diff --git a/gdigi.c b/gdigi.c index 9b2e1c2..76fd240 100644 --- a/gdigi.c +++ b/gdigi.c @@ -274,12 +274,59 @@ void push_message(GString *msg) } else { g_message("%d %d moved to %d %d", str[9], str[10], str[11], str[12]); } + case NOTIFY_MODIFIER_GROUP_CHANGED: + { + int i; + printf("\n"); + for (i = 0; i < msg->len; i++) { + printf(" %02x", (unsigned char) str[i]); + } + printf("\n"); + g_message("Modifier group id %d changed", + (str[9] << 8) | (str[10])); break; + } default: g_message("Received unhandled device notification 0x%x", str[11]); } g_string_free(msg, TRUE); return; + case RECEIVE_GLOBAL_PARAMETERS: + unpack_message(msg); + gint tot, n, x; + tot = (unsigned char)msg->str[9]; + for (n = 0; n < msg->len; n++) { + printf("%02x ",(unsigned char) msg->str[n]); + } + printf("\n"); + + n = 0; + x = 10; + do { + param = setting_param_new_from_data(&msg->str[x], &x); + g_message("Received global param ID: %d Position: %d Value: %d", + param->id, param->position, param->value); + setting_param_free(param); + } while ( (x < msg->len) && n < tot); + + g_string_free(msg, TRUE); + return; + + + case RECEIVE_MODIFIER_LINKABLE_LIST: + unpack_message(msg); + tot = (unsigned char)msg->str[9]; + for (n = 0; n < msg->len; n++) { + printf("%02x ",(unsigned char) msg->str[n]); + } + printf("\n"); + + modifier_linkable_list(msg); + + g_string_free(msg, TRUE); + return; + + default: g_mutex_lock(message_queue_mutex); g_queue_push_tail(message_queue, msg); @@ -664,6 +711,7 @@ void set_option(guint id, guint position, guint value) ((id & 0xFF00) >> 8), (id & 0xFF), position); append_value(msg, value); + g_message("Sending id %d position %d value %d", id, position, value); send_message(RECEIVE_PARAMETER_VALUE, msg->str, msg->len); g_string_free(msg, TRUE); } diff --git a/gdigi.h b/gdigi.h index 1a46e4b..45aece8 100644 --- a/gdigi.h +++ b/gdigi.h @@ -964,10 +964,14 @@ enum { }; #define USB_POSITION 0 +#define GLOBAL_POSITION 0 + +#define TUNING_REFERENCE 12288 #define USB_AUDIO_PLAYBACK_MIX 12297 #define USB_AUDIO_LEVEL 12307 - #define GUI_MODE_ON_OFF 12298 +#define EXP_PEDAL_LEVEL 12300 +#define STOMP_MODE 12370 #endif /* DOXYGEN_SHOULD_SKIP_THIS */ diff --git a/gui.c b/gui.c index 2179207..c3048c8 100644 --- a/gui.c +++ b/gui.c @@ -1338,8 +1338,15 @@ void gui_create(Device *device) g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(gtk_main_quit), NULL); /* Not part of the preset, but update from the device. */ - get_option(USB_AUDIO_LEVEL, USB_POSITION); - get_option(USB_AUDIO_PLAYBACK_MIX, USB_POSITION); + get_option(TUNING_REFERENCE, GLOBAL_POSITION); + get_option(USB_AUDIO_PLAYBACK_MIX, GLOBAL_POSITION); + get_option(GUI_MODE_ON_OFF, GLOBAL_POSITION); + get_option(USB_AUDIO_LEVEL, GLOBAL_POSITION); + get_option(EXP_PEDAL_LEVEL, GLOBAL_POSITION); + get_option(STOMP_MODE, GLOBAL_POSITION); + + send_message(REQUEST_MODIFIER_LINKABLE_LIST, "\x00\x01", 2); + } /** diff --git a/preset_xml.c b/preset_xml.c index a5bd749..f2f246c 100644 --- a/preset_xml.c +++ b/preset_xml.c @@ -83,7 +83,6 @@ map_xml_value(XmlSettings *xml, gint value) return NULL; } - gboolean value_is_extra (EffectValues *val, SettingParam *param) { if ((param->value < val->min) || (param->value > val->max)) { @@ -96,7 +95,6 @@ gboolean value_is_extra (EffectValues *val, SettingParam *param) void write_preset_to_xml(Preset *preset, gchar *filename) { - int rc; xmlTextWriterPtr writer; GList *iter_params = preset->params; @@ -246,11 +244,7 @@ write_preset_to_xml(Preset *preset, gchar *filename) iter_params = iter_params->next; } - - /* Here we could close the elements ORDER and EXAMPLE using the - * function xmlTextWriterEndElement, but since we do not want to - * write any other elements, we simply call xmlTextWriterEndDocument, - * which will do all the work. */ + rc = xmlTextWriterEndDocument(writer); if (rc < 0) { printf("testXmlwriterFilename: Error at xmlTextWriterEndDocument\n");