(8.D.2.5) SampleAndHold
Overview
Sample and hold module
Discussion
An audio rate sample and hold module for use with the Audio Weaver environment. The module has two input pins: trigger and data. The trigger signal block size must be either 1 or the same block size as the input signal. If the trigger signal block size is 1 then the trigger applies to all the samples.
The output samples follow the input samples whenever the trigger sample is not zero. The first zero sample in the trigger holds the prior input sample for output until the next non-zero trigger sample. The module is designed to work with multichannel data.
There are two operating modes. If the trigger pin has a single channel, then the trigger is applied to all of the interleaved data channels. Otherwise, if the trigger has the same number of channels as the data, then a separate trigger is applied to each channel.
Internally, the module stores the sampled data within the value array. This array has 1 sample per input channel.
Type Definition
typedef struct _ModuleSampleAndHold
{
ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure
FLOAT32* value; // Holds the last data value which was sampled. This is an array so that multiple channels can be supported.
} ModuleSampleAndHoldClass;
Variables
Properties
Name | Type | Usage | isHidden | Default value | Range | Units |
value | float* | state | 0 | [1 x 1] | Unrestricted | Â |
Pins
Input Pins
Name: trig
Description: trigger signal
Data type: int
Channel range: Unrestricted
Block size range: Unrestricted
Sample rate range: Unrestricted
Complex support: Real
Â
Name: in
Description: input data
Data type: {float, int, fract32}
Channel range: Unrestricted
Block size range: Unrestricted
Sample rate range: Unrestricted
Complex support: Real
Output Pins
Name: out
Description: output data
Data type: {float, int, fract32}
MATLAB Usage
File Name: sample_and_hold_module.m
M=sample_and_hold_module(NAME)
Creates a sample and hold module for use with the Audio Weaver
environment.
Arugments:
NAME - name of the module.
Â