TriggeredFileSink
Overview
Writes data to a WAV file when triggered
Discussion
This modules writes a few seconds of audio to a file once the trigger signal is asserted. This module only works under Windows and Linux and is not available on embedded targets. You specify the number of seconds to record as a module argument. The module records any number of channels and the first written is in WAV format with 32-bit integer samples. The module accepts any type of input audio data and converts to fract32 as it is recording.
The module has two input pins. The first is the trigger and has 1 channel of integer data. When the first sample of the trigger signal is non zero, the module will start storing data to an internal state buffer. The module stores data for the number of seconds specified as a module argument. Once the data is stored, the data will be written to the output file in the module's set function. After the WAV file is written the module can be triggered again.
Type Definition
typedef struct _ModuleTriggeredFileSink
{
ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure
INT32 fileIndex; // Index of file to record
INT32 samplesStored; // Number of samples stored in the state buffer
INT32 recordingActive; // Indicates whether we are actively recording a file
INT32 errorCode; // Return error condition
FLOAT32 duration; // Length of each recording, in seconds
INT32 durationSamples; // Length of each recording, in samples
INT32 fullFileSize; // Size of the array to hold the full file path of the output .wav file
INT32 dataType; // Data type of the input pin
INT32* fullFileName; // Complete file path of the output .wav file to be written data
fract32* state; // Stores data prior to writing to disk
} ModuleTriggeredFileSinkClass;
Variables
Properties
Name | Type | Usage | isHidden | Default value | Range | Units |
BlockSize | int | const | 0 | 32 | Unrestricted | Â |
NumChannels | int | const | 0 | 1 | Unrestricted | Â |
SampleRate | float | const | 0 | 48000 | Unrestricted | Â |
IsComplex | int | const | 0 | 0 | Unrestricted | Â |
enable | int | parameter | 1 | 0 | Unrestricted | Â |
value | float* | state | 0 | [32 x 1] | Unrestricted | Â |
yRange | float* | parameter | 0 | [1 x 2] | Unrestricted | Â |
Pins
Input Pins
Name: trigger
Description: triggers recording
Data type: int
Channel range: 1
Block size range: 1
Sample rate range: Unrestricted
Complex support: Real
Â
Name: in
Description: audio input
Data type: {float, int, fract32}
Channel range: Unrestricted
Block size range: Unrestricted
Sample rate range: Unrestricted
Complex support: Real
MATLAB Usage
File Name: triggered_file_sink_module.m
M = triggered_file_sink_module(NAME, DURATION, FILEPATH, BASENAME)
This module writes data to disk for a specified number of seconds. The write
is triggered by an external pin and the file name is incremented each time
allowing multiple files to be written.
Arguments:
NAME - name of the module.
DURATION - duration, in seconds, to record (By default = 1.0 for one
second.)
FILEPATH - File path where the output .csv file will be created.
BASENAME - Base name of the output file. The final file name
used is of the form: BASENAME_0000.wav, BASENAME_0001.wav, etc.
The internal variable .duration controls how many seconds of audio
are recorded per trigger.
Â