dnaldoog

Forum Replies Created

Viewing 20 posts - 461 through 480 (of 480 total)
  • Author
    Posts
  • in reply to: Demo panel for MIDI receive/transmit routines #73205
    dnaldoog
    Participant
      • Topics: 4
      • Replies: 480
      • Total: 484
      • ★★

      Or this, which is much closer to your original code:

      
      function buildBankA()
      
      --concatenate strings
      
      	local data1=panel:getComponent("lcd_presetData1"):getProperty("uiLabelText")
      	local data2=panel:getComponent("lcd_presetData2"):getProperty("uiLabelText")
      	local data3=panel:getComponent("lcd_presetData3"):getProperty("uiLabelText")
      	local data4=panel:getComponent("lcd_presetData4"):getProperty("uiLabelText")
      
      	tabl_bankA = {}
      
      	tabl_bankA[1]	= data1 -- tostring() not necessary
      	tabl_bankA[2]	= data2
      	tabl_bankA[3]	= data3
      	tabl_bankA[4]	= data4
      
      --concatenate table into single string
      	DatasConcat = table.concat(tabl_bankA," ")
      	console ("DatasConcat : "..DatasConcat)
      
      --make a memory block from the string
      	memB = MemoryBlock(DatasConcat)
      
      --send it to synth
      	panel:sendMidiMessageNow(CtrlrMidiMessage(memB))
      	--console("memBlock :"..memB:toHexString(1))
      
      --send it to lcd
      	panel:getComponent("lcd_bankDataA"):setPropertyString("uiLabelText",""..memB:toHexString(1))
      
      end

      panel:sendMidiMessageNow(CtrlrMidiMessage(DatasConcat )) also works, so there’s no need for the MemoryBlock function

      in reply to: Demo panel for MIDI receive/transmit routines #73204
      dnaldoog
      Participant
        • Topics: 4
        • Replies: 480
        • Total: 484
        • ★★

        Hi Human Fly,

        This code below works and I think you were on the right track (didn’t know about that table.concat function), but I think the problem was the method getPropertyString – getProperty seems to work though. Also for the sendMidi function I think you wrote Memb, should be memB. Interesting!

        function buildBankA()
        
        --add strings to table
        	tabl_bankA = {}
        for i=1,4 do
        local s=L(panel:getComponent("lcd_presetData"..i):getProperty("uiLabelText"))
            table.insert(tabl_bankA,s)
        end
        --concatenate table into single string
        	DatasConcat = table.concat(tabl_bankA, " ")
        --	console (String("DatasConcat : "..DatasConcat))
        --make a memory block from the string
        memB = MemoryBlock(DatasConcat)
        
        --send it to synth
        panel:sendMidiMessageNow(CtrlrMidiMessage(memB))
        console(String("memBlock :"..memB:toHexString(1)))
        
        --send it to lcd
        panel:getComponent("lcd_bankDataA"):setPropertyString("uiLabelText",""..memB:toHexString(1))
        
        end
        in reply to: Callback Error #73145
        dnaldoog
        Participant
          • Topics: 4
          • Replies: 480
          • Total: 484
          • ★★

          That error is due to a change in the code for the latest version, so to fix it try using an older version or if you can do it, go into the lua source code and everywhere you see the word console, put two (minus signs) — in front of console(“….”) – click on save and compile all and it should work

          • console(“message is here”) becomes
          • –console(“message is here”)

          If you want to keep the console message printing to the console window (but maybe you don’t need it) then do:

          • console(String(“message is here”))

          NOTE: must be ‘String’ not ‘string’

          Regards,

          P.S. Oh – I think Human Fly already told you this!

          in reply to: 4 separate on/off switches on same parameter address? #73081
          dnaldoog
          Participant
            • Topics: 4
            • Replies: 480
            • Total: 484
            • ★★

            I think the ‘ipairs’ or ‘pairs’ must be unique to lua, but it is central to any programming language (looping through an array’s index and value), so the syntax will vary from language to language, for example php uses foreach (i as v){} – but if you get into lua you will need to be familiar with ipairs and pairs (there is a difference).

            Regards

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

              Thanks for this and no checksum necessary I see in the case of the PCM-70

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

                Hi Zmix,

                It’s great that you got the uiFixedSlider option worked out.

                I didn’t know you could start with values like 497, and if you are sending sysex from the panel I discovered you can do something like:
                F0 ?? ?? ?? ?? ?? MS LS “checksum here” F7
                to split the bytes into two values MS,LS (which would work on the Roland JD990) much like the function I posted, but then how do you calculate the checksum, without going into lua? For Roland it is ‘z5’ – are you just using that?

                I would be curious to know how you are sending these big values to the PCM-70.
                How are values above 127 split?

                I looked at the manual very briefly. It seems very different from the Roland system and I’m only familiar with that.

                Regards.

                in reply to: 4 separate on/off switches on same parameter address? #73023
                dnaldoog
                Participant
                  • Topics: 4
                  • Replies: 480
                  • Total: 484
                  • ★★

                  Hi Human Fly – arg must be an array or table as it is (usually?) called in Lua. An array is a set of usually related items collected together so you can loop through them.
                  for i,v in ipairs(arg) do...
                  will then loop through the array – i is the position in the array (a counter) starting at 1 and v is the value for that position. Obviously very useful if you have a large number of items to process.

                  For example on page 117 of the Roland D110 manual you could have a lua array of all the parameters in 5-1-2 starting with WG Pitch Coarse as the first item in your table and the last (58th 0x3A -> 0-57) item TVA Env Sustain level. The D110 address of each parameter would be i-1 (the Roland will start at 0, not 1)

                  arrayOfParams={"WG Pitch Coarse",..[insert 56 items here]....,"TVA Env Sustain level"}
                  for i,v in ipairs(arrayOfParams)do
                  console(String("address is: "..string.format("%0.2x",i-1)..": name is "..v))
                  end
                  dnaldoog
                  Participant
                    • Topics: 4
                    • Replies: 480
                    • Total: 484
                    • ★★

                    If I understand correctly you are able to send values 462-562 as sysex to the PCM-70 and it shows 0%-100%.

                    I think all you need to do is change the uiSlider to a uiFixedSlider and then enter the following into the field ‘slider contents’:
                    0%=0
                    1%=1

                    100%=100
                    Now the slider will reflect what you are seeing on the PCM-70.

                    Note: As far as I am aware you can’t enter 0%=452,1%=453 etc. uiFixedSlider always starts from 0. I think uiCombo is the same.

                    …then you may have to write a Lua callback function in the “Called when Modulator Value Changes” that takes the value and adds 462 to it. Set Midi Message Type to none if you have it currently set to “SysEx”. Now you may need that msb,lsb function I posted earlier.

                    mySendSysEx=function(mod,value,source)
                    value=value+462
                    panel:sendMidiMessageNow(CtrlrMidiMessage(
                                    {0xf0, ......value ,0xF7}))
                    end
                    dnaldoog
                    Participant
                      • Topics: 4
                      • Replies: 480
                      • Total: 484
                      • ★★

                      Maybe something like this to split large values greater than 127 into more than one byte?

                      function Add462(mod,value,source)
                              if value > 511 then
                                  MSB=0x03
                                  LSB=value -512
                              elseif value > 255 then
                                  MSB=0x02
                                  LSB=value -256
                              elseif value   > 127 then 
                                  MSB=0x01
                                  LSB=value -128
                              elseif value  < 128 then
                                  MSB=0x00
                                  LSB=value 
                              end
                      		panel:sendMidiMessageNow(CtrlrMidiMessage(
                                      {0xf0, 0x06, 0x00, ???, ???, MSB,LSB,0xF7}))
                      				
                      				end
                      in reply to: 4 separate on/off switches on same parameter address? #73012
                      dnaldoog
                      Participant
                        • Topics: 4
                        • Replies: 480
                        • Total: 484
                        • ★★

                        Hi Human Fly – I realised it was an old post, but I thought just in case you were wilting away all this time 🙂

                        Well, the
                        cs=myChecksumFunction(sumOfa) is (pseudo) code for calculating the checksum. The function myChecksumFunction(sumOfa) would actually look ‘something’ like:
                        myChecksumFunction(0x12, 0x04, 0x00, 0x0c, sumOfa)

                        myChecksumFunction=function(...)
                            local total=0
                            local result=0
                            for i,v in ipairs(arg) do
                                total=total+v --addup all the numbers
                                if(total > 127) then
                                    total=total - 128
                                end
                            end
                            result=128-total
                        	if result== 128 then result = 0 end -- If the result is 128 then substitute a value of 0
                            return result
                        end --function
                        ---------------------------------------------------------
                        • This reply was modified 6 years, 3 months ago by dnaldoog. Reason: minor correction if result == 128
                        in reply to: 4 separate on/off switches on same parameter address? #73000
                        dnaldoog
                        Participant
                          • Topics: 4
                          • Replies: 480
                          • Total: 484
                          • ★★

                          Hi there Human Fly!

                          I would create an array of the buttons, then multiply by 1,2,4, or 8 through a loop adding each button state on/off. They will add up to anything from 0-15. Then just send that value in the sysex.

                          fourButtons = function(--[[ CtrlrModulator --]] mod, --[[ number --]] value, --[[ number --]] source)
                              a={"P1","P2","P3","P4"} --array of buttons
                              m={1,2,4,8} -- multiplier
                              sumOfa=0 --variable to hold multiplied values
                              for i,v in ipairs(a) do
                                  local val=panel:getModulatorByName(v):getModulatorValue()
                                  sumOfa=sumOfa+val*m[ i ]
                                  --add up the values 
                              end --loop
                              console(String(sumOfa))
                              --You then don't even need to do an if // else - just include the sum in the sysex message
                              cs=myCheckSumFunction(0x12, 0x04, 0x00, 0x0c, sumOfa)
                              panel:sendMidiMessageNow(CtrlrMidiMessage({0xf0, 0x41, 0x10, 0x16, 0x12, 0x04, 0x00, 0x0c, sumOfa , cs , 0xf7}))
                          end --function
                          ---------------------------------------------------------
                          myCheckSumFunction=function(...)
                              local total=0
                              local result=0
                              for i,v in ipairs(arg) do
                                  total=total+v --addup all the numbers
                                  if(total > 127) then
                                      total=total - 128
                                  end
                              end
                          
                              result=128-total
                          if result== 128 then result = 0 end -- If the result is 128 then substitute a value of 0
                              return result
                          
                          end --function
                          ---------------------------------------------------------

                          NOTE: the attached panel has a small error “return result,10” in myCheckSumFunction() (but still works – should be just “return result”

                          Attachments:
                          You must be logged in to view attached files.
                          in reply to: console error #72898
                          dnaldoog
                          Participant
                            • Topics: 4
                            • Replies: 480
                            • Total: 484
                            • ★★

                            I found that in the source code headers of version 5.3 there is only:
                            static void console (const String &arg);

                            but in version 5.5 there is:

                            static void console (const String &arg);
                            static void console (const std::string &arg);

                            ctrlr/Source/Lua/JuceClasses/LGlobalFunctions.h

                            so that is probably causing:

                            ERROR: Ambiguous, candidates:
                            void console(String const&)
                            void console(std::string const&)

                            …but what this change represents, I wouldn’t know.

                            • This reply was modified 6 years, 7 months ago by dnaldoog.
                            in reply to: console error #72890
                            dnaldoog
                            Participant
                              • Topics: 4
                              • Replies: 480
                              • Total: 484
                              • ★★

                              console(String(“Hello World”)) should solve the problem

                              in reply to: Roland checksum – how to #72753
                              dnaldoog
                              Participant
                                • Topics: 4
                                • Replies: 480
                                • Total: 484
                                • ★★

                                You’re welcome Human Fly! – took me a while to work out, so I thought I would pass it on. As you can see from the commented code, I too used that web page as a reference.

                                in reply to: Roland checksum – how to #72742
                                dnaldoog
                                Participant
                                  • Topics: 4
                                  • Replies: 480
                                  • Total: 484
                                  • ★★
                                  07/10/2018 Note: see the end of this post for a better formula. This formula returns an incorrect value for numbers adding up to over 256 (although maybe a sysex sent message never adds up to that much?)

                                  The following function calculates and returns a Roland checksum. Pass parameters to it as in:
                                  local cs=myCheckSum(0x06,0x30,0x00,0x4F,0x64) for example
                                  cs = 23 (or 0x17)

                                  myCheckSum=function(...)
                                      --1. Convert the hex values to decimal. (function parameters are automatically converted)
                                      --2. Add the values together, but if the answer to any sum exceeds 127 then subtract 128.
                                      --3. Subtract the final answer from 128.
                                      --4. Convert the resulting value back to hex and use as the checksum.
                                      local total=0
                                      local result=0
                                      for i,v in ipairs(arg) do
                                          total=total+v --add up all the numbers
                                          if(total > 127) then
                                              total=total - 128
                                          end
                                      end
                                  
                                      result=128-total
                                  	if result== 128 then result = 0 end -- If the result is 128 then substitute a value of 0
                                      return tonumber(result,10)
                                  
                                  end --function
                                  ---------------------------------------------------------
                                  • This reply was modified 6 years, 3 months ago by dnaldoog. Reason: correction if result == 128 then return 0 as checksum
                                  • This reply was modified 5 years, 9 months ago by dnaldoog. Reason: formula may return a wrong value for numbers over 256
                                  in reply to: Best way to assign values to modulator #72719
                                  dnaldoog
                                  Participant
                                    • Topics: 4
                                    • Replies: 480
                                    • Total: 484
                                    • ★★

                                    This elaborates on some code Atom posted before – how to generate a list of modulators in your program by name. print() function is optional – can use console() instead.

                                    myGenerateModNames = function()
                                    n = panel:getNumModulators()

                                    for i=0,n-1 do
                                    mod = panel:getModulatorByIndex(i)
                                    local Name= L(mod:getName())
                                    print (i,Name)
                                    end
                                    end — function

                                    print=function(…)
                                    local output=””
                                    for i,v in ipairs(arg) do
                                    v=string.format(“%s”,v)
                                    output = output..” “..v
                                    end
                                    console(String(output))
                                    end –function

                                    myGenerateModNames()

                                    in reply to: [resolved] setting visible name via Lua? #72545
                                    dnaldoog
                                    Participant
                                      • Topics: 4
                                      • Replies: 480
                                      • Total: 484
                                      • ★★

                                      Thanks for this!!

                                      
                                      panel:getModulatorByName("lfo 1"):getComponent():setPropertyString("componentVisibleName", "my Label")
                                      
                                      in reply to: All Lua programming lost!? #72474
                                      dnaldoog
                                      Participant
                                        • Topics: 4
                                        • Replies: 480
                                        • Total: 484
                                        • ★★

                                        Thanks Human Fly and Atom,

                                        Yes, I am sure there must be something in there that causes the panel to not open on re-opening of Ctrlr. In my case I was sure it was cutting and pasting modulators from another panel into groups or tabs, but I couldn’t be sure.

                                        But it hasn’t happened often and I am still constantly impressed with what Ctrlr can do to allow deeper access to these old synths!

                                        in reply to: All Lua programming lost!? #72470
                                        dnaldoog
                                        Participant
                                          • Topics: 4
                                          • Replies: 480
                                          • Total: 484
                                          • ★★

                                          Thanks Possemo – yes I tried all that – even installing a different version – I think in my case it had something to do with tabs and groups, shuffling them around; cutting and pasting etc. It was all working until I closed Ctrlr and re-opened, then nothing, just a blank canvas.

                                          I wonder if there’s a generally agreed upon most stable version of Ctrlr for Windows? I am using 5.3.199 – the latest version seems less stable.

                                          I now do a backup before making any big changes or every few minutes or so.

                                          Still, Ctrlr is quite amazing! A great recent discovery for me.

                                          in reply to: All Lua programming lost!? #72463
                                          dnaldoog
                                          Participant
                                            • Topics: 4
                                            • Replies: 480
                                            • Total: 484
                                            • ★★

                                            ….”I did save this panel yesterday evening just before I quit (went to bed). I usually save every 15 minutes or even more often, especially when I have done a lot of programming.”

                                            Me too!! On windows – all lost when closing Ctrlr and re-opening.

                                            Ctrlr is blank and any attempt to restore using a program like Meld or NotePad++ results in the file not being able to be opened either

                                          Viewing 20 posts - 461 through 480 (of 480 total)
                                          Ctrlr