(8.D.2.7) PeriodicFunctionGen
Overview
General purpose periodic function generator
Discussion
General purpose function generator, with parameters for controlling frequency, amplitude and start phase. The module can generate Sine wave, Square wave, Triangle wave, Sawtooth wave and Impulse with the control parameter, functionType. If functionType = 0 generates Sine wave, functionType = 1 generates Square wave, functionType = 2 generates Triangle wave, functionType = 3 generates Sawtooth wave, . and functionType = 4 generates Impulse wave.
Type Definition
typedef struct _ModulePeriodicFunctionGen
{
ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure
INT32 functionType; // Type of the wave form to be generated on output
FLOAT32 freq; // Frequency of the function generator output wave.
FLOAT32 amplitude; // Amplitude in linear units.
FLOAT32 offset; // Starting phase of the function generator output wave.
FLOAT32 offsetRad; // Offset in radiuns.
FLOAT32 phase; // Instantanteous phase and also starting phase.
FLOAT32 phaseInc; // Instantaneous sample to sample phase increment.
INT32 impPeriod; // Period or rate of the impulse generator.
INT32 impSampleIndex; // Specifies the index of the next non-zero value.
FLOAT32 triPhase; // Instantanteous phase and also starting phase.
FLOAT32 triPhaseInc; // Instantaneous sample to sample phase increment.
FLOAT32 sawPhase; // The stored phase of the sawtooth function.
FLOAT32 sawPhaseIncrement; // The amount that the oscillator phase is incremented for each output sample.
} ModulePeriodicFunctionGenClass;
Variables
Properties
Name | Type | Usage | isHidden | Default value | Range | Units |
functionType | int | parameter | 0 | 0 | 0:4 | Â |
freq | float | parameter | 0 | 1000 | 0.01:24000 | Hz |
amplitude | float | parameter | 0 | 1 | 0:2 | linear |
offset | float | parameter | 0 | 0 | 0:360 | degrees |
offsetRad | float | derived | 1 | 0 | Unrestricted | Â |
phase | float | state | 1 | 0 | Unrestricted | radians |
phaseInc | float | derived | 1 | 0.1309 | Unrestricted | radians/sample |
impPeriod | int | derived | 1 | 48 | Unrestricted | samples |
impSampleIndex | int | state | 1 | 0 | Unrestricted | Â |
triPhase | float | state | 1 | 0 | Unrestricted | Â |
triPhaseInc | float | derived | 1 | 0.08333 | Unrestricted | Â |
sawPhase | float | state | 1 | 0 | Unrestricted | Â |
sawPhaseIncrement | float | derived | 1 | 0.04167 | Unrestricted | Â |
Pins
Output Pins
Name: out
Description: audio output
Data type: float
MATLAB Usage
File Name: periodic_function_gen_module.m
M=periodic_function_gen_module(NAME, SR, BLOCKSIZE)
Creates a general purpose function generator for use in the Audio Weaver
environment. This module has a single channel output pin with controllable
frequency. The output of the module changes instantly when the frequency
is updated. This module can generate sine wave, square wave, trinagular
wave, sawtooth wave and impulse with control variable.
Arguments:
NAME - name of the module.
SR - sample rate.
BLOCKSIZE - number of samples per output channel.
Â