Standalone Lua Not Loading

Home Forums General Programming Standalone Lua Not Loading

Viewing 20 posts - 1 through 20 (of 31 total)
  • Author
    Posts
  • #96537
    dnaldoogdnaldoog
    Participant
    • Topics: 1
    • Replies: 237
    • Total: 238
    • ★★

    I have a completed panel working (mostly) as a .panel file, but when exported as a (restricted) instance standalone, the panel behaves as if lua is disabled. Any images loaded by lua are missing, but present in APPDATA%/myPanelName. No functions work etc.

    If I then close the standalone program and restart it, it then works perfectly. All images (that lua functions load) are loaded and all functions are working.

    If I load this panel as a .dll VST in Cubase same problem, except this time I cannot restart it and have all the images and lua working, so it’s completely broken there.

    • tried on version 5.3.201, 0.01, 6.04 all same result
    • reinstalled on version 5.3.201, 0.01, 6.04 all same result
    • recreated all png files
    • tried deleting certain png files
    • tried deleting layers (the panel has about 7 layers)
    • disabled various initialising lua functions
    • deleted various uiCustomComponent functions
    • disabled various all functions
    • tried all this on another PC.

    Well I feel like I have tried everything. I get no errors with the .panel and I wonder if there is a way to debug the executable? The log file on the instance doesn’t reveal anything.

    #98010
    dasfaker
    Keymaster
    • Topics: 79
    • Replies: 786
    • Total: 865
    • ★★★

    I would bet this is due to some error in your LUA code. It has happen to me sometimes, everything fine as .panel but LUA not working as .exe, and finally finding some variable missing (using some variable before assigning it’s value).

    A good candidate is method “called before any modulators are created” and all functions, timers, etc… called from it.

    #98026
    dnaldoogdnaldoog
    Participant
    • Topics: 1
    • Replies: 237
    • Total: 238
    • ★★

    Thanks for your response Dasfaker,

    I had actually started a complete rewrite from scratch, but I then I thought the problem may be that I have this function (below) (from Goodweather) in all of my uiCustomComponents. So I went back to the panel only this morning and after removing that function, one of the uiCustomComponents loaded, so I think I am on to it. The other components are still broken, but lua seems to be engaged. I just have to track down some uninitialised (or blocked) variables that aren’t set on loading the panel, or maybe find a missing variable, which is exactly what you are suggesting I think, and I hope I can fix the problem. I had all but given up.

    
    isPanelReady = function()
    
        if panel:getBootstrapState() == false and panel:getProgramState() == false --[[ and allowPopup == 0--]] then
            return (true)
        else
            return (false)
        end
    end --function
    ---------------------------------------------------------
    

    My “called before any modulators are created” only contains a panel:setPropertyInt("panelMidiPauseOut",1) which I don’t think is the problem.

    Well I didn’t think I would get a reply on this one, so I really appreciate your suggestions. It tells me I am probably on the right track. Will post results for future reference here.

    #98147
    dnaldoogdnaldoog
    Participant
    • Topics: 1
    • Replies: 237
    • Total: 238
    • ★★

    I found that if you block a uiCustomComponent from loading (when the panel is run) in a Called When a panel has finished loading function — using panel:getBootstrapState() or panel:getProgramState() — when you run a standalone executable or dll or you block any variables/tables from initialising that are needed by uiCustomComponent, then the program might not load properly as a standalone/dll even if it works perfectly as a panel file. lua functions will/may not work and images loaded by lua will be missing.

    In my case it seemed that lua was disabled entirely, but if you close the program and reopen, then it runs as normal.

    #115525
    goodweathergoodweather
    Participant
    • Topics: 41
    • Replies: 443
    • Total: 484
    • ★★

    Hi,
    I’m just busy to make my first VST versions of my panels and had the problem that no Lua code was launched as dll. Spent the whole afternoon reading the forum about VST preparation.
    Found the issue then found your post here. Didn’t know you referred to my me and my code…

    So, my apologize for the issue…

    I discovered that we should not have getProgramState() in the condition in the isPanelReady function.
    Removing that and thus only using
    if panel:getBootstrapState() == false and bPanelLoaded == true then
    solves the issue.

    I will search further in the forum about the meaning of getProgramState().
    All the startup phase of a panel is still a bit cryptic even if I understand it more and more.

    About the .exe: they will not work the first time you open the panel. They will work fine from second opening.

    I’m using 5.3.201 without any issue.

    #115534
    dnaldoogdnaldoog
    Participant
    • Topics: 1
    • Replies: 237
    • Total: 238
    • ★★

    Hi Goodweather,

    So getProgramState() was the culprit? I never tried removing that from the function you wrote and I was using. That’s a good find!

    To get around the problem, I eliminated the function entirely and instead used a variable which I set to 0 on startup in luaPanelLoaded at the beginning of the function, in my case init().

    allowrunatstartup=0

    At the end of that init() function I run a timer:

    
        timer:setCallback (1,timerCallback) -- allow popups on startup
        timer:startTimer(1,400)
    	

    the timer code is:

    
    function timerCallback(timerId)
        -- Load program timer
        if timerId == 1 then -- ALLOW POPUPS
            allowrunatstartup=1
            timer:stopTimer(timerId)
    		...
    

    In any function that I do not want running at startup, I include the code if allowrunatstartup==1 then ... at the start of that function.

    It seems to work just fine, although in future panels I will probably go back to your function without the getProgramState() check.

    Well hardly any need to apologize – I have repeatedly used code from and been inspired by your DS2 panel, so my thanks to you for that.


    Here is some code I use to generate VST indexes. I make a table _toBeVstIndexed of only the modulators I want indexed. Of course the names must match the actual modulator names exactly. All other modulators and elements will not be VST indexed and not show in the DAW. Run this function once in your luaPanelLoaded startup function when panel is loaded or wherever, then disable it – VST indexes appear to start at zero – I hope it might be of some help.

    Regards,

    
    function generateVstIndex()
        -- DELETED PANELREADY BLOCK#14
        _toBeVstIndexed={
            "PATCHLVL", --[[ Patch level --]]
            "PATCHPAN", --[[ Patch Pan --]]
    		"TONESWITCH1", --[[ TONESWITCH --]]
    		"TONESWITCH2", --[[ TONESWITCH --]]
    		--...continue with all modulators you want indexed
        }
        --[[
         RE-SET VST INDEXES WARNING!! 
        DO NOT START CTRLR WITH THIS FUNCTION 
        ENABLED IN luaPanelLoaded !! 
        --]]
        n = panel:getNumModulators()
        for i=0,n-1 do
            --CLEAR ALL FIRST
            mod = panel:getModulatorByIndex(i)
            mod:setPropertyString("vstIndex",'')
            mod:setPropertyString("modulatorVstExported",'0')
        end
    -- NOW INDEX
        for i,v in ipairs(_toBeVstIndexed)do
            n=panel:getModulatorByName(v)
            n:setPropertyString("vstIndex",tostring(i-1))
            n:setPropertyString("modulatorVstExported",'1')
    --DEBUG INFO
            console(String(string.format("\"%s\", --[[ set to %d--]]",v,i-1)))
        end
    --DEBUG INFO
        console(String("table size="..#_toBeVstIndexed))
    end --function
    --------------------------------------------------------
    
    
    #115541
    goodweathergoodweather
    Participant
    • Topics: 41
    • Replies: 443
    • Total: 484
    • ★★

    We may need to have 2 versions for each panel then: one using getProgramState() check for standalone export and one without for VST export.

    Good that you remembered there was something about that!
    I checked the forum for getProgramState() but didn’t find any info.

    I have now made some VST tests (still need to do more): you can have any number for VST index.
    In my exported panel I have them between 2400 and 2600 and they all went thru without issue.
    Before exporting I just changed my Preferences to set 5000 as Max exported VST params.

    What could be good to do however is to only export the parameters that need automation.
    This is the next test I’ll do: check if everything is working fine with “Don’t export” except for automotion params.

    #115547
    dnaldoogdnaldoog
    Participant
    • Topics: 1
    • Replies: 237
    • Total: 238
    • ★★

    Hi Goodweather,

    I believe if you follow the method I use, setting a variable as off/0/false when initiating the panel then setting it to true/1 in a timer at the end of an init script and then check for false/true in each function you don’t want to trigger when loading, then you don’t need to use panel:getBootstrapState() or panel:getProgramState() at all, thus not having to make two separate panels; standalone and VST. I believe it works very well! Have tested thoroughly myself and an another user has tested it too. See JD-990 panel.

    Regards,

    #115561
    goodweathergoodweather
    Participant
    • Topics: 41
    • Replies: 443
    • Total: 484
    • ★★

    Yep, I may indeed change my panels to take that approach.
    I have already a PanelLoaded method using a bPanelLoaded and it is triggering a timer to show a welcome message.
    So, just need to change my isPanelReady and keep only the check for bPanelLoaded.
    Will definitely try this!
    Thanks

    #115937
    dnaldoogdnaldoog
    Participant
    • Topics: 1
    • Replies: 237
    • Total: 238
    • ★★


    My conclusion is that the best way to stop Called when the modulator value changes functions from firing when loading a panel or VST instance etc is to:

    1. Set a variable panelLoaded=0 either in a function in Called When the Panel has finished loading, or in Called before any modulators are created or perhaps both?
    2. Create a timer that is triggered by a uiButton (can be hidden in a hidden layer) Called when the modulator value changes. This button will be triggered when the panel starts.
      This timer will contain the code panelLoaded=1 (This seems to be necessary for VST and AU instances of a panel on MacOS).
    3. In each Called when the modulator value changes function you want to block from running at startup, include either:
      • if panelLoaded == 0 then return end
      • if panelLoaded == 1 then .. run code .. end

    ISSUES

    1. If a uiImageButton with callback Called when the modulator value changes functions contains any of:
      • utils.infoWindow() etc
      • popUpMenu()
      • AlertWindow()

      … these will appear when another panel is opened in the same session.

    2. To fix this use a function in Called when a mouse is down on this component in a invisible uiButton in a layer directly above the uiImageButton.
    3. This is necessary because Called when a mouse is down on this component doesn’t work with uiImageButton (unless you click on the Modulator Name area!!).
    • This reply was modified 7 months ago by dnaldoogdnaldoog.
    • This reply was modified 7 months ago by dnaldoogdnaldoog.
    • This reply was modified 7 months ago by dnaldoogdnaldoog.
    #117435
    dnaldoogdnaldoog
    Participant
    • Topics: 1
    • Replies: 237
    • Total: 238
    • ★★

    I re-edited a follow up post, but it was deleted from this thread. It seems if you edit a post more than three times it disappears and you cannot repost it again.

    Re-posted below

    #117437
    dnaldoogdnaldoog
    Participant
    • Topics: 1
    • Replies: 237
    • Total: 238
    • ★★

    My latest findings:

    If you want to block certain functions from running at start up running

    if panel:getProgramState()==false and panel:getBootstrapState()==false then ...

    at the head of that function will block functions from running at startup in panel files loaded into Ctrlr, no problem there.

    However compiled VST/AU and standalone instances may not load properly when using these functions.

    My solution was to create a variable e.g allowToRun=0 at the beginning of an initializing function in Called when the panel has finished loading and then at the end of this function run a timer that sets the variable to 1.

    At the beginning of each function you want blocked, include if allowToRun==1 then ... etc.

    This seemed to work for Windows VST and Standalone programs very well, but not in MacOS.

    So my solution for MacOS (which also works in Windows) is to run the timer in a callback function assigned to a uiButton in luaModulatorValueChange. This button can be hidden and is never clicked on by the user. It is triggered when the program loads. This callback will contain the following:

    timer:setCallback (1,timerCallback) 
    -- allowToRun =  1
    timer:startTimer(1,400)

    and the timer code function code:

    
    function timerCallback(timerId)
        -- Load program timer
        if timerId == 1 then
            allowToRun=1
            timer:stopTimer(timerId)
        else ...
    

    When Ctrlr loads, it automatically runs callback functions luaModulatorValueChange assigned to buttons, combos etc.

    Ctrlr does this after the luaPanelLoaded function has loaded. In other words functions checking for allowToRun=1 don’t run on startup because the variable allowToRun is stll 0. The timer then sets allowToRun=1.

    So, in a way this is using the original problem (luaModulatorValueChange functions triggering at startup) to solve the problem. I hope this makes sense!

    See attached panel, which might explain it better.
    Please download new panel Version 2 – 3/18/2020 not old one

    Attachments:
    You must be logged in to view attached files.
    #117446
    goodweathergoodweather
    Participant
    • Topics: 41
    • Replies: 443
    • Total: 484
    • ★★

    I’m using the same technique since long but still I cannot open 2 times the same panel.
    When I will have some time I will dig down into that. Some panels made by others seems to accept that but not mine so there must be something in the code (or maybe that panels made by others do not have any code).

    To come back on what you mention, I have indeed a variable bPanelLoaded = false at panel load.
    Method isPanelReady() checks for bootstrapstate and bPanelLoaded

    --
    -- Check if the panel is not busy to load or receiving a program
    --
    isPanelReady = function()
    
    --	if panel:getBootstrapState() == false and panel:getProgramState() == false and bPanelLoaded == true then
    	if panel:getBootstrapState() == false and bPanelLoaded == true then
    		return (true)
    	else
    		return (false)
    	end
    
    end

    bPanelLoaded = true based on a timer.
    Then at beginning of methods called when the value change, I check for isPanelReady()

    	-- No action while loading a program or if the panel is in bootstrap or program states
    	if bLoadingProgram or not isPanelReady() then
    		return
    	end
    #117447
    goodweathergoodweather
    Participant
    • Topics: 41
    • Replies: 443
    • Total: 484
    • ★★

    Do you know how to use/set the attributes of method with template luaPanelLoaded?

    --
    -- Called when the panel has finished loading
    --
    -- @type the type of instance beeing started, types available in the CtrlrPanel
    -- class as enum
    --
    -- InstanceSingle
    -- InstanceMulti
    -- InstanceSingleRestriced
    -- InstanceSingleEngine
    -- InstanceMultiEngine
    -- InstanceSingleRestrictedEngine
    --
    myNewMethod = function(--[[ CtrlrInstance --]] type)
    end
    #117450
    dnaldoogdnaldoog
    Participant
    • Topics: 1
    • Replies: 237
    • Total: 238
    • ★★

    Hi Goodweather,

    I stopped using panel:getBootstrapState() and panel:getProgramState() as mentioned above. I think they are problematic for VST/AU and Standalone instances.

    Recently I was wondering about setting a unique id for a panel; something like:

    Set in a constructor or initialising function

    
    r=math.random(2,1024)
    block=0
    

    So when you open the panel or the same panel in Ctrlr it should generate a different id for each opened instance, then in a timer on startup or a button as I do it:

    function timerCallback(timerId)
        -- Load program timer
        if timerId == 1 then
            block=r
            timer:stopTimer(timerId)
     ...
    

    then in the function you want to stop at load…

    x= function()
    if block == r then
    
    --run function code
    
    end
    end

    I haven’t tried it, but might try it soon to see if it works.

    PS just testing this and it doesn’t work. Will keep trying

    #117451
    dnaldoogdnaldoog
    Participant
    • Topics: 1
    • Replies: 237
    • Total: 238
    • ★★

    Do you know how to use/set the attributes of method with template luaPanelLoaded?

    --
    -- Called when the panel has finished loading
    --
    -- @type the type of instance beeing started, types available in the CtrlrPanel
    -- class as enum
    --
    -- InstanceSingle
    -- InstanceMulti
    -- InstanceSingleRestriced
    -- InstanceSingleEngine
    -- InstanceMultiEngine
    -- InstanceSingleRestrictedEngine
    --
    myNewMethod = function(--[[ CtrlrInstance --]] type)
    end

    I couldn’t find anything. It looks important or potentially very useful, but I can’t see how to use it!

    #117452
    dnaldoogdnaldoog
    Participant
    • Topics: 1
    • Replies: 237
    • Total: 238
    • ★★

    Hi Goodweather,

    See panel below.

    I can block an infoWindow from blocking on startup, hence a function from running, but when I open a second instance it pops up. If I open a third instance the original first window pops up.

    My workaround for this has been to put the function in a MouseDown Callback.

    It would be great to discover if each panel opened in the same session has some kind of unique id.

    Regards.

    Attachments:
    You must be logged in to view attached files.
    #117461
    goodweathergoodweather
    Participant
    • Topics: 41
    • Replies: 443
    • Total: 484
    • ★★

    On my side, using “if panel:getBootstrapState() == false and bPanelLoaded == true” works fine in all cases (standalone, VST, AU). The only thing not ok (even in Ctrlr directly) is to open the same panel several times.
    I have also been thinking about a unique identifier by panel instance and your idea above is good.
    I will try it from a simple panel to a more complicated one with indeed some popups, Save…

    I was interested in the uiPanelLoad attributes to try finding that uique ID hoping it is created by Ctrlr.
    I found this function that I will try using: String getPanelInstanceID()

    Curious to see if it will be different for 2 instances of the same panel.

    Will try during the w-e…

    #117465
    dnaldoogdnaldoog
    Participant
    • Topics: 1
    • Replies: 237
    • Total: 238
    • ★★

    panel:getProperty("panelIndex")

    I found this changed from 0 for the first panel to 1 for the second, but it still didn’t block code from running in the first instance when the second was loaded.

    But logically you could do:

    if panel:getProperty("panelIndex") == 0 then
    -- run code
    end

    but the second instance wouldn’t be able to run code in theory. I tried this but no change. It’s as if Ctrlr sees two loaded programs as one in some areas.

    #117468
    goodweathergoodweather
    Participant
    • Topics: 41
    • Replies: 443
    • Total: 484
    • ★★

    Drives me nuts…
    Here is my test panel.
    It fires Rename when you open a second instance…grrrr

    Will post a bug to Roman, maybe we will get some answer

    Attachments:
    You must be logged in to view attached files.
Viewing 20 posts - 1 through 20 (of 31 total)
  • You must be logged in to reply to this topic.
There is currently 1 user and 24 guests online
igor.mathez
Forum Statistics
Threads: 2,310, Posts: 16,191, Members: 59,569
Most users ever online was 12 on January 22, 2019 3:47 pm
Do NOT follow this link or you will be banned from the site!