(8.D.2.2) MultiplexorV2
Overview
General purpose multiplexor
Discussion
This module has a variable number of input pins and routes (or copies) one of these pins to the output pin, while smoothly varying the multiplexor module with fade time between input pin transitions.
This module has built in smoothing to prevent audible clicks when transitioning between input pins. The smoothing is performed using a first order smoother and the variable smoothingTime controls the transition rate. It takes about 3 x smoothingTime for the complete transition to occur.
An optional control pin (Ctrl) is provided (enabled under module Arguments using isControl = true). The first sample value of the control pin is used as the index for the multiplexor input pins; all other values are ignored. The control pin contains an integer value in the range 0 to N-1, where N is the number of audio inputs. If the control value is outside of the allowable range it is clipped to max index (N-1).
Only when the control pin is disabled (isControl = false) the index for the multiplexor input pins can be selected from the Module Inspector (Double clicking on the Module on the designer canvas)
Each audio input pin must have the same number of channels and block size.
The module can also be configured to output zeros between transitions. The variable fadeTime specifies the silence period, in msec, when transitions occur.
Type Definition
typedef struct _ModuleMultiplexorV2
{
ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure
INT32 index; // Specifies which input pin to route to the output. The index is zero based.
FLOAT32 smoothingTime; // Time constant of the smoothing process
FLOAT32 fadeTime; // Silence time in crossfade
INT32 isControl; // Indicates if the index is controlled by an external signal
FLOAT32 smoothingCoeff; // Smoothing coefficient
FLOAT32 oldSrcGain; // Instanteous gain being applied to the old source. This is an internal variable used in the smoothing process
FLOAT32 newSrcGain; // Instanteous gain being applied to the new source. This is an internal variable used in the smoothing process
INT32 fadeState; // State variable for determining when to transitioning between inputs
INT32 fadeStateInit; // Derived from fadeTime, determines number of blocks to wait before switching input pins
INT32 oldIndex; // This is the index that is currently being used
INT32 newIndex; // This is the index being transitioned to
} ModuleMultiplexorV2Class;
Variables
Properties
Name | Type | Usage | isHidden | Default value | Range | Units |
index | int | parameter | 0 | 0 | 0:2 | Â |
smoothingTime | float | parameter | 0 | 10 | 0:100 | msec |
fadeTime | float | parameter | 0 | 0 | 0:100 | msec |
isControl | int | const | 1 | 1 | Unrestricted | Â |
smoothingCoeff | float | derived | 1 | 0.002081 | Unrestricted | Â |
oldSrcGain | float | state | 1 | 1 | Unrestricted | Â |
newSrcGain | float | state | 1 | 0 | Unrestricted | Â |
fadeState | int | state | 1 | 0 | Unrestricted | Â |
fadeStateInit | int | derived | 1 | 0 | Unrestricted | Â |
oldIndex | int | parameter | 1 | 0 | Unrestricted | Â |
newIndex | int | parameter | 1 | 0 | Unrestricted | Â |
Pins
Input Pins
Name: Ctrl
Description: Input pin control signal
Data type: int
Channel range: Unrestricted
Block size range: Unrestricted
Sample rate range: Unrestricted
Complex support: Real
Â
Name: in1
Description: Input signal
Data type: float
Channel range: Unrestricted
Block size range: Unrestricted
Sample rate range: Unrestricted
Complex support: Real and Complex
Â
Name: in2
Description: Input signal
Data type: float
Channel range: Unrestricted
Block size range: Unrestricted
Sample rate range: Unrestricted
Complex support: Real and Complex
Â
Name: in3
Description: Input signal
Data type: float
Channel range: Unrestricted
Block size range: Unrestricted
Sample rate range: Unrestricted
Complex support: Real and Complex
Output Pins
Name: out
Description: Output signal
Data type: float
MATLAB Usage
File Name: multiplexor_v2_module.m
M = multiplexor_v2_module(NAME, ISCONTROL, NUMINPINS)
Creates a multiplexor module that seamlessly switches between inputs.
The module has multiple input pins and switches from one input to another.
The optional control pin is the first pin (when enabled) and determines
which of N inputs is selected. The input pin is an integer value in the
range 0 to N-1.
Arguments:
NAME - name of the module.
ISCONTROL - enables or disables the control pin
NUMINPINS - number of input pins.
All input pins must have the same block size and number of channels.
Note, this verson implements an optional smooth crossfade between inputs.
Â