Help dump !

Home Forums General Programming Help dump !

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

      I’ve take care of  tips in the Lua in Ctrlr – list of frequently used commands post

      but i’ve really a problem to understand how to catch a midi message in lua a dump have naturaly variables so how to get this type of message ? i’ve tried but i’ve error when i dump see the pics…

      -Modulator linked to panel property : LUA panel midi received  What for ?

      -LUA modulator midi send and LUA modulator midi receive What for ? How ?

      More i know more i don’t know :d

       

      Attachments:
      You must be logged in to view attached files.
      #5882
      Hecticcc
      Participant
        • Topics: 25
        • Replies: 160
        • Total: 185
        • ★★

        MidiMessageReceived:getMidiMessage() does not exist, that is why you get the error.
        Also the fx1 string has no use here, my guess is that this is the string you want to receive and then use some of the values of that string?

        The rest of it makes sense, you’ll get there in no time. A few months ago i knew nothing about programming, now i am starting to understand more & more also 😉

        Here’s a little example of what script in the “called when the panel receives a midi message could be like:

        panelMidiReceived = function(midi)

        ID = midi:getLuaData():getByte(7)
        LS = midi:getLuaData():getByte(9)
        MS = midi:getLuaData():getByte(10)

        if ID == 1 then
        if MS == 0 then
        panel:getModulatorByName("modulator-1"):setModulatorValue(LS, true, false, true)
        elseif MS == 1 then
        panel:getModulatorByName("modulator-1"):setModulatorValue(LS+10, true, false, true)
        end
        end

        if ID == 2 then
        panel:getModulatorByName("modulator-2"):setModulatorValue(LS, true, false, true)
        end

        ...
        end

        #5884
        SWB
        Participant
          • Topics: 35
          • Replies: 157
          • Total: 192
          • ★★

          I’m at the moment facing the task of getting preset data from my device and distributing the data to the various modulators on my panel. This example code gets me going! Thanks!

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

            Still not working now it is slighty better the error comes just in the message i want :fx1

            few time before the error comes with the first dump data : prg,sounds,patterns

            This is what i’ve done :

            My main question : must i type the incoming message or i can select just bytes i want from any messages and use” if then ” to presice what message i want like i’ve done  ?

             

            Attachments:
            You must be logged in to view attached files.
            #5918
            SWB
            Participant
              • Topics: 35
              • Replies: 157
              • Total: 192
              • ★★

              From what I can deduct of your code (with my still very meager knowledge of Lua!), it seems that Lua is not getting a valid value to send to your modulator. Correct me if I’m wrong.

              This is the code I use at the moment to get a data byte from a MIDI-in message, convert it to a number value and send that number to set a modulator to that value, in my case an instrument number:

              — get primary instrument number
              modValue_lsb = midi:getLuaData():getByte(53)
              modValue_msb = midi:getLuaData():getByte(54)
              mv1 = string.format(modValue_lsb)
              mv2 = string.format(modValue_msb)
              if mv2 == “4” then
              mv1 = mv1 + 125
              end
              modValue = tonumber(string.format(mv1))
              panel:getModulatorByName(“primaryinstrument”):setModulatorValue(modValue, false, true, false)

              Don’t pay attention to the elements of this code specific for my goal, but look at the conversion functions: ‘string.format’ and ‘tonumber’. Of course I’m not sure this is the perfect way, but it works for me.

              • This reply was modified 11 years, 3 months ago by SWB.
              #5925
              atom
              Keymaster
                • Topics: 159
                • Replies: 2945
                • Total: 3104
                • ★★★★★

                Don’t do things like that, there are specialized classes for this stuff. Like BigInteger for dealing with MSB/LSB, to string conversions and add 125 etc, that’s scary.

                Explaing what you want to achieve i’m sure we can provide a much cleaner solution

                #5928
                Hecticcc
                Participant
                  • Topics: 25
                  • Replies: 160
                  • Total: 185
                  • ★★

                  @ Zeoka,

                   

                  If you use setValue you need only one bool value.

                  Like this:

                  panel:getModulatorByName("modulator-1"):setValue(yourValueHere, true)

                   

                  • This reply was modified 11 years, 3 months ago by Hecticcc.
                  • This reply was modified 11 years, 3 months ago by Hecticcc.
                  • This reply was modified 11 years, 3 months ago by Hecticcc.
                  • This reply was modified 11 years, 3 months ago by Hecticcc.
                  #5935
                  dasfaker
                  Keymaster
                    • Topics: 80
                    • Replies: 793
                    • Total: 873
                    • ★★★

                    Using setValue(int,bool) the message will be sent to the synth always. Sometimes you don’t want this (specially after receiving a dump from the synth). In this cases is better to use setModulatorValue

                    #5937
                    SWB
                    Participant
                      • Topics: 35
                      • Replies: 157
                      • Total: 192
                      • ★★

                      Don’t do things like that, there are specialized classes for this stuff. Like BigInteger for dealing with MSB/LSB, to string conversions and add 125 etc, that’s scary. Explaing what you want to achieve i’m sure we can provide a much cleaner solution

                      I hope you’re referring to my (as it seems) crapy code 😉 What I want to achieve is the following. I want to edit a certain preset, so I send (using a dedicated modulator for this) to my device a message requesting all the parameters of this preset. The device answers by sending all the needed data in one message of 265 bytes. My panel receives this message and because I know exactly where in the message the bytes (always  a lsb and msb pair) are for each parameter, I just ‘get’ these bytes, convert these to a string (in case of a preset name) or to a integer value. These values I send to the concerning modulators. In this way all the modulators have the right values when starting to edit this preset. I got my ideas (for doing it the way I showed in the code) from the panel Emu 1.2 (I believe Hecticcc made it). If you can provide a more efficient and less scary 🙂 code for this, that would be much appreciated!

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

                        Thank you all !

                        Or i use one bool but it will send to synth

                        Or i convert byte to value (i believe i saw this in frequently used command )

                        Or i use setModulatorValue command

                        I will try again and show the script here if it works

                        Big up !

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

                          What i can say, whatever works for you do it. I’m not to judge anyonoes code, the point is that it works and that it’s possibly fast. I just wanted to say that such conversions from pure MIDI data to strings then to numbers are inefficient in term of performance, if you plan on doing things like that in realtime (for example in plugin mode when dragging a slider) you might cause CPU spike that you don’t want. I’ll try to put an example how to deal with larger chunks of memory and how to efficiently get parts from it and use that data.

                          #5954
                          Hecticcc
                          Participant
                            • Topics: 25
                            • Replies: 160
                            • Total: 185
                            • ★★

                            Just wanted to add that the code in my v1.2 panel is indeed not so clean, this was made with my first experiences of using Ctrlr & getting the hang of the whole Lua thing.
                            In the mean time im have learned alot more and although there are many things i still need to learn it is much cleaner already. Try looking at the latest one i posted, there are some parts that still need cleaning up but its getting there 😉

                            @ das,

                            Thanks for pointing out the difference in behaviour in both methods, i was not aware of this.

                            • This reply was modified 11 years, 3 months ago by Hecticcc.
                            #5962
                            SWB
                            Participant
                              • Topics: 35
                              • Replies: 157
                              • Total: 192
                              • ★★

                              … I’ll try to put an example how to deal with larger chunks of memory and how to efficiently get parts from it and use that data.

                              Thanks in advance for this example! In my case I think speed isn’t that much of an issue (yet…), because my Lua-script only loads the preset data in my panel for editing. For sending data to the device I use mainly ‘direct’ sysex messages, without scripting at all or some very very small scripts. This works very well in my case, because I just want to change one modulator at a time to hear the effect on the sound or preset. Sending the final result of my editing I have to rely on the snapshot feature of CTRLR, isn’t it? (I experimented a bit with this feature, but had some inconsistent results, meaning that the device showed receiving other data than were send… But I will dive deeper in this in the near future.)

                              About using strings as numbers. I am studying ‘Programming in Lua’ and noticed (chapter 2.4) that Lua provides automatic conversion of strings to numbers, so that’s why (for example) I confidently added up strings and numbers, but also took the advice to convert strings to numbers using ‘tonumber’ to be on the safe side…

                              Well anyway I’m always open to better  programming resulting in  faster code execution and please be as critical as possible to my programming attempts! I don’t mind at all and I’m used taking in critics!

                               

                              #5974
                              Hecticcc
                              Participant
                                • Topics: 25
                                • Replies: 160
                                • Total: 185
                                • ★★

                                Whilst on the topic of dumps, anyone here has experience with parsing variable lenght dump strings?
                                The Emu Eos does a dump using a header,and then for each of the types of data it sends a “counter” byte stating the number of bytes that will follow for that data type. Once these are passed the next byte is again a “counter” byte, and so on & on, in one giant stream of data.
                                It has a ack/nack/hold system though so it is possible to break it up into several pieces using some timer system i guess…

                                To give you an idea, a fully maxed out preset would be 1,772,606 Bytes – but it is advised to keep then under 64k 😆

                                Until now i have used individual request/response messages using timers to spread out the load, but even with only 1/4th of the total number of parameters in place it is getting a bit messy imo to keep it this way.

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