Option for a second Stop button

Is there a way to have two ways of stopping playback? I usually use “Stop” with auto return, but often it would be conveniant to have a stopbutton without auto return on a different key. In Cubase I used to make a macro for that an had the second option on the number pad (comma or point).

You could probably make a simple little lua script to do this and assign a keyboard shortcut to it, similar to how you did it in Cubase.

Here’s an example of one of mine that moves the cursor and plays the next region. You can use this as a template and replace the commands I’m using with the one to stop the transport - I’m not sure what the command is but should be easy to find in the Ardour documentation. ardour-scripts/A7/play next region.lua at master · davidhealey/ardour-scripts · GitHub

1 Like

Thank you, I tried but failed. I wonder how you guys know what functions to use…the only related item in the reference was set_auto_return(), which didn’t work (the function wasn’t found), then I stumbled over ToggleAutoReturn, which kind of works, but still doesn’t do what I want and I dont know why. The simple script I came up with:

ardour {
	["type"]    = "EditorAction",
	name        = "Stop right here",
	license     = "MIT",
	author      = "Werner Back",
	description = [[Disables autoreturn, stop transport and reenables autoreturn]]
}

function factory ()
    return function ()
        Editor:access_action ("Transport", "ToggleAutoReturn"); -- disable autoreturn
        Editor:access_action ("Transport", "ToggleRoll"); -- start playback
        Editor:access_action ("Transport", "ToggleAutoReturn"); -- enable autoreturn
    end
end

If I comment out the last ToggleAutoReturn, it works as you’d expect, but of course Auto Return remains off, which I do not want. When I enable the line the script behaves like the normal stop button. It*s as if the both “ToggleAutoReturn” are executed first. How can that be?

Stop w/o auto-return would be:

Session:cfg():set_auto_return (false) 
Session:request_stop (false, true, ARDOUR.TransportRequestSource.TRS_UI)

There is a wrinkle tough… “stop” happens a short time after the request (next process cycle), and auto-return needs to remain disabled until then. One hack would be to just wait for 100ms

ARDOUR.LuaAPI.usleep(100000)
Session:cfg():set_auto_return (true)

Then you can use default roll/stop with auto-return, and the script for a stop w/o return.

1 Like

Thank you very much, that works perfectly. I still wonder what would be the best source of information for things like this?

That’s exactly where I looked. But I don’t understand how to use the information properly. I searched for anything regarding to “auto return” and the only thing I found was set_auto_return(), so I thougt the right way would be to write something like ARDOUR.SessionConfiguration:set_auto_return(false), which gave me an error (something like “function not found”). How do I get from this to what Robin wrote? Or with other words, why is ARDOUR.SessionConfiguration:set_auto_return(false) wrong?

By trial and error, prior art studying and asking around. There’s no comprehensive “guide to do absolutely anything you want with lua in ardour” :).

1 Like

There are subtleties, for sure, in how the Lua scripting environment is set up. For instance, the difference between @x42’s invocation:

and the one you guessed:

ARDOUR.SessionConfiguration:set_auto_return(false)

is that Session is a globally-available namespace for the scripting environment, and its config() function returns the current session instance, which then has a set_auto_return method. The ARDOUR.SessionConfiguration bits in your example are the module and class defining how that instance method works, but they don’t tell you how to get access to the instance.

1 Like