Document toolboxDocument toolbox

(8.D.2.1) 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.

Â