Document toolboxDocument toolbox

(8.D.2.6) Oscillator

Overview

Numerically-controlled oscillator

Discussion

Implements a discrete-time oscillator by using the input signal to adjust the nominal frequency driving a sinusoid generator. The output is $y[n] = \sin (omega_o nT + \sum_{k=0}^n x[k] + \phi)$ where $\omega_o$ is the nominal frequency in radians/s, T is the sample period and $\phi$ is the starting phase in radians (default is 0).

The internal variable freq caches the nominal frequency in units of radians/second. phase maintains the current phase in radians between blocks

Type Definition

typedef struct _ModuleOscillator { ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure FLOAT32 freqhz; // Nominal oscillator frequency in Hz FLOAT32 startPhase; // Starting phase oscillator in multiples of pi radians FLOAT32 freq; // Current oscillator frequency FLOAT32* phase; // Current oscillator phase } ModuleOscillatorClass;

Variables

Properties

Name

Type

Usage

isHidden

Default value

Range

Units

freqhz

float

parameter

0

0

0:5000

Hz

startPhase

float

parameter

0

0

-1:1

x pi radians

freq

float

state

1

0

Unrestricted

radians/s

phase

float*

state

1

[1 x 1]

Unrestricted

radians

Pins

Input Pins

Name: control

Description: Frequency control input

Data type: float

Channel range: 1

Block size range: Unrestricted

Sample rate range: Unrestricted

Complex support: Real

Output Pins

Name: out

Description: Oscillator output

Data type: float

MATLAB Usage

File Name: oscillator_module.m

This module implements a sinusiodal oscillator whose output frequency is determined by the input signal. It is derived from the sine generator. Arguments: NAME - name of the module. QUAD - true means the output is 2 channels in quadrature

Â