Audio Chains and Splitters

AudioChains and Splitters 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

AudioChains are defined as

PulseArchitect.AudioChains.AudioChainType
AudioChain

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 of AudioChain (representing a parallel branch where the input is split among subchains).

The AudioChain type supports various input options via its constructors:

  1. Empty Chain: Create an empty audio chain with no processing steps.

    chain = AudioChain()
  2. 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 a ChainStep using chain_step).
    chain = AudioChain(f, some_subchain, g)
  3. 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.

source

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.SplitterType
Splitter(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 an AudioChain 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:

  1. Execute all pipelines concurrently (in parallel) on the input signal.
  2. Scale each pipeline's output by its corresponding weight.
  3. Sum the weighted outputs element‐wise to produce the final merged output.

Assumes that all pipelines return arrays of samples of the same length.

source