13
0

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)
*
* @param s Session Handle
* @param p Identifier or Name of the Processor
* @param s Session Handle
* @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)
*/
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);
/** List all installed plugins */
@ -98,8 +102,12 @@ namespace ARDOUR { namespace LuaAPI {
* @param id Plugin Name, ID or URI
* @param type Plugin Type
* @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
*/
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 = "");
/** set a plugin control-input parameter value

View File

@ -80,6 +80,12 @@ ARDOUR::LuaAPI::nil_processor ()
boost::shared_ptr<Processor>
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) {
return boost::shared_ptr<Processor> ();
@ -108,8 +114,7 @@ ARDOUR::LuaAPI::new_luaproc (Session *s, const string& name)
return boost::shared_ptr<Processor> ();
}
#warning NUTEMPO caller should be able to control time domain
return boost::shared_ptr<Processor> (new PluginInsert (*s, Config->get_default_automation_time_domain(), p));
return boost::shared_ptr<Processor> (new PluginInsert (*s, td, p));
}
boost::shared_ptr<Processor>
@ -209,6 +214,12 @@ ARDOUR::LuaAPI::new_plugin_info (const string& name, ARDOUR::PluginType type)
boost::shared_ptr<Processor>
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) {
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, Config->get_default_automation_time_domain(), p));
return boost::shared_ptr<Processor> (new PluginInsert (*s, td, p));
}
bool

View File

@ -2567,10 +2567,12 @@ LuaBindings::common (lua_State* L)
.addFunction ("nil_proc", ARDOUR::LuaAPI::nil_processor)
.addFunction ("new_luaproc", ARDOUR::LuaAPI::new_luaproc)
.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 ("dump_untagged_plugins", ARDOUR::LuaAPI::dump_untagged_plugins)
.addFunction ("new_plugin_info", ARDOUR::LuaAPI::new_plugin_info)
.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_plugin_insert_param", ARDOUR::LuaAPI::set_plugin_insert_param)
.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;
case AnyTime::Seconds:
return (samplecnt_t) floor (duration.seconds * sample_rate());
return (samplecnt_t) round (duration.seconds * sample_rate());
break;
case AnyTime::Samples: