From bdb35ddf5456434395680afc696cd224e55ede60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mo=C5=84?= Date: Sat, 14 Mar 2009 12:39:45 +0100 Subject: [PATCH] finish modifier_linkable_list(), add modifier_group_free() --- TODO | 4 +--- effects.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- effects.h | 8 +++++++ 3 files changed, 70 insertions(+), 4 deletions(-) diff --git a/TODO b/TODO index 8bbd636..304642b 100644 --- a/TODO +++ b/TODO @@ -2,6 +2,4 @@ -effects level -handling presets (saving, exporting to xml patches) -buildsystem (install knob.png to share dir, don't use inline knob pixbuf) --expression pedal settings - -finish modifier_linkable_list() (gdigi.c) - -add it to gui +-add expression pedal settings to gui diff --git a/effects.c b/effects.c index 3fd53df..72258f1 100644 --- a/effects.c +++ b/effects.c @@ -893,7 +893,27 @@ static Modifier *get_modifier(guint id, guint position) return NULL; } -void modifier_linkable_list() +static EffectSettings *get_modifier_settings(EffectValues *values) +{ + if (values == NULL) + return NULL; + + /* TODO: reuse exsisting settings if values is the same */ + EffectSettings *settings = g_slice_alloc0(2 * sizeof(EffectSettings)); + settings[0].id = EXP_MIN; + settings[1].id = EXP_MAX; + + settings[0].label = "Min"; + settings[1].label = "Max"; + + settings[0].position = settings[1].position = EXP_POSITION; + + settings[0].values = settings[1].values = values; + + return settings; +} + +ModifierGroup *modifier_linkable_list() { guint group_id; guint count; @@ -908,12 +928,52 @@ void modifier_linkable_list() group_id = (str[8] << 8) | str[9]; count = (str[10] << 8) | str[11]; + ModifierGroup *modifier_group = g_slice_new(ModifierGroup); + g_message("Group %d count %d", group_id, count); + EffectGroup *group = g_slice_alloc(count * sizeof(EffectGroup)); + for (i=0; ilabel; + group[i].settings = get_modifier_settings(modifier->values); + group[i].settings_amt = 2; + } else { + group[i].label = NULL; + group[i].settings = NULL; + } + + if (group[i].settings == NULL) + group[i].settings_amt = 0; + g_message("ID: %d Position: %d Label: %s", id, position, modifier ? modifier->label : NULL); } + + modifier_group->group = group; + modifier_group->group_amt = count; + + return modifier_group; +} + +void modifier_group_free(ModifierGroup *modifier_group) +{ + g_return_if_fail(modifier_group != NULL); + + int x; + for (x=0; xgroup_amt; x++) { + if (modifier_group->group[x].settings) + g_slice_free1(2 * sizeof(EffectSettings), + modifier_group->group[x].settings); + } + g_slice_free1(modifier_group->group_amt * sizeof(EffectGroup), + modifier_group->group); + g_slice_free(ModifierGroup, modifier_group); } diff --git a/effects.h b/effects.h index f19c1cf..0df1ee6 100644 --- a/effects.h +++ b/effects.h @@ -54,4 +54,12 @@ typedef struct { gint amt; /* list of supported effects length */ } EffectList; +typedef struct { + EffectGroup *group; + gint group_amt; +} ModifierGroup; + +ModifierGroup *modifier_linkable_list(); +void modifier_group_free(ModifierGroup *modifier_group); + #endif /* GDIGI_EFFECTS_H */