Document toolboxDocument toolbox

(8.D.2.1) WaveTableOscillator

Overview

Wave table based oscillator

Discussion

Wave table function generator with input pins to control frequency and phase of the generated wave form. The module can generate sine, square, triangle, sawtooth and custom definable waves via table readout.

The output is, e.g. for a sine: $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 phase in radians (default is 0).

Type Definition

typedef struct _ModuleWaveTableOscillator { ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure INT32 smoothingTime; // Time constant of the pitch smoothing process INT32 smoothingFactor; // Update rate for smoothing coeffs (per block) INT32 numOutPin; // Mono/Stereo INT32 tableSize; // Table size in samples INT32 fIndex; // Current sample index in the wave table FLOAT32 currentFStep; // Current (smoothed) rate at which audio is read from the input buffer FLOAT32 phiIndex; // Current phi index in the wave table FLOAT32 currentPhiStep; // Current (smoothed) phi at which audio is read from the input buffer INT32 tableSize2; // Table size in samples INT32 NCOFracBits; // Number of least-significant bits for the *fractional* part of the NCO word (word size: 32) FLOAT32 smoothingCoeff; // Smoothing (pitch) coefficient FLOAT32 scaleFactorFRatio; // Scale factor for playback rate FLOAT32 scaleFactorPhi; // Scale factor for target phi INT32 NCOIntBits; // Number of most-significant bits for the *integer* part of the NCO word (word size: 32). By default: 20 bits FLOAT32 formatF; // Integer value of left-shift by NCOFracBits. Determines the precision of the linear interpolation. FLOAT32 formatI; // Integer value of left-shift by NCOIntBits. Determines the maximum playback rate and the maximum size of a wave file in samples. FLOAT32* table_coeffs; // Table coefficients INT32* table; // Data transferred from PC to target DSP via this buffer. FLOAT32* table2_coeffs; // Table coefficients INT32* table2; // Data transferred from PC to target DSP via this buffer. } ModuleWaveTableOscillatorClass;

Variables

Properties

Name

Type

Usage

isHidden

Default value

Range

Units

smoothingTime

int

parameter

0

10

1:1000

msec

smoothingFactor

int

parameter

0

4

1:512

 

numOutPin

int

const

0

2

Unrestricted

 

tableSize

int

const

0

1024

Unrestricted

 

fIndex

int

state

0

0

Unrestricted

 

currentFStep

float

state

0

1

Unrestricted

 

phiIndex

float

state

0

0

Unrestricted

 

currentPhiStep

float

state

0

0

Unrestricted

 

tableSize2

int

const

1

1024

Unrestricted

 

NCOFracBits

int

const

1

12

Unrestricted

 

smoothingCoeff

float

derived

1

0.1248

Unrestricted

 

scaleFactorFRatio

float

derived

1

0.02133

Unrestricted

 

scaleFactorPhi

float

derived

1

2.844

Unrestricted

 

NCOIntBits

int

derived

1

20

Unrestricted

 

formatF

float

derived

1

4096

Unrestricted

 

formatI

float

derived

1

524300

Unrestricted

 

table_coeffs

float*

parameter

0

[1024 x 1]

Unrestricted

 

table

int*

parameter

1

[514 x 1]

Unrestricted

 

table2_coeffs

float*

parameter

0

[1024 x 1]

Unrestricted

 

table2

int*

parameter

1

[514 x 1]

Unrestricted

 

Pins

Input Pins

Name: freq

Description: Control Input Frequency (Hz)

Data type: float

Channel range: 1

Block size range: Unrestricted

Sample rate range: Unrestricted

Complex support: Real

 

Name: phase

Description: Control Input Phase (0..360°)

Data type: float

Channel range: 1

Block size range: Unrestricted

Sample rate range: Unrestricted

Complex support: Real

Output Pins

Name: out1

Description: Output audio data

Data type: float

 

Name: out2

Description: Output audio data

Data type: float

MATLAB Usage

File Name: wave_table_oscillator_module.m

M=wave_table_oscillator_module(NAME, MODE, BLOCKSIZE, SAMPLERATE, WAVEFORM, WAVEFORM2, TABLESIZE) Creates a source module that reads wave samples from a wave file and outputs blocks of data. Arguments: NAME - name of the module. MODE - Mono or Stereo (two oscillators) output By default, MODE = 1 (mono). BLOCKSIZE - number of samples per output channel. By default, BLOCKSIZE = 256. SAMPLERATE - sample rate of the output signal, in Hz. By default, SAMPLERATE = 48000. WAVEFORM - Oscillator type By default, WAVEFORM = 0 (sine). WAVEFORM2 - Oscillator type By default, WAVEFORM = 0 (sine). TABLESIZE - Number of samples in wave table By default, TABLESIZE = 1024. Copyright 2022. DSP Concepts, Inc. All Rights Reserved. AudioWeaverModule [This tag makes it appear under awe_help]