Saving/Loading button combinations with other buttons and a menu

Andrew Finch
Andrew Finch Member Posts: 17 Newcomer

Hey all,

I am working on a script that allows the user to save a preset to a specific button. So far I have 4 buttons which should be selected in any combination then by pressing the dropdown menu you can save or load. This all works fine but now I want to implement the 'Save to P1' and 'Save to P2' idea. By selecting either of these with the current button combination I want to be able to save the combination to the button so that when it is pressed it will load the combination. Further to this the idea, I want the user to be able to save their own combinations to the preset buttons meaning that you should be able to overide the previous selected preset. Below is what I have so far, any suggestions or ideas would be gratefully recieved:

{Load/Save Test}


on init

    message("")
        set_script_title("Save/Load Test")


{------------------------------------------Save/Load----------------------------------}


 declare $count

    declare %combination_buttons[4]
    declare $sync_id 

{---Save combinations of these buttons---}

    declare ui_switch $button1 
    declare ui_switch $button2 
    declare ui_switch $button3 
    declare ui_switch $button4

    make_persistent($button1) 
    make_persistent($button2)
    make_persistent($button3)
    make_persistent($button4)


{---Preset Buttons---}

    declare ui_switch $preset1 
    declare ui_switch $preset2 

    make_persistent($preset1) 
    make_persistent($preset2)

    move_control_px($preset1,66,25)
    move_control_px($preset2,158,25)


{---Dropdown menu to give options: Save, Load, Save to P1, Save to P2---}


        declare ui_menu $load_save_menu
        make_persistent($load_save_menu)
        add_menu_item($load_save_menu,"Save",0) 
        add_menu_item($load_save_menu,"Load",1) 
        add_menu_item($load_save_menu,"Save to P1",2) 
        add_menu_item($load_save_menu,"Save to P2",3) 

        move_control_px($load_save_menu,500,2)

end on


on async_complete 
 if ($NI_ASYNC_ID = $sync_id) 
  $sync_id := -1 
end if 
end on 


on ui_control ($load_save_menu) 
select ($load_save_menu) 
   case 0 
   save_array (%combination_buttons,0)  
   case 1 
   $sync_id := load_array (%combination_buttons,0) 
   while ($sync_id # -1) 
   wait (1) 
  end while  


  $button1 := %combination_buttons[0] 
  $button2 := %combination_buttons[1] 
  $button3 := %combination_buttons[2]
  $button4 := %combination_buttons[3]

end select 

end on 


on ui_control($button1)
   %combination_buttons[0] := $button1
end on


on ui_control($button2) 
   %combination_buttons[1] := $button2
end on


on ui_control($button3) 
   %combination_buttons[2] := $button3
end on


on ui_control($button4) 
   %combination_buttons[3] := $button4
end on


Best Answer

  • EvilDragon
    EvilDragon Moderator Posts: 1,022 mod
    Answer ✓

    That... is pretty complicated to do. To get an idea on how you'd go about it, you should check out how saving and loading mixer presets in Studio Drummer works.

Answers

  • EvilDragon
    EvilDragon Moderator Posts: 1,022 mod

    You would need an array that holds your P1 and P2 presets too, persistent of course. Then store the state of buttons to that array in order to be able to retrieve it.

  • Andrew Finch
    Andrew Finch Member Posts: 17 Newcomer

    I am a little confused on where to start with this! As the .NKA files are stored in the data folder how do I 'hold' the P1 and P2 presets?

  • EvilDragon
    EvilDragon Moderator Posts: 1,022 mod
    edited February 2022

    Well first, are P1 and P2 supposed to be stored in the NKA as well, or are they separate presets that you load INTO from the saved NKA?

    Because the way you worder it in the code to me it seemed like "Save to P1/P2" options were meant to store the current state of buttons to an array, rather than load data INTO those presets from NKAs...

  • Andrew Finch
    Andrew Finch Member Posts: 17 Newcomer

    So the main idea is to link P1 and P2 (I actually want 24 total) to key switches meaning that you can change to different button combinations (to give different sounds) in the middle of a MIDI mock up. In itself that isn't too difficult but in addition to this I want the user to be able to create their own button combinations and have the option of using them live and cycling through them with key switches. I have now changed my idea slightly in that basically I want P1 and P2 to be menus that when you click on them they will show the saved presets you have made (.NKA files). When selected the .NKA file is 'saved' to P1 or P2 and then you can cycle between your own presets in the midi mock-up. Hope that makes sense!

  • EvilDragon
    EvilDragon Moderator Posts: 1,022 mod
    Answer ✓

    That... is pretty complicated to do. To get an idea on how you'd go about it, you should check out how saving and loading mixer presets in Studio Drummer works.

Back To Top