diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2016-09-26 01:26:42 +0200 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2016-09-26 01:49:58 +0200 |
commit | 00deaf779f872253f7ab1395402f7a13c5264e8a (patch) | |
tree | b4a2c8eb798cb786ded17b24a8ca4fc6f21dcf7a | |
parent | 48958218c4bb948a37c819270e77038115a3bbae (diff) | |
download | applause2-00deaf779f872253f7ab1395402f7a13c5264e8a.tar.gz |
LADSPAStream: limited support for multi-channel input streams
* When specified as part of a port-mapping array or list, they
are automatically expanded.
I.e. if `stream` is stereo, LADSPAStream(..., stream) is equivalent to
LADSPAStream(..., stream:demux(1), stream:demux(2))
* This is often handy because stereo input ports are usually
defined consecutively by LADSPA plugins.
-rw-r--r-- | ladspa.lua | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -165,6 +165,10 @@ LADSPAStream = DeriveClass(Stream) -- Every plugin input port must either be mapped or have a default -- value. -- Constants are handled specially and are faster than streams. +-- Multi-channel input streams do not result in muxing of the LADSPAStream, +-- so every input stream must be mono. +-- However, to ease binding the individual channels of a multi-channel +-- stream, they are automatically expanded to consecutive input streams. -- -- Multi-channel output plugins are always muxed. But you may use -- LADSPAStream(...):demux(...) to discard uninteresting output channels. @@ -177,6 +181,26 @@ function LADSPAStream:ctor(file, ...) local input_ports = mangleInputPorts(...) + -- Expand all multi-channel input streams in arrays. + -- This is handy, since often stereo inputs are defined + -- as consecutive input ports. + do + local i = 1 + while i <= table.maxn(input_ports) do + local port = input_ports[i] + + if type(port) == "table" and port.is_a_stream and + port.channels > 1 then + table.remove(input_ports, i) + for c = port.channels, 1, -1 do + table.insert(input_ports, i, port:demux(c)) + end + end + + i = i + 1 + end + end + -- NOTE: The FFI clib is saved in the object -- to keep it alive even though we call only function pointers -- after the constructor. |