Signal Chain#
Signal chain stages allow for the control of signal flow through the pipeline. This includes stages for combining and splitting signals, basic gain components, and delays.
Bypass#
- class audio_dsp.stages.signal_chain.Bypass(**kwargs)
Stage which does not modify its inputs. Useful if data needs to flow through a thread which is not being processed on to keep pipeline lengths aligned.
- process(in_channels)
Return a copy of the inputs.
Control
The Bypass Stage has no runtime controllable parameters.
Fork#
- class audio_dsp.stages.signal_chain.Fork(count=2, **kwargs)
Fork the signal.
Use if the same data needs to be sent to multiple data paths:
a = t.stage(Example, ...) f = t.stage(Fork, a, count=2) # count optional, default is 2 b = t.stage(Example, f.forks[0]) c = t.stage(Example, f.forks[1])
- Attributes:
- forkslist[list[StageOutput]]
For convenience, each forked output will be available in this list each entry contains a set of outputs which will contain the same data as the input.
- class ForkOutputList(edges: Optional[list[audio_dsp.design.stage.StageOutput | None]] = None)
Custom StageOutputList that is created by Fork.
This allows convenient access to each fork output.
- Attributes:
- forks: list[StageOutputList]
Fork duplicates its inputs, each entry in the forks list is a single copy of the input edges.
- get_frequency_response(nfft=512)
Fork has no sensible frequency response, not implemented.
- process(in_channels)
Duplicate the inputs to the outputs based on this fork’s configuration.
Control
The Fork Stage has no runtime controllable parameters.
Mixer#
- class audio_dsp.stages.signal_chain.Mixer(**kwargs)
Mixes the input signals together. The mixer can be used to add signals together, or to attenuate the input signals.
- Attributes:
- dsp_block
audio_dsp.dsp.signal_chain.mixer
The DSP block class; see Mixer for implementation details
- dsp_block
- set_gain(gain_db)
Set the gain of the mixer in dB.
- Parameters:
- gain_dbfloat
The gain of the mixer in dB.
Control
The following runtime control parameters are available for the Mixer Stage:
Command ID macro |
Payload length |
Description |
---|---|---|
CMD_MIXER_GAIN |
|
The current gain in Q_GAIN format. |
Adder#
- class audio_dsp.stages.signal_chain.Adder(**kwargs)
Add the input signals together. The adder can be used to add signals together.
- Attributes:
- dsp_block
audio_dsp.dsp.signal_chain.adder
The DSP block class; see Adder for implementation details.
- dsp_block
Control
The Adder Stage has no runtime controllable parameters.
Subtractor#
- class audio_dsp.stages.signal_chain.Subtractor(**kwargs)
Subtract the second input from the first. The subtractor can be used to subtract signals from each other. It must only have 2 inputs.
- Attributes:
- dsp_block
audio_dsp.dsp.signal_chain.subtractor
The DSP block class; see Subtractor for implementation details.
- dsp_block
Control
The Subtractor Stage has no runtime controllable parameters.
FixedGain#
- class audio_dsp.stages.signal_chain.FixedGain(gain_db=0, **kwargs)
This stage implements a fixed gain. The input signal is multiplied by a gain. If the gain is changed at runtime, pops and clicks may occur.
If the gain needs to be changed at runtime, use a
VolumeControl
stage instead.- Parameters:
- gain_dbfloat, optional
The gain of the mixer in dB.
- Attributes:
- dsp_block
audio_dsp.dsp.signal_chain.fixed_gain
The DSP block class; see Fixed Gain for implementation details.
- dsp_block
- set_gain(gain_db)
Set the gain of the fixed gain in dB.
- Parameters:
- gain_dbfloat
The gain of the fixed gain in dB.
Control
The following runtime control parameters are available for the FixedGain Stage:
Command ID macro |
Payload length |
Description |
---|---|---|
CMD_FIXED_GAIN_GAIN |
|
The gain value in Q_GAIN format. |
VolumeControl#
- class audio_dsp.stages.signal_chain.VolumeControl(gain_dB=0, mute_state=0, **kwargs)
This stage implements a volume control. The input signal is multiplied by a gain. The gain can be changed at runtime. To avoid pops and clicks during gain changes, a slew is applied to the gain update. The stage can be muted and unmuted at runtime.
- Parameters:
- gain_dbfloat, optional
The gain of the mixer in dB.
- mute_stateint, optional
The mute state of the Volume Control: 0: unmuted, 1: muted.
- Attributes:
- dsp_block
audio_dsp.dsp.signal_chain.volume_control
The DSP block class; see Volume Control for implementation details.
- dsp_block
- make_volume_control(gain_dB, slew_shift, mute_state, Q_sig=27)
Update the settings of this volume control.
- Parameters:
- gain_dB
Target gain of this volume control.
- slew_shift
The shift value used in the exponential slew.
- mute_state
The mute state of the Volume Control: 0: unmuted, 1: muted.
- set_gain(gain_dB)
Set the gain of the volume control in dB.
- Parameters:
- gain_dbfloat
The gain of the volume control in dB.
- set_mute_state(mute_state)
Set the mute state of the volume control.
- Parameters:
- mute_statebool
The mute state of the volume control.
Control
The following runtime control parameters are available for the VolumeControl Stage:
Command ID macro |
Payload length |
Description |
---|---|---|
CMD_VOLUME_CONTROL_TARGET_GAIN |
|
The target gain of the volume control in Q_GAIN format. |
CMD_VOLUME_CONTROL_GAIN |
|
The current gain of the volume control in Q_GAIN format. This will slew towards the target gain. |
CMD_VOLUME_CONTROL_SLEW_SHIFT |
|
The shift value used to set the slew rate. See the volume control documentation for conversions between slew_shift and time constant. |
CMD_VOLUME_CONTROL_MUTE_STATE |
|
Sets the mute state. 1 is muted and 0 is unmuted. |
Switch#
- class audio_dsp.stages.signal_chain.Switch(index=0, **kwargs)
Switch the input to one of the outputs. The switch can be used to select between different signals.
- move_switch(position)
Move the switch to the specified position.
- Parameters:
- positionint
The position to which to move the switch. This changes the output signal to the input[position]
Control
The following runtime control parameters are available for the Switch Stage:
Command ID macro |
Payload length |
Description |
---|---|---|
CMD_SWITCH_POSITION |
|
The current switch position. |
Delay#
- class audio_dsp.stages.signal_chain.Delay(max_delay, starting_delay, units='samples', **kwargs)
Delay the input signal by a specified amount.
The maximum delay is set at compile time, and the runtime delay can be set between 0 and
max_delay
.- Parameters:
- max_delayfloat
The maximum delay in specified units. This can only be set at compile time.
- starting_delayfloat
The starting delay in specified units.
- unitsstr, optional
The units of the delay, can be ‘samples’, ‘ms’ or ‘s’. Default is ‘samples’.
- Attributes:
- dsp_block
audio_dsp.dsp.signal_chain.delay
The DSP block class; see Delay for implementation details.
- dsp_block
- set_delay(delay, units='samples')
Set the length of the delay line, will saturate at max_delay.
- Parameters:
- delayfloat
The delay in specified units.
- unitsstr
The units of the delay, can be ‘samples’, ‘ms’ or ‘s’. Default is ‘samples’.
Control
The following runtime control parameters are available for the Delay Stage:
Command ID macro |
Payload length |
Description |
---|---|---|
CMD_DELAY_MAX_DELAY |
|
The maximum delay value in samples. This is only configurable at compile time. |
CMD_DELAY_DELAY |
|
The current delay value in samples. |