...
Each audio module has an associated header file ModClassName.h containing a class definition, and a source file ModClassName.c containing the associated class structure and functions. The header and source files are generated by MATLAB, but it is important to understand their contents and how all of the pieces fit together.
...
Data types and Structure Definitions
Let's begin by looking at the class definition for the smoothly varying scaler found in ModScalerSmoothedExample.h:
Code Block |
---|
typedef struct _awe_modScalerSmoothedExampleInstance |
...
{
ModuleInstanceDescriptor instance;
FLOAT32 gain; // Target gain
FLOAT32 smoothingTime; // Time constant of the smoothing process
FLOAT32 currentGain; // Instantaneous gain applied by the module. This is also the starting gain of the module.
FLOAT32 smoothingCoeff; // Smoothing coefficient
} awe_modScalerSmoothedExampleInstance;
...
{
ModuleInstanceDescriptor instance;
FLOAT32 gain; // Target gain
FLOAT32 smoothingTime; // Time constant of the smoothing process
FLOAT32 currentGain; // Instantaneous gain applied by the module. This is also the starting gain of the module.
FLOAT32 smoothingCoeff; // Smoothing coefficient
} awe_modScalerSmoothedExampleInstance; |
The first field, "instance", is the common header used by all audio modules and the type ModuleInstanceDescriptor is defined in
...
Framework.h contains the primary data types and definitions used by Audio Weaver. Most of the definitions are used internally by the Server, but a few apply to audio modules.
...
Module Instance Structure
Following the instance header are all of the module specific variables. Only 8 types of module variables are currently supported:
...
ClassModule_GetModuleState(S) – returns the module's run-time state. ACTIVE=0, BYPASSED=1, MUTED=2, and INACTIVE=3.
...
Pins and Wires
A wire in Audio Weaver contains more than just audio samples. A wire is defined as:
...
Both of the module examples use a set of "vector" functions to perform the actual computation. It is possible to perform the computation within the module's processing function – many modules do this. For some modules, however, we have chosen to use vector functions since smaller functions may be more easily optimized in assembly and a single function may be reused by multiple modules. For example, Vec_Scale() is used by the scaler_module.m, scalern_module.m, and scaler_db_module.m. Thus, by optimizing a single function vector for a target processor we obtain 3 optimized modules.
...
Class Object and Constructor Functions
The module constructor function is called in response to a create_module command sent from the Server to the target. A module's constructor function is called once per module instance and is responsible for allocating memory for the module and copying arguments from the create_module command into the instance structure.
...
The Biquad module was used as an example to illustrate the constructor function because it requires an array to be allocated. If the Constructor function pointer in the module's class structure is set to NULL, then the generic module constructor is called. The generic constructor simply calls BaseClassModule_Constructor() and is sufficient for modules that do not require additional memory allocation outside of the instance structure or other custom initialization. The generic constructor is sufficient for a large number of modules and reduces the code size of the target executable.
...
Memory Allocation using awe_fwMalloc()
Dynamic memory allocation is accomplished in Audio Weaver by the function awe_fwMalloc(). To avoid memory fragmentation, memory can only be allocated but never individually freed. You can only free all memory completely using the destroy command and then start again.
...