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
Code Block |
---|
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
...
Sample rate range: Unrestricted
Complex support: Real
Output Pins
Name: out
Description: Oscillator output
Data type: float
MATLAB Usage
File Name: oscillator_module.m
...