Human readable debug
Leverage the code that writes a preset to XML so that messages can be displayed in a human readable format. E.g., (6, 2432, 1280) Distortion: Dist Type: Screamer The 3-tuple is position, id, value, which is followed by the colon separated decode of the position, id, and the mapped value.
This commit is contained in:
47
effects.c
47
effects.c
@@ -3970,7 +3970,7 @@ XmlSettings xml_settings[] = {
|
|||||||
{WAH_ON_OFF, WAH_POSITION, "Wah Enable", &values_on_off, xml_on_off_labels, G_N_ELEMENTS(xml_on_off_labels)},
|
{WAH_ON_OFF, WAH_POSITION, "Wah Enable", &values_on_off, xml_on_off_labels, G_N_ELEMENTS(xml_on_off_labels)},
|
||||||
{WAH_PEDAL_POSITION, WAH_POSITION, "Wah Position", &values_0_to_99,},
|
{WAH_PEDAL_POSITION, WAH_POSITION, "Wah Position", &values_0_to_99,},
|
||||||
{WAH_VOLUME_BOOST, WAH_POSITION, "Wah Vol. Boost", &values_db_boost,},
|
{WAH_VOLUME_BOOST, WAH_POSITION, "Wah Vol. Boost", &values_db_boost,},
|
||||||
{MOD_TYPE, MOD_POSITION, "Mod Type", &values_0_to_99,}, // ???
|
//{MOD_TYPE, MOD_POSITION, "Mod Type", &values_0_to_99,}, // ???
|
||||||
|
|
||||||
{PRESET_LEVEL, PRESET_POSITION, "Preset Level", &values_0_to_99,},
|
{PRESET_LEVEL, PRESET_POSITION, "Preset Level", &values_0_to_99,},
|
||||||
|
|
||||||
@@ -4034,8 +4034,51 @@ XmlSettings xml_settings[] = {
|
|||||||
{STOMP_MODE, GLOBAL_POSITION, "Stomp Mode", &values_0_to_99,},
|
{STOMP_MODE, GLOBAL_POSITION, "Stomp Mode", &values_0_to_99,},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
guint n_xml_settings = G_N_ELEMENTS(xml_settings);
|
guint n_xml_settings = G_N_ELEMENTS(xml_settings);
|
||||||
|
|
||||||
|
gchar *Positions[] = {
|
||||||
|
[ GLOBAL_POSITION ] = "Global",
|
||||||
|
[ PICKUP_POSITION ] = "Pickup",
|
||||||
|
[ WAH_POSITION ] = "Wah",
|
||||||
|
[ COMP_POSITION ] = "Compressor",
|
||||||
|
[ GNX3K_WHAM_POSITION ] = "Gnx3K Wham",
|
||||||
|
[ DIST_POSITION ] = "Distortion",
|
||||||
|
[ AMP_CHANNEL_POSITION ] = "Amp Channel",
|
||||||
|
[ GNX_CHANNEL_POSITION ] = "Gnx Channel",
|
||||||
|
[ AMP_A_POSITION ] = "Amp A",
|
||||||
|
[ AMP_CAB_POSITION ] = "Amp Cab A",
|
||||||
|
[ AMP_B_POSITION ] = "Amp B",
|
||||||
|
[ AMP_CAB_B_POSITION ] = "Amp Cab B",
|
||||||
|
[ NOISEGATE_POSITION ] = "Noise Gate",
|
||||||
|
[ VOLUME_PRE_FX_POSITION ] = "Volume Pre Fx",
|
||||||
|
[ CHORUSFX_POSITION ] = "Chorus Fx",
|
||||||
|
[ DELAY_POSITION ] = "Delay",
|
||||||
|
[ REVERB_POSITION ] = "Reverb",
|
||||||
|
[ VOLUME_POST_FX_POSITION ] = "Volume Post Fx",
|
||||||
|
[ PRESET_POSITION ] = "Preset",
|
||||||
|
[ EXP_POSITION ] = "Expression",
|
||||||
|
[ WAH_POSITION_MIN_MAX ] = "Wah Min Max",
|
||||||
|
[ VSWITCH_ASSIGN_POSITION ] = "Vswitch",
|
||||||
|
[ LFO1_POSITION ] = "LFO 1",
|
||||||
|
[ LFO2_POSITION ] = "LFO 2",
|
||||||
|
[ EQ_A_POSITION ] = "EQ A",
|
||||||
|
[ EQ_B_POSITION ] = "EQ B",
|
||||||
|
[ LIB_POSITION ] = "Library",
|
||||||
|
[ AMP_LOOP_POSITION ] = "Amp Loop",
|
||||||
|
};
|
||||||
|
|
||||||
|
guint max_position = G_N_ELEMENTS(Positions);
|
||||||
|
|
||||||
|
gchar *
|
||||||
|
get_position (guint position)
|
||||||
|
{
|
||||||
|
if (position > max_position) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
return Positions[position];
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
|
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -116,6 +116,7 @@ typedef struct {
|
|||||||
gint n_banks;
|
gint n_banks;
|
||||||
} Device;
|
} Device;
|
||||||
|
|
||||||
|
gchar *get_position(guint position);
|
||||||
ModifierGroup *modifier_linkable_list();
|
ModifierGroup *modifier_linkable_list();
|
||||||
void modifier_group_free(ModifierGroup *modifier_group);
|
void modifier_group_free(ModifierGroup *modifier_group);
|
||||||
void get_values_info(EffectValues *values,
|
void get_values_info(EffectValues *values,
|
||||||
|
|||||||
133
gdigi.c
133
gdigi.c
@@ -21,6 +21,7 @@
|
|||||||
#include <alsa/asoundlib.h>
|
#include <alsa/asoundlib.h>
|
||||||
#include <alloca.h>
|
#include <alloca.h>
|
||||||
#include "gdigi.h"
|
#include "gdigi.h"
|
||||||
|
#include "gdigi_xml.h"
|
||||||
#include "gui.h"
|
#include "gui.h"
|
||||||
|
|
||||||
static unsigned char device_id = 0x7F;
|
static unsigned char device_id = 0x7F;
|
||||||
@@ -55,6 +56,9 @@ gboolean set_debug_flags (const gchar *option_name, const gchar *value,
|
|||||||
if (strchr(value, 'h')) {
|
if (strchr(value, 'h')) {
|
||||||
DebugFlags |= DEBUG_MSG2HOST;
|
DebugFlags |= DEBUG_MSG2HOST;
|
||||||
}
|
}
|
||||||
|
if (strchr(value, 'm')) {
|
||||||
|
DebugFlags |= DEBUG_MSG2DEV|DEBUG_MSG2HOST|DEBUG_GROUP;
|
||||||
|
}
|
||||||
if (strchr(value, 's')) {
|
if (strchr(value, 's')) {
|
||||||
DebugFlags |= DEBUG_STARTUP;
|
DebugFlags |= DEBUG_STARTUP;
|
||||||
}
|
}
|
||||||
@@ -88,10 +92,105 @@ debug_msg (debug_flags_t flags, char *fmt, ...)
|
|||||||
vsnprintf(buf, 1024, fmt, ap);
|
vsnprintf(buf, 1024, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
g_message("%s", buf);
|
fprintf(stderr, "%s\n", buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Format a value according to the xml setting.
|
||||||
|
* Returns an allocated buffer that must be freed by the caller.
|
||||||
|
*/
|
||||||
|
GString *
|
||||||
|
format_value (XmlSettings *xml, guint value)
|
||||||
|
{
|
||||||
|
GString *buf = g_string_sized_new(1);
|
||||||
|
EffectValues *values = NULL;
|
||||||
|
ValueType vtype;
|
||||||
|
gchar *suffix = "";
|
||||||
|
gdouble step = 1.0;
|
||||||
|
gint offset = 0;
|
||||||
|
gboolean decimal = FALSE;
|
||||||
|
|
||||||
|
values = xml->values;
|
||||||
|
vtype = values->type;
|
||||||
|
while ((vtype & VALUE_TYPE_EXTRA) && value_is_extra(values, value)) {
|
||||||
|
values = values->extra;
|
||||||
|
vtype = values->type;
|
||||||
|
}
|
||||||
|
vtype &= ~VALUE_TYPE_EXTRA;
|
||||||
|
|
||||||
|
if (vtype & VALUE_TYPE_OFFSET) {
|
||||||
|
offset = values->offset;
|
||||||
|
vtype &= ~VALUE_TYPE_OFFSET;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vtype & VALUE_TYPE_STEP) {
|
||||||
|
step = values->step;
|
||||||
|
vtype &= ~VALUE_TYPE_STEP;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vtype & VALUE_TYPE_SUFFIX) {
|
||||||
|
suffix = values->suffix;
|
||||||
|
vtype &= ~VALUE_TYPE_SUFFIX;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vtype & VALUE_TYPE_DECIMAL) {
|
||||||
|
decimal = TRUE;
|
||||||
|
vtype &= ~VALUE_TYPE_DECIMAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (vtype) {
|
||||||
|
case VALUE_TYPE_LABEL:
|
||||||
|
{
|
||||||
|
char *textp = map_xml_value(xml, value);
|
||||||
|
if (!textp) {
|
||||||
|
g_warning("Unable to map %s value %d for id %d position %d",
|
||||||
|
xml->label, value, xml->id, xml->position);
|
||||||
|
textp = "";
|
||||||
|
}
|
||||||
|
g_string_printf(buf, "%s", textp);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case VALUE_TYPE_PLAIN:
|
||||||
|
{
|
||||||
|
if (decimal) {
|
||||||
|
double dvalue = (value + offset) * step;
|
||||||
|
g_string_printf(buf, "%0.2f%s", dvalue, suffix);
|
||||||
|
} else {
|
||||||
|
gint ivalue = (value + offset) * step;
|
||||||
|
g_string_printf(buf, "%d%s", ivalue, suffix);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case VALUE_TYPE_NONE:
|
||||||
|
g_string_printf(buf, "%s", "");
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
g_warning("Unhandled value type %d", vtype);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
GString *
|
||||||
|
format_ipv (guint id, guint pos, guint val)
|
||||||
|
{
|
||||||
|
GString *buf = g_string_sized_new(1);
|
||||||
|
GString *vec_buf = g_string_sized_new(1);
|
||||||
|
XmlSettings *xml = get_xml_settings(id, pos);
|
||||||
|
GString *val_buf = format_value(xml, val);
|
||||||
|
|
||||||
|
g_string_printf(vec_buf, "(%d, %d, %d)", pos, id, val);
|
||||||
|
g_string_printf(buf, "%-16s %s: %s: %s",
|
||||||
|
vec_buf->str,
|
||||||
|
get_position(pos), xml->label, val_buf->str);
|
||||||
|
g_string_free(vec_buf, TRUE);
|
||||||
|
g_string_free(val_buf, TRUE);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers an error quark for gdigi if necessary.
|
* Registers an error quark for gdigi if necessary.
|
||||||
*
|
*
|
||||||
@@ -275,10 +374,7 @@ MessageID get_message_id(GString *msg)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "gdigi_xml.h"
|
void push_message (GString *msg)
|
||||||
extern XmlSettings *get_xml_settings (guint id, guint position);
|
|
||||||
|
|
||||||
void push_message(GString *msg)
|
|
||||||
{
|
{
|
||||||
MessageID msgid = get_message_id(msg);
|
MessageID msgid = get_message_id(msg);
|
||||||
if (((unsigned char)msg->str[0] == 0xF0) && ((unsigned char)msg->str[msg->len-1] == 0xF7))
|
if (((unsigned char)msg->str[0] == 0xF0) && ((unsigned char)msg->str[msg->len-1] == 0xF7))
|
||||||
@@ -315,13 +411,14 @@ void push_message(GString *msg)
|
|||||||
{
|
{
|
||||||
unpack_message(msg);
|
unpack_message(msg);
|
||||||
param = setting_param_new_from_data(&msg->str[8], NULL);
|
param = setting_param_new_from_data(&msg->str[8], NULL);
|
||||||
XmlSettings *xml = get_xml_settings(param->id, param->position);
|
if (debug_flag_is_set(DEBUG_MSG2HOST)) {
|
||||||
char *label = xml ? xml->label : "NULL";
|
GString *ipv = format_ipv(param->id,
|
||||||
debug_msg(DEBUG_MSG2HOST,
|
param->position,
|
||||||
"RECEIVE_PARAMETER_VALUE: ID: %5d Position: %2d "
|
param->value);
|
||||||
"Value: %6.1d: %s",
|
debug_msg(DEBUG_MSG2HOST, "RECEIVE_PARAMETER_VALUE\n%s",
|
||||||
param->id, param->position,
|
ipv->str);
|
||||||
param->value, label);
|
g_string_free(ipv, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
GDK_THREADS_ENTER();
|
GDK_THREADS_ENTER();
|
||||||
apply_setting_param_to_gui(param);
|
apply_setting_param_to_gui(param);
|
||||||
@@ -545,8 +642,9 @@ void send_message(gint procedure, gchar *data, gint len)
|
|||||||
g_string_append_printf(msg, "%c\xF7",
|
g_string_append_printf(msg, "%c\xF7",
|
||||||
calculate_checksum(&msg->str[1], msg->len - 1));
|
calculate_checksum(&msg->str[1], msg->len - 1));
|
||||||
|
|
||||||
debug_msg(DEBUG_VERBOSE, "Sending message %s len %d",
|
debug_msg(DEBUG_VERBOSE, "Sending %s len %d",
|
||||||
get_message_name(procedure), len);
|
get_message_name(procedure), len);
|
||||||
|
|
||||||
send_data(msg->str, msg->len);
|
send_data(msg->str, msg->len);
|
||||||
|
|
||||||
g_string_free(msg, TRUE);
|
g_string_free(msg, TRUE);
|
||||||
@@ -805,8 +903,11 @@ void set_option(guint id, guint position, guint value)
|
|||||||
((id & 0xFF00) >> 8), (id & 0xFF),
|
((id & 0xFF00) >> 8), (id & 0xFF),
|
||||||
position);
|
position);
|
||||||
append_value(msg, value);
|
append_value(msg, value);
|
||||||
debug_msg(DEBUG_MSG2DEV, "Sending id %d position %d value %d",
|
if (debug_flag_is_set(DEBUG_MSG2DEV)) {
|
||||||
id, position, value);
|
GString *ipv = format_ipv(id, position, value);
|
||||||
|
debug_msg(DEBUG_MSG2DEV, "RECEIVE_PARAMETER_VALUE\n%s", ipv->str);
|
||||||
|
g_string_free(ipv, TRUE);
|
||||||
|
}
|
||||||
send_message(RECEIVE_PARAMETER_VALUE, msg->str, msg->len);
|
send_message(RECEIVE_PARAMETER_VALUE, msg->str, msg->len);
|
||||||
g_string_free(msg, TRUE);
|
g_string_free(msg, TRUE);
|
||||||
}
|
}
|
||||||
|
|||||||
3
gdigi.h
3
gdigi.h
@@ -530,7 +530,6 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define MOD_TYPE 768
|
#define MOD_TYPE 768
|
||||||
#define MOD_POSITION 768
|
|
||||||
#define MOD_PRE_POST 1798
|
#define MOD_PRE_POST 1798
|
||||||
|
|
||||||
#define CHORUSFX_TYPE 768
|
#define CHORUSFX_TYPE 768
|
||||||
@@ -893,7 +892,6 @@ enum {
|
|||||||
#define LIBRARY_EFFECTS 8705
|
#define LIBRARY_EFFECTS 8705
|
||||||
#define EFFECTS_LEVEL 8706
|
#define EFFECTS_LEVEL 8706
|
||||||
|
|
||||||
#define LIBRARY_POSITION 25
|
|
||||||
#define LIB_POSITION 26
|
#define LIB_POSITION 26
|
||||||
|
|
||||||
#define TONE_LIB_TYPE 8704
|
#define TONE_LIB_TYPE 8704
|
||||||
@@ -1145,5 +1143,6 @@ void set_preset_level(int level);
|
|||||||
GStrv query_preset_names(gchar bank);
|
GStrv query_preset_names(gchar bank);
|
||||||
void message_list_free(GList *list);
|
void message_list_free(GList *list);
|
||||||
GList *get_current_preset();
|
GList *get_current_preset();
|
||||||
|
GString *format_ipv(guint id, guint pos, guint val);
|
||||||
|
|
||||||
#endif /* GDIGI_H */
|
#endif /* GDIGI_H */
|
||||||
|
|||||||
@@ -33,7 +33,9 @@ typedef struct {
|
|||||||
guint xml_labels_amt;
|
guint xml_labels_amt;
|
||||||
} XmlSettings;
|
} XmlSettings;
|
||||||
|
|
||||||
// XmlSettings *get_xml_settings(guint id, guint position);
|
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 *get_xml_label(guint id, guint position, gint type);
|
// gchar *get_xml_label(guint id, guint position, gint type);
|
||||||
|
|
||||||
#endif /* GDIGI_XML_H */
|
#endif /* GDIGI_XML_H */
|
||||||
|
|||||||
9
preset.c
9
preset.c
@@ -330,10 +330,11 @@ Preset *create_preset_from_data(GList *list)
|
|||||||
SettingParam *param = setting_param_new_from_data(&data->str[x], &x);
|
SettingParam *param = setting_param_new_from_data(&data->str[x], &x);
|
||||||
n++;
|
n++;
|
||||||
preset->params = g_list_prepend(preset->params, param);
|
preset->params = g_list_prepend(preset->params, param);
|
||||||
debug_msg(DEBUG_MSG2HOST, "%3d ID %4d Position %2d "
|
if (debug_flag_is_set(DEBUG_MSG2HOST)) {
|
||||||
"Value %6.1d",
|
GString *ipv = format_ipv(param->id, param->position, param->value);
|
||||||
n, param->id, param->position,
|
debug_msg(DEBUG_MSG2HOST, "%3d %s", n, ipv->str);
|
||||||
param->value);
|
g_string_free(ipv, TRUE);
|
||||||
|
}
|
||||||
} while ((x < data->len) && n<total);
|
} while ((x < data->len) && n<total);
|
||||||
debug_msg(DEBUG_MSG2HOST, "TOTAL %d", total);
|
debug_msg(DEBUG_MSG2HOST, "TOTAL %d", total);
|
||||||
preset->params = g_list_sort(preset->params, params_cmp);
|
preset->params = g_list_sort(preset->params, params_cmp);
|
||||||
|
|||||||
16
preset_xml.c
16
preset_xml.c
@@ -52,7 +52,7 @@ XmlSettings *get_xml_settings (guint id, guint position)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gchar *
|
gchar *
|
||||||
map_xml_value(XmlSettings *xml, gint value)
|
map_xml_value (XmlSettings *xml, gint value)
|
||||||
{
|
{
|
||||||
switch (xml->values->type) {
|
switch (xml->values->type) {
|
||||||
case VALUE_TYPE_LABEL:
|
case VALUE_TYPE_LABEL:
|
||||||
@@ -84,10 +84,9 @@ map_xml_value(XmlSettings *xml, gint value)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean value_is_extra (EffectValues *val, int value)
|
||||||
gboolean value_is_extra (EffectValues *val, SettingParam *param)
|
|
||||||
{
|
{
|
||||||
if ((param->value < val->min) || (param->value > val->max)) {
|
if ((value < val->min) || (value > val->max)) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -97,7 +96,6 @@ gboolean value_is_extra (EffectValues *val, SettingParam *param)
|
|||||||
void
|
void
|
||||||
write_preset_to_xml(Preset *preset, gchar *filename)
|
write_preset_to_xml(Preset *preset, gchar *filename)
|
||||||
{
|
{
|
||||||
|
|
||||||
int rc;
|
int rc;
|
||||||
xmlTextWriterPtr writer;
|
xmlTextWriterPtr writer;
|
||||||
GList *iter_params = preset->params;
|
GList *iter_params = preset->params;
|
||||||
@@ -178,7 +176,7 @@ write_preset_to_xml(Preset *preset, gchar *filename)
|
|||||||
BAD_CAST xml->label);
|
BAD_CAST xml->label);
|
||||||
values = xml->values;
|
values = xml->values;
|
||||||
type = values->type;
|
type = values->type;
|
||||||
while ((type & VALUE_TYPE_EXTRA) && value_is_extra(values, param)) {
|
while ((type & VALUE_TYPE_EXTRA) && value_is_extra(values, param->value)) {
|
||||||
values = values->extra;
|
values = values->extra;
|
||||||
type = values->type;
|
type = values->type;
|
||||||
}
|
}
|
||||||
@@ -248,11 +246,7 @@ write_preset_to_xml(Preset *preset, gchar *filename)
|
|||||||
|
|
||||||
iter_params = iter_params->next;
|
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);
|
rc = xmlTextWriterEndDocument(writer);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
printf("testXmlwriterFilename: Error at xmlTextWriterEndDocument\n");
|
printf("testXmlwriterFilename: Error at xmlTextWriterEndDocument\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user