SineGen
Discussion
THIS MODULE IS DEPRECATED AND NOT RECOMMENDED FOR NEW DESIGNS. PLEASE USE THE SineSmoothedGen MODULE INSTEAD.
Sine wave generator, with parameters for controlling frequency and start phase. The module requires setting sample rate and blocksize as input arguments. If the module is instantiated with the optional ISQUAD set to 1, the module will act as a quadrature sine oscillator, with the single output pin sending out the quadrature signal in interleaved form. In quadrature mode, the output contains two interleaved channels with the first channel representing the real portion of the oscillator (cosine), and the second channel representing the imaginary portion (sine). When using the quadrature output, a deinterleave module can be used following the module to separate the sine and cosine outputs.
Internally, the module uses complex rotation around the unit circle to achieve the sine and cosine outputs. The complex vector [stateReal stateImag] has unity magnitude and is repeatedly multiplied by another unity magnitude complex vector [incReal incImag]. [stateReal stateImag] represents the instantaneous phase with stateReal representing the cosine output and stateImag representing the sine output. The initial values of [stateReal and stateImag] are determined by the startPhase parameter. startPhase is specified in degrees. The rotation vector [incReal incImag] determines the frequency of the oscillator: \(\mathrm{incReal} + j \mathrm{incImag} = e^{\frac{j 2 \pi \mathrm{freq}}{\mathrm{sampleRate}}}\)
Module Pack
Deprecated
ClassID
classID = 2043
Type Definition
typedef struct _ModuleSineGen
{
ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure
FLOAT32 freq; // Frequency of the sine wave.
FLOAT32 startPhase; // Starting phase of the sine wave.
FLOAT32 stateReal; // Real part of the complex unity magnitude state variable
FLOAT32 stateImag; // Imaginary part of the complex unity magnitude state variable.
FLOAT32 incReal; // Real part of the complex unity magnitude multiplier.
FLOAT32 incImag; // Imaginary part of the complex unity magnitude multiplier.
} ModuleSineGenClass;
Variables
Properties
| Name | Type | Usage | isHidden | Default Value | Range | Units |
|---|---|---|---|---|---|---|
| freq | float | parameter | 0 | 1000 | 0.01:24000 | Hz |
| startPhase | float | parameter | 0 | 0 | 0:360 | degrees |
| stateReal | float | state | 1 | 1 | Unrestricted | |
| stateImag | float | state | 1 | 0 | Unrestricted | |
| incReal | float | derived | 1 | 0.9914 | Unrestricted | |
| incImag | float | derived | 1 | 0.1305 | Unrestricted |
Pins
Output Pins
| Name | out |
| Description | audio output |
| Data Type | float |
Matlab Usage
File Name: sine_gen_module.m
M=sine_gen_module(NAME, SR, BLOCKSIZE, ISQUAD)
Creates a sine wave 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.
Arguments:
NAME - name of the module.
SR - sample rate.
BLOCKSIZE - number of samples per output channel.
ISQUAD - Boolean specifies that this is a quadrature oscillator with
two separate output pins. The first output pin is the cosine portion
and the second output pin is the sine portion. Default = 0.
Copyright (c) 2026 DSP Concepts, Inc.