From f389caffbc7ecf090aba62956e5f8520d9465fd2 Mon Sep 17 00:00:00 2001 From: Tim LaBerge Date: Mon, 3 Dec 2012 19:25:24 -0800 Subject: [PATCH] Fix RHold display for delay repeats. This involved passing the EffectValue resulting from the resolution of an VALUE_TYPE_EXTRA to map_xml_value() and some more careful range checking. Also, the delay repeats effect needed an xml_label for the special 'repeat forever' value 100, which maps to the string RHold. --- effects.c | 7 ++++--- gdigi.c | 2 +- gdigi_xml.h | 2 +- preset_xml.c | 12 +++++++----- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/effects.c b/effects.c index 244896e..e54b617 100644 --- a/effects.c +++ b/effects.c @@ -3875,6 +3875,9 @@ static XmlLabel xml_fx_lib_labels[] = { {EFFECTS_LIB_ROTARY_TAPE, "Rotary + Tape Delay"}, }; +static XmlLabel xml_rhold_labels[] = { + {100, "RHold"}, +}; /* Array to map id/position pairs to labels and settings. */ XmlSettings xml_settings[] = { {0, 0, "None", NULL,}, @@ -4027,12 +4030,10 @@ XmlSettings xml_settings[] = { {SYNTH_TALK_VOX, CHORUSFX_POSITION, "Synth Talk Vox", &values_0_to_99,}, {SYNTH_TALK_BALANCE, CHORUSFX_POSITION, "Synth Talk Balance", &values_0_to_99,}, - - {DELAY_TYPE, DELAY_POSITION, "Delay Type", &values_delay_type, xml_delay_labels, G_N_ELEMENTS(xml_delay_labels)}, {DELAY_ON_OFF, DELAY_POSITION, "Delay Enable", &values_on_off, xml_on_off_labels, G_N_ELEMENTS(xml_on_off_labels)}, {DELAY_TIME, DELAY_POSITION, "Delay Time", &values_delay_time,}, - {DELAY_REPEATS, DELAY_POSITION, "Delay Repeats", &values_delay_repeats,}, + {DELAY_REPEATS, DELAY_POSITION, "Delay Repeats", &values_delay_repeats, xml_rhold_labels, G_N_ELEMENTS(xml_rhold_labels)}, {DELAY_LEVEL, DELAY_POSITION, "Delay Level", &values_0_to_99,}, {DELAY_DUCK_THRESH, DELAY_POSITION, "Delay Duck Thresh", &values_0_to_99,}, {DELAY_DUCK_LEVEL, DELAY_POSITION, "Delay Duck Level", &values_0_to_99,}, diff --git a/gdigi.c b/gdigi.c index 6dec470..dc1ff24 100644 --- a/gdigi.c +++ b/gdigi.c @@ -142,7 +142,7 @@ format_value (XmlSettings *xml, guint value) switch (vtype) { case VALUE_TYPE_LABEL: { - char *textp = map_xml_value(xml, value); + char *textp = map_xml_value(xml, values, value); if (!textp) { g_warning("Unable to map %s value %d for id %d position %d", xml->label, value, xml->id, xml->position); diff --git a/gdigi_xml.h b/gdigi_xml.h index 8a60b80..b5f73b9 100644 --- a/gdigi_xml.h +++ b/gdigi_xml.h @@ -35,7 +35,7 @@ typedef struct { XmlSettings *get_xml_settings(guint id, guint position); gboolean value_is_extra(EffectValues *val, int value); -gchar * map_xml_value(XmlSettings *xml, gint value); +gchar * map_xml_value(XmlSettings *xml, EffectValues *values, gint value); // gchar *get_xml_label(guint id, guint position, gint type); #endif /* GDIGI_XML_H */ diff --git a/preset_xml.c b/preset_xml.c index cb873e1..1ae4623 100644 --- a/preset_xml.c +++ b/preset_xml.c @@ -30,6 +30,7 @@ extern XmlSettings xml_settings[]; extern guint n_xml_settings; extern EffectValues values_on_off; + /** * \param id modifier ID * \param position modifier position @@ -52,15 +53,16 @@ XmlSettings *get_xml_settings (guint id, guint position) } gchar * -map_xml_value (XmlSettings *xml, gint value) +map_xml_value (XmlSettings *xml, EffectValues *values, gint value) { - switch (xml->values->type) { + switch (values->type) { case VALUE_TYPE_LABEL: - if ((xml->values == &values_on_off) && (value > 1)) { + if ((values == &values_on_off) && (value > 1)) { g_warning("Skipping modifier->label %s\n", xml->label); return NULL; } - if (value > xml->values->max || value < xml->values->min) { + + if (value > values->max || value < values->min) { g_warning("%s value %d out of range %0.1f %0.1f", xml->label, value, xml->values->min, xml->values->max); } @@ -205,7 +207,7 @@ write_preset_to_xml(Preset *preset, gchar *filename) switch (type) { case VALUE_TYPE_LABEL: { - char *textp = map_xml_value(xml, param->value); + char *textp = map_xml_value(xml, values, param->value); if (!textp) { g_warning("Unable to map %s value %d for id %d position %d", xml->label, param->value, param->id,