Debugging Augustus Loop scripts in Logic/Mainstage

Official support for: expertsleepers.co.uk
Post Reply New Topic
RELATED
PRODUCTS

Post

So, I'm trying to cook up a control scheme that uses long presses and multi-presses to control AL as a looper under MainStage and or Logic Pro X. I _think_ I know what I'm doing in terms of how I'm managing state and I've grabbed a tiny state machine library off Github to help with that but I'm climbing the wall trying to get debugging traces from the console. I've sprinkled print statements throughout the code, but I'm not seeing any of the output I expect. Nor am I seeing any obvious error messages.

However, if I write a suicide.lua script:

Code: Select all

thisFunctionDoesNotExist(1/0)
and place it in the script directory, it dies quietly without, as far as I can tell, emitting anything that I can find via Console.app. When I run that script on the command line, I get attempt to call a nil value ..., but searching for that string in Console finds nothing.

Am I missing something?

Post

I can see Lua output in the console - easier if you filter by process:
Screenshot 2020-09-16 at 10.00.21.png
You do not have the required permissions to view the files attached to this post.

Post

I can see the lua output, no problem. What I can't see are any runtime or compile time errors; at least, not from Logic.

Post

Right. Here's a helpful fragment of code to catch error messages and print them to the logs before rethrowing them.

Code: Select all

if debugging then
  function catch_and_rethrow(func, ...)
     local function parse_pcall_results(succ, err, ...)
        if succ then
           return table.unpack({err, ...})
        else
           print('Caught error: '..err)
           return error(err)
        end
     end
     return parse_pcall_results(pcall(func, ...))
  end
else
  function catch_and_rethrow(func, ...)
    return func(...)
  end
end
Then you can wrap function calls in like so:

Code: Select all

result = catch_and_rethrow(suspect_function, arg1, arg2, ...)
If suspect_function is throwing an error and debugging is truthy, then catch_and_rethrow will catch it, print it out using the lua 'print' function, ensuring the error message reaches the console, and then rethrow the error. If debugging is false, lua's tail call optimisation should means it shouldn't impact performance.

Post

Nice, thanks.

Post

I tracked my problem with the state machine library down to the fact that the lua I was testing it with on the commandline had 'table.unpack', but the lua in AL is an older version that has 'unpack' in the global namespace. Quite tricky to track down when errors weren't being reported.

Post Reply

Return to “Expert Sleepers”