extend Lua API a little to allow callers to specify time domain for script/plugin automation data

This commit is contained in:
Paul Davis 2021-01-25 14:27:27 -07:00
parent ff77b3eb75
commit 1637c13fbf
4 changed files with 27 additions and 7 deletions

View file

@ -70,10 +70,14 @@ namespace ARDOUR { namespace LuaAPI {
/** create a new Lua Processor (Plugin) /** create a new Lua Processor (Plugin)
* *
* @param s Session Handle * @param s Session Handle
* @param p Identifier or Name of the Processor * @param p Identifier or Name of the Processor
* @param td Time domain (audio or beats) for any automation data
* @returns Processor object (may be nil) * @returns Processor object (may be nil)
*/ */
boost::shared_ptr<ARDOUR::Processor> new_luaproc_with_time_domain (ARDOUR::Session *s, const std::string& p, Temporal::TimeDomain td);
/* As above but uses default time domain for the session/application */
boost::shared_ptr<ARDOUR::Processor> new_luaproc (ARDOUR::Session *s, const std::string& p); boost::shared_ptr<ARDOUR::Processor> new_luaproc (ARDOUR::Session *s, const std::string& p);
/** List all installed plugins */ /** List all installed plugins */
@ -98,8 +102,12 @@ namespace ARDOUR { namespace LuaAPI {
* @param id Plugin Name, ID or URI * @param id Plugin Name, ID or URI
* @param type Plugin Type * @param type Plugin Type
* @param preset name of plugin-preset to load, leave empty "" to not load any preset after instantiation * @param preset name of plugin-preset to load, leave empty "" to not load any preset after instantiation
* @param td Time domain for any automation data
* @returns Processor or nil * @returns Processor or nil
*/ */
boost::shared_ptr<ARDOUR::Processor> new_plugin_with_time_domain (ARDOUR::Session *s, const std::string& id, ARDOUR::PluginType type, Temporal::TimeDomain td, const std::string& preset = "");
/* As above but uses default time domain for the session/application */
boost::shared_ptr<ARDOUR::Processor> new_plugin (ARDOUR::Session *s, const std::string& id, ARDOUR::PluginType type, const std::string& preset = ""); boost::shared_ptr<ARDOUR::Processor> new_plugin (ARDOUR::Session *s, const std::string& id, ARDOUR::PluginType type, const std::string& preset = "");
/** set a plugin control-input parameter value /** set a plugin control-input parameter value

View file

@ -80,6 +80,12 @@ ARDOUR::LuaAPI::nil_processor ()
boost::shared_ptr<Processor> boost::shared_ptr<Processor>
ARDOUR::LuaAPI::new_luaproc (Session *s, const string& name) ARDOUR::LuaAPI::new_luaproc (Session *s, const string& name)
{
return new_luaproc_with_time_domain (s, name, Config->get_default_automation_time_domain());
}
boost::shared_ptr<Processor>
ARDOUR::LuaAPI::new_luaproc_with_time_domain (Session *s, const string& name, Temporal::TimeDomain td)
{ {
if (!s) { if (!s) {
return boost::shared_ptr<Processor> (); return boost::shared_ptr<Processor> ();
@ -108,8 +114,7 @@ ARDOUR::LuaAPI::new_luaproc (Session *s, const string& name)
return boost::shared_ptr<Processor> (); return boost::shared_ptr<Processor> ();
} }
#warning NUTEMPO caller should be able to control time domain return boost::shared_ptr<Processor> (new PluginInsert (*s, td, p));
return boost::shared_ptr<Processor> (new PluginInsert (*s, Config->get_default_automation_time_domain(), p));
} }
boost::shared_ptr<Processor> boost::shared_ptr<Processor>
@ -209,6 +214,12 @@ ARDOUR::LuaAPI::new_plugin_info (const string& name, ARDOUR::PluginType type)
boost::shared_ptr<Processor> boost::shared_ptr<Processor>
ARDOUR::LuaAPI::new_plugin (Session *s, const string& name, ARDOUR::PluginType type, const string& preset) ARDOUR::LuaAPI::new_plugin (Session *s, const string& name, ARDOUR::PluginType type, const string& preset)
{
return new_plugin_with_time_domain (s, name, type, Config->get_default_automation_time_domain(), preset);
}
boost::shared_ptr<Processor>
ARDOUR::LuaAPI::new_plugin_with_time_domain (Session *s, const string& name, ARDOUR::PluginType type, Temporal::TimeDomain td, const string& preset)
{ {
if (!s) { if (!s) {
return boost::shared_ptr<Processor> (); return boost::shared_ptr<Processor> ();
@ -232,8 +243,7 @@ ARDOUR::LuaAPI::new_plugin (Session *s, const string& name, ARDOUR::PluginType t
} }
} }
#warning NUTEMPO caller should be able to control time domain return boost::shared_ptr<Processor> (new PluginInsert (*s, td, p));
return boost::shared_ptr<Processor> (new PluginInsert (*s, Config->get_default_automation_time_domain(), p));
} }
bool bool

View file

@ -2567,10 +2567,12 @@ LuaBindings::common (lua_State* L)
.addFunction ("nil_proc", ARDOUR::LuaAPI::nil_processor) .addFunction ("nil_proc", ARDOUR::LuaAPI::nil_processor)
.addFunction ("new_luaproc", ARDOUR::LuaAPI::new_luaproc) .addFunction ("new_luaproc", ARDOUR::LuaAPI::new_luaproc)
.addFunction ("new_send", ARDOUR::LuaAPI::new_send) .addFunction ("new_send", ARDOUR::LuaAPI::new_send)
.addFunction ("new_luaproc_with_time_domain", ARDOUR::LuaAPI::new_luaproc_with_time_domain)
.addFunction ("list_plugins", ARDOUR::LuaAPI::list_plugins) .addFunction ("list_plugins", ARDOUR::LuaAPI::list_plugins)
.addFunction ("dump_untagged_plugins", ARDOUR::LuaAPI::dump_untagged_plugins) .addFunction ("dump_untagged_plugins", ARDOUR::LuaAPI::dump_untagged_plugins)
.addFunction ("new_plugin_info", ARDOUR::LuaAPI::new_plugin_info) .addFunction ("new_plugin_info", ARDOUR::LuaAPI::new_plugin_info)
.addFunction ("new_plugin", ARDOUR::LuaAPI::new_plugin) .addFunction ("new_plugin", ARDOUR::LuaAPI::new_plugin)
.addFunction ("new_plugin_with_time_domain", ARDOUR::LuaAPI::new_plugin_with_time_domain)
.addFunction ("set_processor_param", ARDOUR::LuaAPI::set_processor_param) .addFunction ("set_processor_param", ARDOUR::LuaAPI::set_processor_param)
.addFunction ("set_plugin_insert_param", ARDOUR::LuaAPI::set_plugin_insert_param) .addFunction ("set_plugin_insert_param", ARDOUR::LuaAPI::set_plugin_insert_param)
.addFunction ("reset_processor_to_default", ARDOUR::LuaAPI::reset_processor_to_default) .addFunction ("reset_processor_to_default", ARDOUR::LuaAPI::reset_processor_to_default)

View file

@ -295,7 +295,7 @@ Session::any_duration_to_samples (samplepos_t position, AnyTime const & duration
break; break;
case AnyTime::Seconds: case AnyTime::Seconds:
return (samplecnt_t) floor (duration.seconds * sample_rate()); return (samplecnt_t) round (duration.seconds * sample_rate());
break; break;
case AnyTime::Samples: case AnyTime::Samples: