From a43240727fa8df60bb015fb81051e8974a9bc958 Mon Sep 17 00:00:00 2001 From: hirsch Date: Sun, 4 Sep 2016 10:33:14 -0400 Subject: [PATCH] Properly handle efx and rev/delay preset names. Tweak tests --- mustang.cpp | 24 +++++++++++++++++++----- mustang.h | 6 ++++-- test.py | 4 ++-- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/mustang.cpp b/mustang.cpp index 8988c6c..2dc8de4 100644 --- a/mustang.cpp +++ b/mustang.cpp @@ -121,16 +121,30 @@ Mustang::handleInput( void ) { } case 0x04: { - // Preset name + // PRESET NAME + // 0 = Amp preset, 1 = Mod preset, 2 = Delay/Reverb preset + int preset_category = read_buf[3]; + + // Rank within preset category int idx = read_buf[4]; + + // Mod + if ( 1 == preset_category ) idx += 100; + // Rev/Delay + else if ( 2 == preset_category ) idx += 112; + + // Preset name pthread_mutex_lock( &preset_names_sync.lock ); strncpy( preset_names[idx], (const char *)read_buf+16, 32 ); preset_names[idx][32] = '\0'; - // Always take the most recent one as the current preset. This - // will properly account for its appearance at the end of a complete - // parm dump or when manual patch change occurs. - curr_preset_idx = idx; + + // Always take the most recent amp preset name as + // current. This will properly account for its appearance at + // the end of a complete parm dump or when manual patch + // change occurs. Not clear if or how current EFX preset + // is reported. + if ( 0 == preset_category ) curr_preset_idx = idx; pthread_mutex_unlock( &preset_names_sync.lock ); break; diff --git a/mustang.h b/mustang.h index 37610e5..9648da5 100644 --- a/mustang.h +++ b/mustang.h @@ -56,9 +56,11 @@ class Mustang { // Synchronize access to preset names Condition preset_names_sync; - char preset_names[100][33]; - // Index to current preset + // 0-99 = amp preset, 100-111 = mod preset, 112-123 = rev/delay preset + char preset_names[124][33]; + + // Index to current amp preset unsigned curr_preset_idx; // Manage access to each DSP data block and/or associated object. diff --git a/test.py b/test.py index 6ab2ea7..2aa5970 100755 --- a/test.py +++ b/test.py @@ -21,13 +21,13 @@ cc = mido.Message('control_change') type = 0 def analog_send( outport, sleeptime=0.25 ): - for value in [ 0, 32, 64, 96, 127, 96, 64, 32, 0 ]: + for value in [ 0, 32, 64, 96, 127, 0 ]: cc.value = value outport.send( cc ) sleep( sleeptime ) def discrete_send( outport, max ): - for value in it.chain( range(0,max+1), range(max,-1,-1) ): + for value in it.chain( range(0,max+1), range(0,1) ): cc.value = value outport.send( cc ) sleep( 0.25 )