Some code that kill ctrlr and hung up windows

Home Forums General Programming Some code that kill ctrlr and hung up windows

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #440
    darlock
    Participant
      • Topics: 3
      • Replies: 13
      • Total: 16

      Last night i try to made debug panel (based on DEMO – Midi.panel) for sysex transmit and receive from my supernova 2.
      I found that toString function dont work. May be becouse supernova transmitted 2 bulk dumps (297 and 99 bytes) at single programm sysex
      I try to use char conversion but CTRL was unstable and my PC is hunged.

      bugged panel:
      http://www.speedyshare.com/files/302635 … 0v1a.panel

      2 sysex from 1 program request:
      http://www.speedyshare.com/files/30263599/sn1a.syx
      http://www.speedyshare.com/files/30263600/sn1b.syx

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

        This panel is broken, and i’m afraid you broke it using LUA the wrong way. You need to be careful how you use LUA cause you can damage more that just the panel. If you look at the XML of your panel (just open the panel file in any text editor)
        [code:e09wlm5z]
        <modulator modulatorValueExpression="modulatorValue" modulatorValueExpressionReverse="midiValue"
        modulatorIsStatic="1" modulatorGlobalVariable="-1" modulatorMuteOnStart="0"
        modulatorExcludeFromSnapshot="0" modulatorLinkedToPanelProperty="– None"
        modulatorLinkedToModulatorProperty="– None" modulatorLinkedToModulator="– None"
        modulatorBaseValue="0" modulatorCustomIndex="0" modulatorCustomIndexGroup="0"
        luaModulatorValueChange="" modulatorMax="65536" modulatorValue="97"
        vstIndex="22" name="lcd_name" uiLabelText="block22" Label text="block111">
        [/code:e09wlm5z]
        the last property is "Label text" that’s and invalid property and breaks the entire XML document, that causes crashes all over the place. You did this in your lua function assignValues297

        [code:e09wlm5z]
        panel:getModulatorByName("lcd_name"):setPropertyString ("Label text", "block111")
        [/code:e09wlm5z]

        i don’t know where you got the "Label text" property name from, but it’s invalid, all the possible properties for each component/modulator/panel are documented in the API DOcs here: api/namespace_ids.html use only those.

        Also you declared a LUA method like:
        [code:e09wlm5z]
        function Sn2 single program dump req ()
        end
        [/code:e09wlm5z]

        you can’t do that, you need to at least grasp the basics of the LUA programming language (no spaces/tabs/newline in any of the variable,object,function names, ever i don’t think a programming language exists that allows this)

        #3276
        darlock
        Participant
          • Topics: 3
          • Replies: 13
          • Total: 16

          Thanks for answers. I wrote my last program more than 6 years ago. I think that i need some practice and good examples to make good ctrlr panels.
          I have only one question now.
          I tried to load sysex message in uiLCDLabel using yours DEMO – Midi.panel
          My code is similar to yours (differs only size of message):
          My:
          [code:3ev0t66t]midiMessageReceived = function(midiMessage)
          s = midiMessage:getSize()
          if s == 297 then
          out = panel:getModulatorByName("outputLabel")
          out:getComponent():setPropertyString ("uiLabelText", midiMessage:toString())
          console("received program data")
          end
          end[/code:3ev0t66t]
          Yours:
          [code:3ev0t66t]midiMessageReceived = function(midiMessage)
          s = midiMessage:getSize()
          if s == 300 then
          out = panel:getModulatorByName("outputLabel")
          out:getComponent():setPropertyString ("uiLabelText", midiMessage:toString())
          console("received program data")
          end
          end[/code:3ev0t66t]

          But when device send sysex i`m catch error:
          http://www.speedyshare.com/files/30265282/error.jpg

          panel:
          http://www.speedyshare.com/files/302652 … i_ed.panel

          Can you show simple way to display preset names using toString function.
          I make some without toString function:
          [code:3ev0t66t]pND = midiMessage:getLuaData():getRange(10,15) –extract name of preset
          outname = panel:getModulatorByName("lcd_name") –choose component to display
          presetname:getComponent():setPropertyString ("uiLabelText", string.char(pND:getByte(0),pND:getByte(1),pND:getByte(2),pND:getByte(3),pND:getByte(4),pND:getByte(5),pND:getByte(6),pND:getByte(7))) — this is my variant of replacement of notworking setPropertyString ("uiLabelText", pND:toString())[/code:3ev0t66t]
          I know that string.char is not implemented in ctrlr but this work.

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

            here is an example how you can get the ascii string if it’s encoded in the midi message
            [code:3ilam9yx]
            mod = panel:getModulatorByName("modulator-1") — first i find my modulator
            midi = mod:getMidiMessage() — here i fetch it’s midi message (this will be available in the next build but you can use any MIDI message)
            console (midi:toString()) — this is how the message looks like in HEX form
            f0 52 6f 6d 61 6e f7

            ascii = midi:getLuaData():getRange(1, 5) — i’m interested in 5 bytes starting from byte indexed 1 (second byte)
            console (ascii:toString()) — since ASCII conversion is natural, a simple toString() should work

            Roman — and there you go, my name in a MIDI Message
            [/code:3ilam9yx]

            #3278
            darlock
            Participant
              • Topics: 3
              • Replies: 13
              • Total: 16

              This code (output to console) worked fine but i need to dispaly preset name (extracted from sysex dump) in editor.

              [code:38x98niq]presetname = panel:getModulatorByName("labelx")
              presetname:getComponent():setPropertyString ("uiLabelText", pND:toString())[/code:38x98niq]

              I try to use toString function to assign text to label component and receive error.

              Can you provide working example where hex dump is loaded in label as ascii text?

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

                i think this error is because the setPropertyString only takes a std::string and the toString() method return a String (internal juce String class), and since LUA does not know about casting i need to fix that, i’ll make it work with the new build. For now you can try
                [code:1r7illfy]
                text = pND:toString()
                presetname:getComponent():setPropertyString ("uiLabelText", text)
                [/code:1r7illfy]

                #3280
                darlock
                Participant
                  • Topics: 3
                  • Replies: 13
                  • Total: 16

                  I try to use intermediate variable before post my previous post. <img decoding=” title=”Wink” />
                  I`m received similar error:
                  [code:11m70m0q]lua runtime error
                  [C]:-1(method setPropertyString) no matching overload found,
                  candidates:
                  void setPropertyString(CtrlrLuaObject&,std::string
                  const&,std::string const&)[/code:11m70m0q]

                  I`m wait next release.

                  Also i found next bugs:
                  1. Modulators work wrong when synth transmit NRPN. All modullators that tuned to transmit NRPN (cc99,cc98,cc6) affected by NRPN cc99 cc98.
                  For example
                  i used cc99=0 cc98=16 for knob1
                  and cc99=0 cc98=14 for knob2
                  My synth receive this perfectly. But when i`m try to rotate knob1 on my synth in panel rotated knob1 and knob2
                  2. When i use cc or NRPN in modulator and sysex window not empty next time when i`m load panel modulator transmit sysex instead of CC or NRPN

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

                    1. this is true and i really don’t know if working around it is a good idea, a NRPN is built of 4 (or 3) CC messages so what Ctrlr does is valid, but i understand your problem, i’ll try to work around it but i can’t promise anything really it will be hard

                    2. i’ll have a look what’s wrong here.

                    #51987
                    Puppeteer
                    Participant
                      • Topics: 16
                      • Replies: 185
                      • Total: 201
                      • ★★

                      I know this is an old thread, but I was wondering if the API docs are still available somewhere. This link is dead

                      all the possible properties for each component/modulator/panel are documented in the API DOcs here: api/namespace_ids.html use only those.

                      The Puppeteer
                      http://godlike.com.au

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

                        You should always look at the methods what() and how()

                        the how() just print all available regeistered classes

                        what(object)

                        prints all available methods on an object, just use it on a modulator/component/whatever and get some answers

                        #52002
                        Puppeteer
                        Participant
                          • Topics: 16
                          • Replies: 185
                          • Total: 201
                          • ★★

                          I can get what() to run (eg set a push button that runs what(panel))

                          But how(panel) returns this error

                          At line [-1]: [C]
                          What: C
                          Namewhat: global
                          Name: class_names
                          Error message: std::runtime_error: ‘Trying to use unregistered class’

                          This is my function

                          WhatMethod = function(--[[ CtrlrModulator --]] mod, --[[ number --]] value)
                          how(panel)
                          end

                          Is that how it’s supposed to be used?

                          The Puppeteer
                          http://godlike.com.au

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

                            Try to use the Lua Console for this like so:

                            how()
                            what(panel)[ENTER]

                            #52076
                            Puppeteer
                            Participant
                              • Topics: 16
                              • Replies: 185
                              • Total: 201
                              • ★★

                              Hi Atom,

                              how() in the console returns an error

                              ERROR: std::runtime_error: ‘Trying to use unregistered class’

                              what(panel) works fine though.

                              The Puppeteer
                              http://godlike.com.au

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

                                how(panel:getModulatorByName()) gives wich parameters to put and in wich form.it ‘s like you do a LUA error ,this is the way i use how(). not sure it is correct

                                #52087
                                Puppeteer
                                Participant
                                  • Topics: 16
                                  • Replies: 185
                                  • Total: 201
                                  • ★★

                                  Thanks, that works.

                                  The Puppeteer
                                  http://godlike.com.au

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