Interacting with Audio Weaver Designer0
The most basic way of using the MATLAB API is to get and set parameters in a system that is loaded in Audio Weaver Designer.
Manipulating Parameters
Assume that you have the system "Example1.awd" open in Designer.
Then from the MATLAB prompt, type
GSYS = get_gsys('Example1.awd');
This returns a MATLAB data structure which contains the entire state of the Designer GUI. We won't go into the details here; the only item of interest is the field .SYS which we call the system structure
GSYS.SYS
= NewClass // Newly created subsystem
SYS_toFloat: [TypeConversion]
Scaler1: [ScalerV2]
SOF1: [SecondOrderFilterSmoothed]
FIR1: [FIR]
SYS_toFract: [TypeConversion]
The system structure contains one entry per module in the system. Looking more closely at Scaler1 we see all of the internal parameters of the module:
GSYS.SYS.Scaler1
Scaler1 = ScalerV2 // General purpose scaler with a single gain
gain: 0 [dB] // Gain in either linear or dB units.
smoothingTime: 10 [msec] // Time constant of the smoothing process.
isDB: 1 // Selects between linear (=0) and dB (=1) operation
The first line displays 3 items:
"Scaler1" – the name of the module within the system.
"ScalerV2" – the underlying class name or type of the module.
"General purpose scaler …" – this is a short description of the function of the module.
The next three lines list exposed interface variables that the module contains. A variable may display applicable units in brackets (e.g, [msec]) and have a short description.
To change the gain of the module, type
GSYS.SYS.Scaler1.gain = -6;
The gain change occurs locally in the MATLAB environment; the system in Designer is unchanged. To send the updated system back to Designer, type
set_gsys(GSYS, 'Example1.awd');
If the system in Designer is built and running, then the gain change will also occur on the target processor when the command
GSYS.SYS.Scaler1.gain = -6;
is issued. The system in Designer doesn't have the new gain value but the target processor does. You have to keep this in mind. Changes made by MATLAB update the target processor directly when in tuning mode but don't update the system in Designer until you issue set_gsys.m.
Commonly Used Commands
This section describes commonly used MATLAB commands. More details can be found in subsequent sections.
Showing Hidden Variables
By default, the MATLAB API does not show hidden variables (e.g., filter state variables). If you would like to make these visible, type
global AWE_INFO;
AWE_INFO.displayControl.showHidden = 1;
AWE_INFO is a global variable which controls various aspects of Audio Weaver. The standard view of the SecondOrderFilterSmoothed module is
GSYS.SYS.SOF1
SOF1 = SecondOrderFilterSmoothed // General 2nd order filter designer with smoothing
filterType: 0 // Selects the type of filter that is implemented.
freq: 250 [Hz] // Cutoff frequency of the filter, in Hz.
gain: 0 [dB] // Amount of boost or cut to apply, in dB if applicable.
Q: 1 // Specifies the Q of the filter, if applicable.
smoothingTime: 10 [msec] // Time constant of the smoothing process.
And now with hidden variables shown
GSYS.SYS.SOF1
SOF1 = SecondOrderFilterSmoothed // General 2nd order filter designer with smoothing
filterType: 0 // Selects the type of filter that is implemented.
freq: 250 [Hz] // Cutoff frequency of the filter, in Hz.
gain: 0 [dB] // Amount of boost or cut to apply, in dB if applicable.
Q: 1 // Specifies the Q of the filter, if applicable.
smoothingTime: 10 [msec] // Time constant of the smoothing process.
updateActive: 1 // Specifies whether the filter coefficients are updating
b0: 1 // Desired first numerator coefficient.
b1: 0 // Desired second numerator coefficient.
b2: 0 // Desired third numerator coefficient.
a1: 0 // Desired second denominator coefficient.
a2: 0 // Desired third denominator coefficient.
current_b0: 1 // Instantaneous first numerator coefficient.
current_b1: 0 // Instantaneous second numerator coefficient.
current_b2: 0 // Instantaneous third numerator coefficient.
current_a1: 0 // Instantaneous second denominator coefficient.
current_a2: 0 // Instantaneous third denominator coefficient.
smoothingCoeff: 0.064493 // Smoothing coefficient. This is computed based on the smoothingTime, sample rate, and block size of the module.
state: [2x2 float] // State variables. 2 per channel.
You'll now see derived variables and state variables which are normally hidden from view.
Building Systems
If the system in Audio Weaver Designer is in Design mode, you can build the system using
GSYS = get_gsys('Example1.awd');
GSYS.SYS = build(GSYS.SYS);
and then you can start real-time audio playback with
test_start_audio;
Loading and Saving Designs
Instead of loading the GSYS structure from Designer, you can load it directly from disk
GSYS = load_awd('Example1.awd');
Then when you are done making modifications, save it to disk
save_awd('Example1.awd', GSYS);
Variable Ranges
Audio Weaver variables can have range information associated with them. To view a variables range information, you can type
GSYS.SYS.Scaler1.gain.range
ans =
-24 24
If you try and set a value outside of the allowable range then a warning will occur:
GSYS.SYS.Scaler1.gain = -40;
Warning: Assignment to variable gain is out of range. Value: -40. Range: [-24:24]
> In awe_variable_subsasgn at 64
In awe_module.subsasgn at 86
In awe_module.subsasgn at 128
To change a variables range, simply update the .range field
GSYS.SYS.Scaler1.gain.range = [-50 0];