Document toolboxDocument toolbox

(8.D.2.7) SineSmoothedGen

Overview

Smoothly varying sine wave generator

Discussion

Sine wave generator, with parameters for controling frequency and start phase. This is a source module and requires that you specify the properties of the output pin (number of channels, blockSize, and sample rate) at construction time. The smoothing coefficient allows for changes to the frequency parameter to be exponentially smoothed (first order IIR) at the sample rate.

Internally, this modules uses the sin() function from the C math library. The instantaneous frequency (which is the phase increment between samples) is smoothed on a sample by sample basis. If you do not need smoothed behavior, use the more efficient sine_gen_module.m instead.

Type Definition

typedef struct _ModuleSineSmoothedGen { ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure FLOAT32 freq; // Frequency of the sine wave, in Hz. FLOAT32 smoothingTime; // Time constant of the frequency adjustment operation, in msec. FLOAT32 startPhase; // Starting phase of the sine wave, in degrees. FLOAT32 smoothingCoeff; // Smoothing coefficient. FLOAT32 phase; // Instantanteous phase and also starting phase. FLOAT32 phaseIncTarget; // Target for the sample to sample phase increment. Essentially the target frequency. FLOAT32 phaseInc; // Instantaneous sample to sample phase increment. } ModuleSineSmoothedGenClass;

Variables

Properties

Name

Type

Usage

isHidden

Default value

Range

Units

freq

float

parameter

0

1000

0.01:24000

Hz

smoothingTime

float

parameter

0

10

0:1000

msec

startPhase

float

parameter

0

0

0:360

degrees

smoothingCoeff

float

derived

1

0.002081

Unrestricted

 

phase

float

parameter

1

0

Unrestricted

radians

phaseIncTarget

float

derived

1

0.1309

Unrestricted

radians/sample

phaseInc

float

derived

1

0.1309

Unrestricted

radians/sample

Pins

Output Pins

Name: out

Description: audio output

Data type: float

MATLAB Usage

File Name: sine_smoothed_gen_module.m

M=sine_smoothed_gen_module(NAME, SR, BLOCKSIZE) Creates a sine wave generator for use in the Audio Weaver environment. This module has a single channel output pin with controllable frequency and built in frequency smoothing. Arguments: NAME - name of the module. SR - sample rate. BLOCKSIZE - number of samples per output channel.

Â