@@ -31,8 +31,6 @@ var amy_module = null;
3131var pendingPatchKnobIndex = null ;
3232var patchKnobSyncAttempts = 0 ;
3333window . current_synth = 1 ;
34- var knob_positions = { } ;
35-
3634
3735// Once AMY module is loaded, register its functions and start AMY (not yet audio, you need to click for that)
3836amyModule ( ) . then ( async function ( am ) {
@@ -235,9 +233,6 @@ function get_events_for_patch_number(patch_number) {
235233 for ( let i = 0 ; i < limit ; i += 1 ) {
236234 const base = eventsPtr + i * layout . size ;
237235 const status = view . getUint8 ( base + offsets . status ) ;
238- if ( status === EVENT_EMPTY ) {
239- break ;
240- }
241236 events . push ( readEvent ( base ) ) ;
242237 }
243238
@@ -399,46 +394,13 @@ function save_to_patch(patchNumber) {
399394 amy_add_log_message ( "K" + patchNumber + payload ) ;
400395 }
401396 amy_add_log_message ( "i" + window . current_synth + "K" + patchNumber ) ;
402- // also save the positions of the knobs to a map, like knob_positions[patchNumber] = {knob_index: value, ...}
403- if ( Array . isArray ( knobList ) ) {
404- const patchState = { } ;
405- knobList . forEach ( function ( knob , index ) {
406- if ( ! knob || knob . knob_type === "spacer" || knob . knob_type === "spacer-half" ) {
407- return ;
408- }
409- patchState [ index ] = Number ( knob . default_value ) ;
410- } ) ;
411- knob_positions [ patchNumber ] = patchState ;
412- }
413-
414397}
415398
416399function load_from_patch ( patchNumber ) {
417400 // Hook for loading a saved memory patch number.
418- // This doesn't set the knobs yet because we don't have access to events from a memory patch number
419401 set_knobs_from_patch_number ( patchNumber ) ;
420- // and here reload the positions of the knobs (set them) from the stored knob_posistions[patchNumber] if it is set
421- restore_knobs_from_saved_knobs ( patchNumber ) ;
422402}
423403
424- function restore_knobs_from_saved_knobs ( patchNumber ) {
425- const patchState = knob_positions [ patchNumber ] ;
426- const knobList = window . get_current_knobs ? window . get_current_knobs ( ) : [ ] ;
427- if ( ! patchState || ! Array . isArray ( knobList ) ) {
428- return ;
429- }
430- Object . keys ( patchState ) . forEach ( function ( key ) {
431- const index = Number ( key ) ;
432- if ( ! Number . isInteger ( index ) || ! knobList [ index ] ) {
433- return ;
434- }
435- const value = patchState [ key ] ;
436- if ( ! Number . isFinite ( value ) ) {
437- return ;
438- }
439- set_knob_ui_value ( knobList [ index ] , value , false ) ;
440- } ) ;
441- }
442404
443405async function amy_external_midi_input_js_hook ( bytes , len , sysex ) {
444406 mp . midiInHook ( bytes , len , sysex ) ;
0 commit comments