Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This class represents a single primitive audio processing function on the target.  A module consists of the following components: a set of names, input and output pins, variables, and functions.  All of these items exist in MATLAB and many of them have duals on the target itself.

Class Object
Anchor
ClassObject
ClassObject

To create an audio module object, call the function M=awe_module(CLASSNAME, DESCRIPTION)

...

The MATLAB m-file associated with an audio module creates and returns an instance of the module.  The typical function signature for a module m-file is

function M=new_module(NAME, ARG1, ARG2,...)

where NAME is a string module name and ARG1, ARG2, are optional arguments.  Good practice is to set default values for all arguments except NAME.  For example:

Code Block
if (nargin < 2)

...


	ARG1=1;

...


end

...


if (nargin < 3)

...


	ARG2=3;

...


end

The main difference between the MATLAB instantiation function and the C constructor is that the C constructor is responsible for all memory allocation.  MATLAB, on the other hand, has the option of doing memory allocation in the prebuild function.

...

This function provides a MATLAB implementation of the module's processing function.  The function signature is:

function [M, WIRE_OUT]=new_process(M, WIRE_IN)

where:

  • M

...

  • is the @awe_module object.

  • WIRE_IN

...

  • is a cell array of corresponding to the input data to be processed by the module.

Note that M serves as both an input argument and output result of the function.  The function modifies the state variables within M and then returns the updated object.  WIRE_OUT is a cell array containing the output data.

Each element within the WIRE_IN cell array is an MxN matrix representing the input data at a particular pin.  Each column of the input data represents a different channel.  The audio data is processed and the result written to WIRE_OUT.  For example, the processing function for the scaler_module.m computes

Code Block
function [M, WIRE_OUT]=scaler_process(M, WIRE_IN)

...

 



WIRE_OUT=cell(size(WIRE_IN));

...

 

...


 
for i=1:length(WIRE_OUT)

...


    WIRE_OUT{i}=WIRE_IN{i}*M.gain;

...

end

 


end
 
return;

One difference between MATLAB and C is that the wires in MATLAB serve only to pass data in and out of the processing function.  Pin information is determined in MATLAB from fields in the audio module structure.  For example, to determine the sample rate of the first input, use

M.inputPin{1}.type.sampleRate

whereas in C, you would use

SR = (float) ClassWire_GetSampleRate(pWires[0]);

.setFunc

Implements the main control functional for a module.  This function is called whenever a variable within the audio module is updated.  The function signature is:

function M=new_set(M)

where:

  • M

...

  • is the @awe_module object.

Note that the MATLAB set function does not have a MASK argument indicating which variable changed.

...

Implements secondary control functionality.  This function is called when a variable in the module is read.  The function signature is identical to the .setFunc

function M=new_get(M)

where:

  • M – is the @awe_module object.

.bypassFunc

Provides a custom bypass function for a module.  The function signature is identical to the .processFunc

function [M, WIRE_OUT]=new_bypass(M, WIRE_IN)

where:

  • M – is the @awe_module object.

  • WIRE_IN – a cell array of corresponding to the input data to be processed by the module.

.preBuildFunc

This function is called when a system is built for execution on a target.  The function updates any internal variables which depend upon the sample rate, block size, or number of channels.  The function also implements non-standard pin propagation functionality.  The function signature is:

function M=new_prebuild(M)

where:

  • M

...

  • is the @awe_module object.

The function updates and returns the module object M.

...

This function computes the frequency response of the system. The function signature is:

function H_OUT=new_freq_response(M, H_IN, W)

where:           

  • M

...

  • is the @awe_module object.

...

  • H_IN

...

  • is a cell array of corresponding to the input data.

...

  • W

...

  • is a vector of frequencies at which frequency response to be computed.

...

  • H_OUT

...

  • is a cell array of frequency response output of corresponding input data.

.textLabelFunc

This is an optional function which returns text labels to be displayed in AWE Designer. The function signature is:

Function L=sof40_cascade_text_label(M)

 

Where,

            M – where:

  • M is the @awe_module object.

...

  • L

...

  • is a cell array of strings with desired text labels in AWE Designer

@awe_subsystem

This class represents both systems and subsystems; they are equivalent and no distinction is made in Audio Weaver.  A subsystem has all of the characteristics of an audio module:  a class name, input and output pins, variables, and associated sub-functions.  In addition, a subsystem contains two other items:

...

Key subsystem functions are described next.

ClassObject

The call to create a new empty subsystem is similar to the call to create a new module described in Section 3.2.1 Class Object.

SYS=awe_subsystem(CLASSNAME, DESCRIPTION);

You have to provide a unique class name and a short description of the function of the subsystem. (To be precise, the CLASSNAME only has to be unique if you are generating C code using the new subsystem class.  Then, the CLASSNAME has to be unique among all of the subsystems and audio modules.)

...