Audio Chains and Splitters
AudioChain
s and Splitter
s allow us to define sequential and parallel effect processing pipelines for audio signals. They are particularly useful in scenarios where multiple effects need to be applied or when different parts of the signal need to be processed independently.
Audio Chain
AudioChain
s are defined as
PulseArchitect.AudioChains.AudioChain
— TypeAudioChain
Represents an audio processing pipeline composed of multiple steps. Each step can be either:
- a
ChainStep
(i.e. a single sequential processing operation), or - a
Vector
ofAudioChain
(representing a parallel branch where the input is split among subchains).
The AudioChain
type supports various input options via its constructors:
Empty Chain: Create an empty audio chain with no processing steps.
chain = AudioChain()
Iterable of Steps: Build an audio chain from an iterable of arguments where each element can be:
- a
ChainStep
, - an
AudioChain
(in which case its steps are flattened into the parent chain), - or a
Function
(which is automatically wrapped into aChainStep
usingchain_step
).
chain = AudioChain(f, some_subchain, g)
- a
Single Function with Keyword Arguments: Shortcut constructor that accepts a single function and optional keyword arguments.
chain = AudioChain(f; multiplier=2)
The AudioChain
is also callable as a function. When invoked on an input (wavevector::Vector{Real}, samplingrate::Int), it processes the input through its sequence of steps.
Splitter
Splitter
allows us to split an audio signal into multiple channels and process each channel separately. It is useful when we need to apply different effects to different parts of the signal.
PulseArchitect.AudioChains.Splitter
— TypeSplitter(weights::Vector{<:Real}, pipelines::Vector)
A splitter that processes an input signal through multiple pipelines concurrently, and then merges the results in a weighted manner.
Fields
weights
: A vector of amplitude weights for each pipeline.pipelines
: A vector of pipelines, each being either anAudioChain
or a function that accepts an input signal and returns a vector of samples.
Constructor
The constructor accepts a vector of weights and a vector of pipelines (which can be functions or AudioChain
objects). It verifies that both vectors have the same length.
Functor
Calling an instance of Splitter
with an input signal will:
- Execute all pipelines concurrently (in parallel) on the input signal.
- Scale each pipeline's output by its corresponding weight.
- Sum the weighted outputs element‐wise to produce the final merged output.
Assumes that all pipelines return arrays of samples of the same length.