Need some help to add patch load/save for the Triode panel

Home Forums General Programming Need some help to add patch load/save for the Triode panel

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #96522
    arcangeli
    Participant
      • Topics: 9
      • Replies: 21
      • Total: 30

      Hi all,

      I’ve already made a fully functional panel for my Meeblip Triode bass synth here: Triode panel.

      This synth has not any patch load/save function. I want to make this with Ctrlr but it’s hard to find how to do that.
      I’ve got some Lua knowledge (i’m a user of the awesome WM for Linux).

      There’s no sysex on the synth. Only CC. There’s no MIDI out on it, only IN. All this load/save function need to be on the Ctrlr side and saved on the computer (as csv file for exemple).

      For saving, i think that i need to read all Modulator value and add them in an array. For loading (with upload to the synth), i think taht i need to read the array and send the value to the modulator AND the synth one by one.
      Loading and saving the array to a csv file may be more simpler to do 😉

      I would be very grateful if anyone could help me. At least for the first modulator…

      • This topic was modified 5 years, 5 months ago by arcangeli.
      #96551
      human fly
      Participant
        • Topics: 124
        • Replies: 1070
        • Total: 1194
        • ★★★★

        it’s been a while since i did anything with Ctrlr, but i’m going to
        suggest you look at the last RX7 panel version. i was doing something
        to collect all modulator values into a table, and restore them.

        in that case, each drum pad had its parameter values, but i was only
        using one set of modulators for all (240…) pads.

        so you could think of each pad table as a preset, that i was sending
        onto the modulators.

        you might find it interesting to look at anyway. i hope it’s not too
        much of a mess to follow, lots of different methods. but the essential
        ones you would be looking for are the ones compiling the tables, and
        retrieving the table values. you will see it also has a kind of ‘autowrite’
        going on each time a modulator changes values, so tables are updating
        constantly. could be what you need if you don’t have presets.

        don’t have it set up on this machine atm but i may be able to remember
        what i was doing …

        #96601
        dnaldoog
        Participant
          • Topics: 4
          • Replies: 480
          • Total: 484
          • ★★

          There’s a DEMO panel by Atom named ‘Files’ https://github.com/RomanKubiak/Panels/tree/master/DEMO in which he shows how to save a file as binary.

          If you create a lookup lua table with names of your Modulators, you could then loop through each modulator and get its value. Untested code follows:

          
          t={}
          lookupTable={{"volume",0x07},{"pan",0x0A},{"Balance",0x09}}
          for _,v in iPairs(lookupTable) do
          table.insert(t,panel:getModulatorByName(v[1]):getModulatorValue())
          end
          

          Then you would convert temp table t to a MemoryBlock
          m=MemoryBlock.fromLuaTable(t)
          and save that to a binary file.


          The reverse would be to load that file and convert to lua table and write back to each modulator:

          
           local  f = utils.openFileWindow("Open file", File.getSpecialLocation(File.userDesktopDirectory), "*.bin", true)
          fileRead 	= File(f)
                      tbin={}
                      local buf	= MemoryBlock()
                      fileRead:loadFileAsData(buf)
                      buf:toLuaTable (tbin)
                      for i,v in pairs(lookupTable) do
          panel:getModulatorByName(v[1]):getComponent():setValue(tbin,true))
          --Set to false if you don't want the value sent
          end
          

          Each modulator would have a cc code setting on the panel, so the modulator sends individual cc messages. If you wanted to send all these values back to the unit at once then from lua you could do something like something like: (again untested)

          
          myChannel=panel:getProperty("panelMidiOutputChannelDevice")
          add=0xb0+(myChannel-1)
          for i,v in ipairs(lookupTable) do
          cn=v[2] -- cc number
          cv=tbin
              m = CtrlrMidiMessage({add, cn, cv}) 
          	-- os.execute(sleep(100)
              panel:sendMidiMessageNow(m)
          	end
          

          or values from the binary file

          
          myChannel=panel:getProperty("panelMidiOutputChannelDevice")
          add=0xb0+(myChannel-1)
          for i,v in ipairs(lookupTable) do
          cn=v[2] -- cc number
          cv=tbin
              m = CtrlrMidiMessage({add, cn, cv}) 
          	-- os.execute(sleep(100)
              panel:sendMidiMessageNow(m)
          	end
          

          This loop could be run inside a timer if it transfers too fast. or e.g. os.execute(sleep(400))

          • This reply was modified 5 years, 5 months ago by dnaldoog.
          #96766
          arcangeli
          Participant
            • Topics: 9
            • Replies: 21
            • Total: 30

            Thanks 🙂
            I’ll try to do the lua Table without saving next week.
            Saving as binary file seem to be more simpler than converting to csv.

          Viewing 4 posts - 1 through 4 (of 4 total)
          • The forum ‘Programming’ is closed to new topics and replies.
          There is currently 0 users and 62 guests online
          No users are currently active
          Forum Statistics
          Threads: 2,495, Posts: 17,374, Members: 77,605
          Most users ever online was 12 on January 22, 2019 3:47 pm
          Ctrlr