From 2d4798abf77b7c19c0fb34e8f22c600a0cef1f85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mo=C5=84?= Date: Mon, 23 Feb 2009 17:43:14 +0100 Subject: [PATCH] more work-in-progress on setting effects type --- gdigi.c | 223 ++++++++++++-------------------------------------------- gdigi.h | 9 +++ 2 files changed, 57 insertions(+), 175 deletions(-) diff --git a/gdigi.c b/gdigi.c index 3a3ac91..9f4a9f8 100644 --- a/gdigi.c +++ b/gdigi.c @@ -187,28 +187,57 @@ void set_wah_level(int level) set_option(WAH_LEVEL, WAH_POSITION, level); } -void set_wah_type(int type) +void set_higher_option(gint id, gint position, int type) { - gint id = 128; - static char set_type[] = {0x00, 0xF0, 0x00, 0x00, 0x10, 0x00, 0x5E, 0x02, 0x41, 0x00, 0x00, 0x00, /* ID */ - 0x03, /* seems to be position */ - 0x01, /* ??? */ - 0x00, /* type */ + 0x00, /* position */ + 0x00, /* value length */ + 0x00, 0x00, /* type */ 0x00, /* checksum */ 0xF7}; - set_type[9] = ((id & 0x80) >> 2) | 0x0C; /* Why 0x0C? */ + set_type[9] = ((id & 0x80) >> 2); set_type[10] = ((id & 0xFF00) >> 8); set_type[11] = ((id & 0x007F)); - /* 8th bit of type is always 1 - check how does it affect command */ - set_type[14] = (type & 0x007F); + set_type[12] = position; - set_type[15] = calculate_checksum(set_type, sizeof(set_type), 15) ^ 0x07; + if (type < 0x80) { + // [13] = type, [14] - checksum, [15] = 0xF7 + } else if (type <= 0xFF) { + set_type[9] |= 0x08; // there'll be length before value + if (((type & 0x80) >> 7) == 1) + set_type[9] |= 0x04; - send_data(set_type, sizeof(set_type)); + set_type[13] = 0x01; + // [14] = type, [15] - checksum, [16] = 0xF7 + set_type[14] = (type & 0x007F); + + set_type[16] = 0xF7; + set_type[15] = calculate_checksum(set_type, 17, 15) ^ 0x07; + + send_data(set_type, 17); + } else if (type < 0xFFFF) { + set_type[9] |= 0x08; // there'll be length before value + if (((type & 0x80) >> 7) == 1) + set_type[9] |= 0x02; + + set_type[13] = 0x02; + + set_type[14] = ((type & 0xFF00) >> 8); + set_type[15] = ((type & 0x007F)); + + set_type[17] = 0xF7; + set_type[16] = calculate_checksum(set_type, 18, 16) ^ 0x07; + + send_data(set_type, 18); + } +} + +void set_wah_type(int type) +{ + set_higher_option(WAH_TYPE, WAH_POSITION, type); } void set_wah_on_off(gboolean val) @@ -242,26 +271,7 @@ void set_comp_level(int level) void set_comp_type(int type) { - gint id = 207; - - static char set_type[] = {0x00, 0xF0, 0x00, 0x00, 0x10, 0x00, 0x5E, 0x02, 0x41, - 0x00, 0x00, 0x00, /* ID */ - 0x04, /* seems to be position */ - 0x01, /* ??? */ - 0x00, /* type */ - 0x00, /* checksum */ 0xF7}; - - set_type[9] = ((id & 0x80) >> 2) | 0x0C; /* Why 0x0C? */ - - set_type[10] = ((id & 0xFF00) >> 8); - set_type[11] = ((id & 0x007F)); - - /* 8th bit of type is always 1 - check how does it affect command */ - set_type[14] = (type & 0x007F); - - set_type[15] = calculate_checksum(set_type, sizeof(set_type), 15) ^ 0x07; - - send_data(set_type, sizeof(set_type)); + set_higher_option(COMP_TYPE, COMP_POSITION, type); } void set_comp_on_off(gboolean val) @@ -293,24 +303,7 @@ void switch_system_preset(int x) void set_pickup_type(int type) { - gint id = 64; - - static char pickup[] = {0x00, 0xF0, 0x00, 0x00, 0x10, 0x00, 0x5E, 0x02, 0x41, - 0x00, 0x00, 0x40, /* ID */ - 0x02, /* seems to be position */ - 0x00, /* type */ - 0x00, /* checksum */ 0xF7}; - - pickup[9] = ((id & 0x80) >> 2); - - pickup[10] = ((id & 0xFF00) >> 8); - pickup[11] = ((id & 0x007F)); - - pickup[13] = type; - - pickup[14] = calculate_checksum(pickup, sizeof(pickup), 14) ^ 0x07; - - send_data(pickup, sizeof(pickup)); + set_option(PICKUP_TYPE, PICKUP_POSITION, type); } void set_pickup_on_off(gboolean val) @@ -320,26 +313,7 @@ void set_pickup_on_off(gboolean val) void set_dist_type(int type) { - gint id = 2432; - - static char set_dist[] = {0x00, 0xF0, 0x00, 0x00, 0x10, 0x00, 0x5E, 0x02, 0x41, - 0x00, 0x00, 0x00, /* ID */ - 0x06, /* seems to be position */ - 0x02, /* ??? */ - 0x00, 0x00, /* type */ - 0x00 /* checksum */, 0xF7}; - - set_dist[9] = ((id & 0x80) >> 2) | 0x08; /* Why 0x08? */ - - set_dist[10] = ((id & 0xFF00) >> 8); - set_dist[11] = ((id & 0x007F)); - - set_dist[14] = ((type & 0xFF00) >> 8); - set_dist[15] = ((type & 0x00FF)); - - set_dist[16] = calculate_checksum(set_dist, sizeof(set_dist), 16) ^ 0x07; - - send_data(set_dist, sizeof(set_dist)); + set_higher_option(DIST_TYPE, DIST_POSITION, type); } void set_dist_option(guint32 option, int value) @@ -360,27 +334,7 @@ void set_preset_level(int level) void set_eq_type(int type) { - gint id = 3202; - - static char set_eq[] = {0x00, 0xF0, 0x00, 0x00, 0x10, 0x00, 0x5E, 0x02, 0x41, - 0x00, 0x00, 0x00, /* ID */ - 0x18, /* seems to be position */ - 0x02, /* ??? */ - 0x05, 0x00, /* type */ - 0x00, /* checksum */ 0xF7}; - - set_eq[9] = ((id & 0x80) >> 2) | 0x0A; /* Why 0x0A? */ - - set_eq[10] = ((id & 0xFF00) >> 8); - set_eq[11] = ((id & 0x007F)); - - /* 8th bit of type is always 1 - check how does it affect command */ - set_eq[14] = ((type & 0xFF00) >> 8); - set_eq[15] = ((type & 0x007F)); - - set_eq[16] = calculate_checksum(set_eq, sizeof(set_eq), 16) ^ 0x07; - - send_data(set_eq, sizeof(set_eq)); + set_higher_option(EQ_TYPE, EQ_POSITION, type); } /* x = 0 to 99 */ @@ -522,26 +476,7 @@ void set_eq_on_off(gboolean val) void set_noisegate_type(int type) { - gint id = 704; - - static char set_type[] = {0x00, 0xF0, 0x00, 0x00, 0x10, 0x00, 0x5E, 0x02, 0x41, - 0x00, 0x00, 0x00, /* ID */ - 0x0C, /* seems to be position */ - 0x02, /* ??? */ - 0x00, 0x00, /* type */ - 0x00 /* checksum */, 0xF7}; - - set_type[9] = ((id & 0x80) >> 2) | 0x08; /* Why 0x08? */ - - set_type[10] = ((id & 0xFF00) >> 8); - set_type[11] = ((id & 0x007F)); - - set_type[14] = ((type & 0xFF00) >> 8); - set_type[15] = ((type & 0x00FF)); - - set_type[16] = calculate_checksum(set_type, sizeof(set_type), 16) ^ 0x07; - - send_data(set_type, sizeof(set_type)); + set_higher_option(NOISEGATE_TYPE, NOISEGATE_POSITION, type); } /* x = 0 to 99 */ @@ -562,31 +497,7 @@ void set_chorusfx_option(guint32 option, int x) void set_chorusfx_type(int type) { - gint id = 768; - - static char set_type[] = {0x00, 0xF0, 0x00, 0x00, 0x10, 0x00, 0x5E, 0x02, 0x41, - 0x00, 0x00, 0x00, /* ID */ - 0x0E, /* seems to be position */ - 0x02, /* ??? */ - 0x00, 0x00, /* type */ - 0x00 /* checksum */, 0xF7}; - - set_type[9] = ((id & 0x80) >> 2); - - set_type[10] = ((id & 0xFF00) >> 8); - set_type[11] = ((id & 0x007F)); - - if (((type & 0x80) >> 7) == 1) - set_type[9] |= 0x0A; - else - set_type[9] |= 0x08; - - set_type[14] = ((type & 0xFF00) >> 8); - set_type[15] = ((type & 0x007F)); - - set_type[16] = calculate_checksum(set_type, sizeof(set_type), 16) ^ 0x07; - - send_data(set_type, sizeof(set_type)); + set_higher_option(CHORUSFX_TYPE, CHORUSFX_POSITION, type); } void set_chorusfx_on_off(gboolean val) @@ -616,26 +527,7 @@ void set_delay_time(int x) void set_delay_type(int type) { - gint id = 1856; - - static char set_type[] = {0x00, 0xF0, 0x00, 0x00, 0x10, 0x00, 0x5E, 0x02, 0x41, - 0x00, 0x00, 0x00, /* ID */ - 0x0F, /* seems to be position */ - 0x02, /* ??? */ - 0x00, 0x00 /* type */, - 0x00 /* checksum */, 0xF7}; - - set_type[9] = ((id & 0x80) >> 2) | 0x08; /* Why 0x08? */ - - set_type[10] = ((id & 0xFF00) >> 8); - set_type[11] = ((id & 0x007F)); - - set_type[14] = ((type & 0xFF00) >> 8); - set_type[15] = ((type & 0x007F)); - - set_type[16] = calculate_checksum(set_type, sizeof(set_type), 16) ^ 0x07; - - send_data(set_type, sizeof(set_type)); + set_higher_option(DELAY_TYPE, DELAY_POSITION, type); } void set_delay_option(guint32 option, int x) @@ -656,26 +548,7 @@ void set_reverb_option(guint32 option, int x) void set_reverb_type(int type) { - gint id = 1920; - - static char set_type[] = {0x00, 0xF0, 0x00, 0x00, 0x10, 0x00, 0x5E, 0x02, 0x41, - 0x00, 0x00, 0x00, /* ID */ - 0x10, /* seems to be position */ - 0x02, /* ??? */ - 0x00, 0x00, /* type1 */ - 0x00 /* checksum */, 0xF7}; - - set_type[9] = ((id & 0x80) >> 2) | 0x08; /* Why 0x08? */ - - set_type[10] = ((id & 0xFF00) >> 8); - set_type[11] = ((id & 0x007F)); - - set_type[14] = ((type & 0xFF00) >> 8); - set_type[15] = ((type & 0x00FF)); - - set_type[16] = calculate_checksum(set_type, sizeof(set_type), 16) ^ 0x07; - - send_data(set_type, sizeof(set_type)); + set_higher_option(REVERB_TYPE, REVERB_POSITION, type); } void set_reverb_on_off(gboolean val) diff --git a/gdigi.h b/gdigi.h index 24c8ab2..2d64b37 100644 --- a/gdigi.h +++ b/gdigi.h @@ -28,6 +28,7 @@ enum { #define WAH_MIN 8195 #define WAH_MAX 8196 +#define WAH_TYPE 128 #define WAH_ON_OFF 129 #define WAH_POSITION 3 @@ -38,6 +39,7 @@ enum { COMP_TYPE_CS = 196 }; +#define COMP_TYPE 207 #define COMP_ON_OFF 193 #define COMP_POSITION 4 @@ -51,6 +53,7 @@ enum { PICKUP_TYPE_SC_HB = 65 }; +#define PICKUP_TYPE 64 #define PICKUP_ON_OFF 65 #define PICKUP_POSITION 2 @@ -70,6 +73,7 @@ enum { DIST_TYPE_MP = 1284 }; +#define DIST_TYPE 2432 #define DIST_ON_OFF 2433 #define DIST_POSITION 6 @@ -130,6 +134,7 @@ enum { #define AMP_GAIN 2497 #define AMP_LEVEL 2498 +#define EQ_TYPE 3202 #define EQ_ON_OFF 3212 #define EQ_POSITION 24 @@ -142,6 +147,7 @@ enum { NOISEGATE_SWELL = 769 }; +#define NOISEGATE_TYPE 704 #define NOISEGATE_ON_OFF 705 #define NOISEGATE_POSITION 12 @@ -176,6 +182,7 @@ enum { CHORUS_TYPE_IPS = 0x541 }; +#define CHORUSFX_TYPE 768 #define CHORUSFX_ON_OFF 769 #define CHORUSFX_POSITION 14 @@ -329,6 +336,7 @@ enum { DELAY_TYPE_TAPE = 1049 }; +#define DELAY_TYPE 1856 #define DELAY_ON_OFF 1857 #define DELAY_POSITION 15 @@ -363,6 +371,7 @@ enum { REVERB_TYPE_EMT240_PLATE = 1151 }; +#define REVERB_TYPE 1920 #define REVERB_ON_OFF 1921 #define REVERB_POSITION 16