WaveTableOscillatorV2
Overview
Wave table based oscillator allowing to exchange wave forms during runtime
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.
At instantiation time you specify the total number of samples (MAXTABLESIZE) that determines the amount of memory allocated to the table.
At run time, you can change the wave form actively used. For custom wave forms you can either fill the array during design time or you use an ArraySet module in conjunction with a TableSource module to access and update the table buffer.
A second output can be enabled to achieve pitch- and phase-synchronized stereo playback and then for example have the capability to morph between different wave forms, e.g. via using a CrossFader.
Module Pack
awe-mod-dspc-snd
ClassID
classID = 41835
Type Definition
typedef struct _ModuleWaveTableOscillatorV2
{
ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure
INT32 waveForm; // Type of wave form to be generated
INT32 waveForm2; // Type of wave form to be generated for 2nd pin (only in modus=Stereo)
INT32 smoothingTime; // Time constant of the pitch smoothing process
INT32 tableSize; // Current table size of the sample buffer data
INT32 modus; // Mono/Stereo
INT32 blockSize; // Block size
FLOAT32 sampleRate; // Sample rate
INT32 maxTableSize; // Table size in samples
INT32 maxTableSize2; // Second table size in samples
FLOAT32 smoothingCoeff; // Smoothing coefficient (pitch & phase)
FLOAT32 scaleFRatio; // Scale factor for playback rate
FLOAT32 scalePhi; // Scale factor for target phi
INT32 fIndex; // Current sample index in the wave table
FLOAT32 currentFRatio; // Current (smoothed) rate at which audio is read from the input buffer
FLOAT32 phiIndex; // Current phi index in the wave table
FLOAT32 currentPhi; // Current (smoothed) phi at which audio is phase-offset from the input buffer
INT32 stateHeap; // Heap in which to allocate memory
INT32 NCOFracBits; // Number of least-significant bits for the *fractional* part of the NCO word (word size: 32)
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.
INT32 firstFrame; // Detect first frame to set the current FRatio to target ratio right away
INT32 updateActive; // Specifies whether the table is updating (=1) or fixed (=0)
FLOAT32* table; // Sample buffer table
FLOAT32* table2; // Secondary sample buffer table
INT32* tablePkd; // Packed 16 bit sample buffer table
INT32* table2Pkd; // Secondary packed 16 bit sample buffer table
} ModuleWaveTableOscillatorV2Class;
Variables
Properties
| Name | Type | Usage | isHidden | Default Value | Range | Units |
|---|---|---|---|---|---|---|
| waveForm | int | parameter | 0 | 0 | 0:4 | |
| waveForm2 | int | parameter | 0 | 0 | 0:4 | |
| smoothingTime | int | parameter | 0 | 10 | 0:1000 | msec |
| tableSize | int | parameter | 0 | 1024 | 4:1024 | |
| modus | int | const | 0 | 2 | Unrestricted | |
| blockSize | int | const | 0 | 256 | Unrestricted | |
| sampleRate | float | const | 0 | 48000 | Unrestricted | |
| maxTableSize | int | const | 0 | 1024 | Unrestricted | |
| maxTableSize2 | int | const | 0 | 1024 | Unrestricted | |
| smoothingCoeff | float | derived | 0 | 0.4134 | Unrestricted | |
| scaleFRatio | float | derived | 0 | 0.02133 | Unrestricted | |
| scalePhi | float | derived | 0 | 2.844 | Unrestricted | |
| fIndex | int | state | 0 | 0 | Unrestricted | |
| currentFRatio | float | state | 0 | 1 | Unrestricted | |
| phiIndex | float | state | 0 | 0 | Unrestricted | |
| currentPhi | float | state | 0 | 0 | Unrestricted | |
| stateHeap | int | const | 1 | 561 | Unrestricted | |
| NCOFracBits | int | const | 1 | 12 | Unrestricted | |
| NCOIntBits | int | const | 1 | 20 | Unrestricted | |
| formatF | float | const | 1 | 4096 | Unrestricted | |
| formatI | float | const | 1 | 524300 | Unrestricted | |
| firstFrame | int | state | 1 | 1 | Unrestricted | |
| updateActive | int | state | 1 | 0 | 0:1 | |
| table | float* | parameter | 0 | [1024 x 1] | Unrestricted | |
| table2 | float* | parameter | 0 | [1024 x 1] | Unrestricted | |
| tablePkd | int* | state | 1 | [513 x 1] | Unrestricted | |
| table2Pkd | int* | state | 1 | [513 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 | out |
| Description | Output audio data |
| Data Type | float |
| Name | out2 |
| Description | Output second audio data |
| Data Type | float |
Matlab Usage
File Name: wave_table_oscillator_v2_module.m
M=wave_table_oscillator_v2_module(NAME, MODUS, BLOCKSIZE, SR, MAXTABLESIZE)
Creates a source module that reads samples from a table and outputs blocks of data.
Arguments:
NAME - name of the module.
MODUS - mono or stereo (two oscillators) output
By default, MODUS = 1 (mono).
BLOCKSIZE - number of samples per output channel.
SR - sample rate of the output signal, in Hz.
MAXTABLESIZE - number of samples in wave table
By default, MAXTABLESIZE = 256.
MEMHEAP - specifies the memory heap to use to allocate the main
state buffer. This is a string and follows the memory allocation
enumeration in Framework.h. Allowable values are:
'AWE_HEAP_FAST' - always use internal DM memory.
'AWE_HEAP_FASTB' - always use internal PM memory.
'AWE_HEAP_SLOW' - always use external memory.
'AWE_HEAP_FAST2SLOW' - use internal memory. If this fails
then use external memory (the default).
'AWE_HEAP_FASTB2SLOW' - use internal memory. If this fails
then use external memory.
Copyright 2024. DSP Concepts, Inc. All Rights Reserved.
AudioWeaverModule [This tag makes it appear under awe_help]
Copyright (c) 2026 DSP Concepts, Inc.