Standalone Lua Not Loading

Home Forums General Programming Standalone Lua Not Loading

This topic contains 9 replies, has 3 voices, and was last updated by dnaldoog dnaldoog 3 weeks, 3 days ago.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #96537
    dnaldoog
    dnaldoog
    Participant
    • Topics: 1
    • Replies: 175
    • Total: 176
    • ★★

    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: 785
    • Total: 864
    • ★★★

    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
    dnaldoog
    dnaldoog
    Participant
    • Topics: 1
    • Replies: 175
    • Total: 176
    • ★★

    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
    dnaldoog
    dnaldoog
    Participant
    • Topics: 1
    • Replies: 175
    • Total: 176
    • ★★

    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
    goodweather
    goodweather
    Participant
    • Topics: 40
    • Replies: 392
    • Total: 432
    • ★★

    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
    dnaldoog
    dnaldoog
    Participant
    • Topics: 1
    • Replies: 175
    • Total: 176
    • ★★

    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
    goodweather
    goodweather
    Participant
    • Topics: 40
    • Replies: 392
    • Total: 432
    • ★★

    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
    dnaldoog
    dnaldoog
    Participant
    • Topics: 1
    • Replies: 175
    • Total: 176
    • ★★

    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
    goodweather
    goodweather
    Participant
    • Topics: 40
    • Replies: 392
    • Total: 432
    • ★★

    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

    #115680
    dnaldoog
    dnaldoog
    Participant
    • Topics: 1
    • Replies: 175
    • Total: 176
    • ★★

    My latest findings:

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

    if panel:getProgramState()==false and if 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 after the initializing function. 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.

    Update 8/21/2019

    *NOTE:: This suggestion isn’t working 100% as I thought — Back to the drawing board!
    • This reply was modified 3 weeks, 3 days ago by dnaldoog dnaldoog.
    • This reply was modified 5 days, 13 hours ago by dnaldoog dnaldoog.
    • This reply was modified 4 days, 12 hours ago by dnaldoog dnaldoog.
    • This reply was modified 3 days, 13 hours ago by dnaldoog dnaldoog.
    Attachments:
    You must be logged in to view attached files.
Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.

There is currently 0 users and 29 guests online
No users are currently active
Forum Statistics
Threads: 2,241, Posts: 15,791, Members: 55,954
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!