...
The example library is found in the 📁 <AWE>\AWEModules\Source\Examples directory. Run the main script make_examples.m to generate code for the entire library.
Scaler Module
Anchor | ||||
---|---|---|---|---|
|
This example is contained in the file scaler_example_module.m. It is equivalent to scaler_module.m provided in the Deprecated module library. This module implements a straightforward linear scaler without any smoothing. The module scaler_smoothed_example_module.m implements linear scaler with smoothing. The module has single input pin and single output pin with arbitrary number of channels. This module illustrate the basic components of Audio Weaver module.
...
and the output data is placed into
pWires[1]->buffer
Peak Hold Module
Anchor | ||||
---|---|---|---|---|
|
The peak hold module demonstrates the use of variable size arrays and shows how the constructor function can be specified completely in MATLAB code. The peak hold module has a single multichannel input pin. The module computes the maximum absolute value for each channel on a block-by-block basis. The module records the peak absolute value seen since the module started running and also computes a peak detector with settable attack and decay rates. In many ways, the peak hold module is similar to a meter module working in block-by-block mode. This module is contained within the file peak_hold_example_module.m. A related fixed-point version is found in peak_hold_example_fract32_module.m
...
The C processing function is straightforward and is not shown here. Refer to the file InnerPeakHoldExample_Process.c.
Fader module
Anchor | ||||
---|---|---|---|---|
|
This example teaches how to create a new module class out of a subsystem and shows how to implement a custom bypass function. The fader module has a single mono input pin, a stereo output pin, and 3 internal modules:
...
There is also a fract32 version of this module called fader_example_fract32_module.m See this module for examples of fixed-point processing.
Downsampler Module
Anchor | ||||
---|---|---|---|---|
|
This module downsamples a signal by keeping only one out of every D input samples. This example demonstrates two further techniques used when creating audio modules. First, the module essentially copies 32-bit samples from input to output and doesn't care if the data type is float, fract32, or int. All of these types will work with the same processing function. This is obvious in C but this flexibility must be encoded into the MATLAB scripts. The second technique shown is how to change the block size and sample rate as part of the prebuild function.
...
Note: The shape information is provided as custom svg image. The default shape of the module is rectangle and it can be overwrite with svgImage tag.
Look Ahead Limiter Module
Anchor | ||||
---|---|---|---|---|
|
This example demonstrates some advanced code generation techniques. The look ahead limiter is a dynamics processor which applies a time-varying gain to a signal. The module m-file takes two arguments.
...
The compiled subsystem contains 4 internal modules:
...
Specifying Internal Module Constructor Arguments
If we follow the normal code generation procedure, then the constructor function for the internal delaymsec_module will be:
...
The argument S->maxDelayTime
initializes the internal module achieving the desired effect.
Disambiguating Wire Allocation
If look at the default subsystem including wiring information, we see:
...
By default, the input and output pins are mono and the system ends up using 3 scratch wires:
Code Block |
---|
>> SYS=lah_limiter_example_module('LAH'); |
...
>> SYS=prebuild(SYS); |
...
>> SYS.scratchPin |
...
ans |
...
...
= [1x1 struct] |
...
[1x1 struct] |
...
[1x1 struct] |
This subsystem is designed to operate on an arbitrary number of channels. However, the wire allocation shown above is only applicable when the input is mono. (To see this, consider the MaxAbs module. This module always has a mono output and is assigned to wire #3. The signal path through DelayMsec can be N-channel and is also assigned to wire #3). If this system is run with stereo inputs, then the wire allocation is incorrect and the audio processing will fail.
To fix this problem, force the system input pin to have 2 channels by default.
Code Block |
---|
pinType=SYS.max_abs.inputPin{1}.type; |
...
add_pin(SYS, 'input', 'in', 'Audio Input', pinType); |
...
SYS.inputPin{1}.type.numChannels=2; |
The pin still holds an arbitrary number of channels, but its default value is 2. When the subsystem is now routed, the wires will be allocated as:
...
The system now requires a total of 4 scratch wires, with a new scratch wire, #6 assigned to the output of DelayMsec
. Furthermore, the buffer allocation is now general purpose and will work with any number of input channels.
The last portion of the file is module browser information as explained in scaler module example above.
Code Block |
---|
SYS.moduleBrowser.path = 'Examples'; |
...
SYS.moduleBrowser.image = '../images/E.bmp'; |
...
SYS.moduleBrowser.name = 'Look Ahead Limiter'; |
...
SYS.moduleBrowser.searchTags = 'lah Limiter'; |
...
SYS.shapeInfo.legend = 'Look Ahead Limiter'; |
...
SYS.shapeInfo.size = [10 6]; |