add a parameter to : getModulatorValuesAsData() method

Home Forums General Programming add a parameter to : getModulatorValuesAsData() method

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #27082
    zeoka
    Participant
      • Topics: 73
      • Replies: 466
      • Total: 539
      • ★★★

      Hi Atom
      Is this possible to add a range value to your method :
      panel:getModulatorValuesAsData(PROPERTY, CtrlrPanel.EncodeNormal, START INDEX,RANGE, false) ??
      This is complicated without.. even that doesn’t work as your panel example
      There is no problem with the inverse method : setModulatorValuesFromData()

      Thank you

      #27097
      atom
      Keymaster
        • Topics: 159
        • Replies: 2945
        • Total: 3104
        • ★★★★★

        What range would that be ? Range of modulators, range of property values ?

        Also, the return value of the call is a MemoryBlock you can cut it up as you wish (take only parts of it).

        #27110
        zeoka
        Participant
          • Topics: 73
          • Replies: 466
          • Total: 539
          • ★★★

          Hi Atom
          Yes a range indexes or prop values
          ex : start from index 3 , up to index 6
          panel:getModulatorValuesAsData(“vstIndex, CtrlrPanel.EncodeNormal, 3,3, false)

          Actually my 3 last mods have index 7,8,9 and not exported
          except a custom mod with index 10
          I do panel:getModulatorValuesAsData(“vstIndex, CtrlrPanel.EncodeNormal, 7, false)
          the result is not ex : 00 7f 50
          but something like ff 00 00 00 00 00 00 00 00 ……………………………….

          even that could be practicle to do other “call bytes” with other mods

          #27194
          atom
          Keymaster
            • Topics: 159
            • Replies: 2945
            • Total: 3104
            • ★★★★★

            I’ve add a third variation for this method:

            LMemoryBlock CtrlrPanel::getModulatorValuesAsData(const String &propertyToIndexBy,
                                                                const CtrlrByteEncoding byteEncoding,
                                                                const int propertyValueStart,
                                                                const int howMany,
                                                                const int bytesPerValue, 
                                                                const bool useMappedValues)

            it should do what you asked for

            #27214
            zeoka
            Participant
              • Topics: 73
              • Replies: 466
              • Total: 539
              • ★★★

              Thank you Atom !
              That’s very complete now 🙂

              #31126
              zeoka
              Participant
                • Topics: 73
                • Replies: 466
                • Total: 539
                • ★★★

                It looks that something is wrong
                I type start byte ex 0 , range ex:2 and 1 but I’ve some strange things
                LUA>> 9
                LUA>> 0
                LUA>> 2
                LUA>> 0
                LUA>> 0
                LUA>> 0
                LUA>> 51
                LUA>> 4
                LUA>> 0
                LUA>> 0
                LUA>> 0
                LUA>> 0
                LUA>> 0
                LUA>> 5
                LUA>> 14
                LUA>> 33
                LUA>> 0
                this is the length of my 17 blocks

                LUA>> ff 68 00 00 00 00 00 00 00
                LUA>>
                LUA>> 00 00
                LUA>>
                LUA>>
                LUA>>
                LUA>> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 00 00 40 00 40 00 23 01 01 52 65 00 00 02 00 2a 7f 2a 00 02 00 01 25 09 00 00 29 33 55 00 40 6a 00 00 40
                LUA>> 00 00 00 00
                LUA>>
                LUA>>
                LUA>>
                LUA>>
                LUA>>
                LUA>> 00 00 00 00 00
                LUA>> 4d 4f 4f 47 59 20 20 20 20 20 20 20 44 4b
                LUA>> 40 40 03 00 00 04 00 00 00 00 00 00 38 00 00 00 00 40 40 00 00 00 00 00 00 00 00 00 00 00 40 40 27
                LUA>>

                this is the data inside

                function loadprg()
                    lm = {}
                	lm[1] = MemoryBlock(panel:getModulatorValuesAsData("vstIndex",CtrlrPanel.EncodeNormal, 0,2,1 ,false))
                	lm[2] = MemoryBlock(panel:getModulatorWithProperty("vstIndex",2):getValue() - 16)
                	lm[3] = MemoryBlock(panel:getModulatorValuesAsData("vstIndex",CtrlrPanel.EncodeNormal, 3,5,1 ,false))
                	lm[4] = MemoryBlock(panel:getModulatorWithProperty("vstIndex",8):getValue() - 16 )
                	lm[5] = MemoryBlock(panel:getModulatorValuesAsData("vstIndex",CtrlrPanel.EncodeNormal, 9,5,1 ,false))
                	lm[6] = MemoryBlock(panel:getModulatorWithProperty("vstIndex",14):getValue() - 16 )
                	lm[7] = MemoryBlock(panel:getModulatorValuesAsData("vstIndex",CtrlrPanel.EncodeNormal, 15,66,1, false))
                    lm[8] = MemoryBlock("00 00 00 00")
                	lm[9] = MemoryBlock(panel:getModulatorValuesAsData("vstIndex", CtrlrPanel.EncodeNormal, 81,3,1 ,false))
                	lm[10] = MemoryBlock(panel:getModulatorWithProperty("vstIndex",84):getValue() - 14)
                	lm[11] = MemoryBlock(panel:getModulatorWithProperty("vstIndex",85):getValue() - 14)
                    lm[12] = MemoryBlock(panel:getModulatorValuesAsData("vstIndex", CtrlrPanel.EncodeNormal, 86,16,1, true))
                    lm[13] = MemoryBlock(panel:getModulatorValuesAsData("vstIndex", CtrlrPanel.EncodeNormal, 102,2, 1 ,false))
                    lm[14] = MemoryBlock("00 00 00 00 00")
                    lm[15] = MemoryBlock()
                    Label = panel:getComponent("SoundName"):getProperty("uiLabelText")
                    for i = 0,13,1 do 
                        s = Label:byte(i+1)
                         if s == nil then 
                            s = 32 
                        end
                        e = string.format("%x",s)
                        d = MemoryBlock(e)
                        lm[15]:insert(d,1,i)
                --console(string.format("%s",	e)) 
                    end
                    lm[16] = glbdat
                    lm[17] = MemoryBlock( panel:getModulatorWithProperty("vstIndex",106):getValue())
                  mydata =  MemoryBlock() 
                     for j = 1,17,1 do 
                        --lm[j] = h
                        --l = h:getSise() 
                        --mydata:append(lm[j],1)
                     --end
                     if lm[j] ~= nil then
                         l = lm[j]:getSize() 
                        --mydata:append(lm[j],l)
                console(string.format("%s",lm[j]:toHexString(1))) 
                end
                end
                end

                at the first block I would have 2 bytes I’ve 9
                the second one block I’ve 0
                only the patch name is correct
                the block 7 seems to be truncated
                etc…
                Atom do you have an idea ?

                `

                #31143
                atom
                Keymaster
                  • Topics: 159
                  • Replies: 2945
                  • Total: 3104
                  • ★★★★★

                  Could you maybe simplify the example. What is the hex block you’d expect, what you are getting and what values the modulators have (maybe a small example with just that in a panel, that would help)

                  #31150
                  zeoka
                  Participant
                    • Topics: 73
                    • Replies: 466
                    • Total: 539
                    • ★★★

                    it seems that the method start at value 1 not 0
                    ex : GetModValAsData setting : 0 start idx ,85 range , 1 bpv , false (valuemapped)
                    it gives : ff 64 00 64 28 7f…..
                    so I set GetModValAsData setting : 1 start idx ,87 range , 1 bpv , false (valuemapped)
                    it gives : 00 00 64 28 7f….
                    correct but first byte is always zero
                    what I call above “vst” is a mod with property vstIndex
                    actually I take vst 1 (byte 0 always 0) to vst 85 (so the vst0 value is taken alone)
                    and vst 81 to vst 85 :
                    by setting GetModValAsData(1,87,1,false) and
                    take bytes by getRange (1,81) and getRange (81,5)
                    for others mods a do loops
                    I can’t use the method with other start byte value than 1 or I have mnany 0 byte to the left of data

                    other problem if I don’t use the method I get trouble to get an hex in string format

                      idx0 = MemoryBlock(panel:getModulatorWithProperty("vstIndex",0):getValue())
                     lm[1] = MemoryBlock(string.format("%s",idx0:toHexString(1))) 

                    I tried %x but it lacks the first 0 when value is < 10 also I have another modulator (idunno why) that don't like at all %x !! that crash Ctrlr

                    #31205
                    zeoka
                    Participant
                      • Topics: 73
                      • Replies: 466
                      • Total: 539
                      • ★★★

                      Ok solved that

                      I’ve build custom scripts for anyone that wants use it
                      call modulators by vst indexes
                      -GetVstMods( 0, 100, false, “memo1”, 0)
                      ———–first byte,lastbyte,valuesMapped=true,blockName,blockID
                      LoadVstMods( “memo1”, 0, false)
                      ————callBlockName,firstModulatorByVstIndex, valuesMapped=true
                      possible to use up to 100 memory blocks

                       function GetVstMods(firstByte, endByte,MappedOrNot,typeName,typeID)
                        if firstByte ~= nil then 
                        if firstByte >= 0 then
                          if endByte ~= nil then
                          if endByte >= firstByte then   
                             if MappedOrNot == true or MappedOrNot == false then  
                                if typeName ~= nil then
                                    if typeID ~= nil then 
                                    if typeID >= 0 then
                                       na = MemoryBlock()
                                       for h = firstByte,endByte,1 do 
                                           md = panel:getModulatorWithProperty("vstIndex", h)
                                           if MappedOrNot == true then 
                                           else a = md:getValueMapped()
                                                a = md:getModulatorValue()
                                       end
                                           if a >= 16 then 
                                              b = MemoryBlock(string.format("%x",a))
                                         else b = MemoryBlock(string.format("0%x",a))
                                          end     
                                              na:insert(b,1,h)
                                       end 
                                   end
                                   end
                               end
                            end
                         end
                         end
                       end
                       end
                              if myBlocks == nil then   
                                 myBlocks = {}
                             end
                              if myNames == nil then   
                                 myNames = {}
                             end
                           myNames[typeID+1] = string.format("%s",typeName)
                           myBlocks[typeID+1] = na 
                         --console(string.format("%s",myBlocks[typeID+1]:toHexString(1)))
                         --console(string.format("%s",myNames[typeID+1]))
                      
                      end
                      function LoadVstMods(nametoGet,startByte,AreValuesMapped) 
                          for p = 1,100,1 do 
                                if  myNames[p] == string.format("%s",nametoGet) then 
                                    console(myNames[p])
                                    console(string.format("%s",myBlocks[p]:toHexString(1)))             
                                    if startByte ~= nil then
                                    if startByte >= 0 then
                                       if AreValuesMapped == true or AreValuesMapped == false then 
                                          panel:setModulatorValuesFromData(myBlocks[p],"vstIndex", CtrlrPanel.EncodeNormal, startByte, 1,AreValuesMapped)         
                                      end
                                   end
                                   end
                               end
                          end
                      end

                      Working
                      If that helps

                      #31208
                      zeoka
                      Participant
                        • Topics: 73
                        • Replies: 466
                        • Total: 539
                        • ★★★

                        added a function that write a data block to another to dump or write file
                        new = MemoryBlock() — the memory block to write here a new
                        CallMyBlocks(“memo1”,new)
                        ____________nameToCall,the memoryblock you want

                        console(string.format(“%s”,(new:toHexString(1)))) — check the data

                        function CallMyBlocks(nameToCall,newBlock)
                            for r = 1,100,1 do 
                                  if  myNames[r] == string.format("%s",nameToCall) then 	
                                    if newBlock ~= nil then 
                                        if newBlock:getSize() > 0 then 
                                           newBlock:setSize(0,false)
                                       end     
                                       newBlock:insert(myBlocks[r],myBlocks[r]:getSize(),0)
                                   end
                                 end
                            end
                        end
                        #31348
                        atom
                        Keymaster
                          • Topics: 159
                          • Replies: 2945
                          • Total: 3104
                          • ★★★★★

                          Good to hear you made it on your own. Since we have a full programming language we can always use that to fix any missing or broken feature in runtime.

                        Viewing 11 posts - 1 through 11 (of 11 total)
                        • The forum ‘Programming’ is closed to new topics and replies.
                        There is currently 0 users and 65 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