Allow Lua DSP scripts to override strict-i/o

This is handy for 1in, 2out plugins or 2in, 1in out (and multiples
thereof).
This commit is contained in:
Robin Gareus
2020-07-13 00:52:59 +02:00
parent 9d7ca1dfa9
commit c03f3d81a6
2 changed files with 23 additions and 0 deletions

View File

@@ -85,6 +85,7 @@ public:
void cleanup () { }
int set_block_size (pframes_t /*nframes*/) { return 0; }
bool connect_all_audio_outputs () const { return _connect_all_audio_outputs; }
int connect_and_run (BufferSet& bufs,
samplepos_t start, samplepos_t end, double speed,
@@ -153,6 +154,7 @@ private:
std::string _docs;
bool _lua_does_channelmapping;
bool _lua_has_inline_display;
bool _connect_all_audio_outputs;
void queue_draw () { QueueDraw(); /* EMIT SIGNAL */ }
DSP::DspShm lshm;

View File

@@ -60,6 +60,7 @@ LuaProc::LuaProc (AudioEngine& engine,
, _script (script)
, _lua_does_channelmapping (false)
, _lua_has_inline_display (false)
, _connect_all_audio_outputs (false)
, _designated_bypass_port (UINT32_MAX)
, _signal_latency (0)
, _control_data (0)
@@ -254,6 +255,26 @@ LuaProc::load_script ()
_lua_latency = new luabridge::LuaRef (lua_dsp_latency);
}
/* parse I/O options */
luabridge::LuaRef ioconfig = luabridge::getGlobal (L, "dsp_ioconfig");
if (ioconfig.isFunction ()) {
try {
luabridge::LuaRef iotable = ioconfig ();
if (iotable.isTable ()) {
for (luabridge::Iterator i (iotable); !i.isNil (); ++i) {
if (!i.key().isString()) {
continue;
}
if (i.key().cast<std::string> () == "connect_all_audio_outputs" && i.value().isBoolean ()) {
_connect_all_audio_outputs = i.value().cast<bool> ();
}
}
}
} catch (...) {
return true;
}
}
// initialize the DSP if needed
luabridge::LuaRef lua_dsp_init = luabridge::getGlobal (L, "dsp_init");
if (lua_dsp_init.type () == LUA_TFUNCTION) {