Skip to content

FileSink

Overview

Copies the data at the input pin and writes it in an CSV file

Discussion

The file sink module copies the data at the input pin to an .csv file. The copy operation occurs at each block process and thus the data continuously written to file. User has to specify the file path and file name as an argument where output file to be created and written. If the file path is not specified then the default Matlab location, pwd, will be used and if the file name is not specified then the heirarchy name will be used as the file name. The module also expects output format of the data to be written to the file, like float, int or fract32. If it is null then the format will be derived from the input pin type.

The first module argument specifies the directory in which to write the .csv file. The second module argument specifies the file name. The third module argument is a C style prinf format string which specifies how the data should be written. If the format string is empty, then it is set to '%g' for floating-point samples and '%d' for integer and fractional samples.

The first row of the output csv file contins block size, number of chnnels, data type and sample rate of the system. Each row of the output csv file contains the data of each channel of the input pin. The module will work with any data type of both real and complex data.

Module Pack

Advanced

ClassID

classID = 1270

Type Definition

typedef struct _ModuleFileSink
{
ModuleInstanceDescriptor instance;            // Common Audio Weaver module instance structure
INT32 fullFileSize;                           // Size of the array to hold the full file path of the output .csv file
INT32 initialize;                             // Flag which controls initial configurations
INT32* FullFileName;                          // Complete file path of the output .csv file to be written data
INT32* OutputFormatString;                    // Format of the output data to be written to .csv file
INT32* DataType;                              // Data type of the input pin
void * filePtr;                               // File pointer of the output .csv file
} ModuleFileSinkClass;

Variables

Properties

Name Type Usage isHidden Default Value Range Units
fullFileSize int derived 1 6 Unrestricted
initialize int state 1 1 Unrestricted
FullFileName int* parameter 1 [1 x 6] Unrestricted
OutputFormatString int* parameter 1 [1 x 1] Unrestricted
DataType int* parameter 1 [1 x 2] Unrestricted
filePtr void * state 1 Unrestricted

Pins

Input Pins

Name in
Description audio input
Data type {float, int, fract32}
Channel range Unrestricted
Block size range Unrestricted
Sample rate range Unrestricted
Complex support Real and Complex

Matlab Usage

File Name: file_sink_module.m 
 M=file_sink_module(NAME, FILEPATH, FILENAME, FORMATSTRING) 
 Creates a file sink (capture) module for use with the Audio Weaver 
 environment. The module captures a block of input data and writes it into 
 a CSV file which is provided as an argument.   

 Arguments: 
    NAME - name of the module. 
    FILEPATH - File path where the output .csv file will be created. 
    FILENAME - File name of the output .csv file. 
    FORMATSTRING - Format of the data to be written in .csv file.  This is 
    a C style string like %.2f or %d. 

Copyright (c) 2026 DSP Concepts, Inc.