ControlOp
Overview
Control signal operations module
Discussion
The module computes control operations (e.g. control signals from CAN) which are simple arithmetic operations using two input values. The module is controlled via the .packedConf array. The array size is numOps x 3 and there is a single row devoted to each operation:
Column 1 specifies what operation should be performed:
op=0, CONST 0 (out = 0).
op=1, CONST 1 (out = 1).
op=2, Pass through (out = in1).
op=3, Sum (out = in1 + in2).
op=4, Diff (out = in1 - in2).
op=5, Average (out = (in1 + in2) / 2).
op=6, Time Derivative (out = (in1[n] - in1[n-1]) * SR)
op=17, Multiplication (out = in1 * in2).
op=7, Division (out = in1 / in2).
op=8, Const Gain (if (in1 == 0) --> out = undb20("channelIndex2"), else out = undb20("-channelIndex2"))
op=18, Dynamic Gain (out = undb20(in1)).
op=9, Max (in1, in2)
op=10, Min (in1, in2)
op=11, Equal One Pass 2 (if (in1 == 1) --> out = in2, else out = 1)
op=12, Not Equal One Pass 2 (if (in1 != 1) --> out = in2, else out = 1)
op=13, Greater Than, (if (in1 >= in2) --> out = 1, else out = 0)
op=14, Boolean Invert (if (in1 < 0.5) --> out = 1, else out = 0)
op=15, FlipFlop1 - 1 for in1 = 1 until in2 = 1, else output 0
op=16, FlipFlop2 - 1 if in1 = 1 for sample count in in2, else output 0
Column 2 contains the channel index of the first input argument (0-based). Column 3 contains the channel index of the second input argument (0-based).
Example (sum): 0x01 00 03 = Ch 0 + Ch 1 = 65539. Example (sum): 0x00 01 03 = Ch 1 + Ch 0 = 259. Example (mul): 0x02 01 07 = Ch 1 * Ch 2 = 131335.
If an index is out of range or the op is out of range then the module outputs 0 for that operation.
This module supports only control data where block size is 1.
Type Definition
typedef struct _ModuleControlOp
{
ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure
INT32 numOps; // Number of operations to be computed
INT32 numOpsPackedSize; // Size in 4 bytes packed for internal use
INT32 updateActive; // Specifies whether the configuration is updating (=1) or fixed (=0).
INT32* config; // Controls the operations. One row per op.
INT32* packedConf; // Operations configuration with each row packed into a word.
FLOAT32* lastValue; // Previous sample value on all input channels
INT32* firstBlock; // Array of flags set on first block of each channel before lastValue is valid
INT32* triggerPulse; // Array of flags set on in operation 16 to trigger pulse output
INT32* prevTriggerState; // Array of flags set on in operation 16 to trigger pulse output
INT32* outPulseCnt; // Array of pulse high period count in samples for operation 16
INT32* triggerPulse2; // Array of flags set on in operation 15 to trigger pulse output
} ModuleControlOpClass;
Variables
Properties
Name | Type | Usage | isHidden | Default value | Range | Units |
numOps | int | const | 0 | 1 | Unrestricted | |
numOpsPackedSize | int | const | 0 | 1 | Unrestricted | |
updateActive | int | parameter | 1 | 1 | 0:1 | |
config | int* | derived | 0 | [1 x 3] | Unrestricted | |
packedConf | int* | parameter | 0 | [1 x 1] | -2147483648:2147483647 | |
lastValue | float* | state | 1 | [1 x 1] | Unrestricted | |
firstBlock | int* | state | 1 | [1 x 1] | Unrestricted | |
triggerPulse | int* | state | 1 | [1 x 1] | Unrestricted | |
prevTriggerState | int* | state | 1 | [1 x 1] | Unrestricted | |
outPulseCnt | int* | state | 1 | [1 x 1] | Unrestricted | |
triggerPulse2 | int* | state | 1 | [1 x 1] | Unrestricted |
Pins
Input Pins
Name: in
Description: Input signal
Data type: float
Channel range: Unrestricted
Block size range: 1
Sample rate range: Unrestricted
Complex support: Real
Output Pins
Name: out
Description: Output signal
Data type: float
MATLAB Usage
File Name: control_op_module.m
Performs various arithmetic operations that are typically applied
to CAN control inputs. The opreation is applied to the two inputs,
which can be also multichannel. The second argument specifies how many
operations shall be performed. Each result is placed on a separate
output channel.
Arguments:
NAME - name of the module.
NUMOPS - number of operations to compute. By default equals 1.