(8.D.2.1) GranularSynthesisDelay
Overview
Synchronous Granular Synthesis Module Delay
Discussion
This module implements (synchronous) granular synthesis functionality. It uses a delay line to store samples from a real-time input stream. Each grain reads sound from the delay line with a potentially different delay time and playback rate. At instantiation time, you must specify the maximum delay time in milliseconds, max grain size in milliseconds. These values determine the sizes of each internal state buffers to hold audio samples and intermediate results.
The input pin fRatio is a floating-point number and specifies the step size between samples as they are played back. Internally, fRatio is smoothed on a block by block basis using the .smoothingTime variable.
If "playDir" parameter has been selected to "backward" or, if fRatio has a negative value [range 0..-1] and "playDir" parameter has been selected to "auto", the delayline buffer is played back in backward direction,
The module has input pin named delayPos that specifies the starting position of the grains at audio rate. Values in the input pin ranges between 0 and 1, and the actual offset in the file is determined be multiplying it with the delayline length. The starting offset of each grain is determined internally and the value at that offset is read from delayPos.
The module has input pin named panMod that specifies the panning coefficients of the grains at audio rate. Values in the input pin ranges between 0 and 1, the specified value is considered as panning coefficient for left channel. 1-coeff is considered as the panning for right channel.
Type Definition
typedef struct _ModuleGranularSynthesisDelay
{
ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure
INT32 grainSize; // Sets the length of each grain, denoted in milliseconds
INT32 grainDensity; // Sets the number of grain samples per second
INT32 playDir; // Playback direction, 0=Forward, 1=Backward, 2=Auto (derived from fRatio input pin)
FLOAT32 gain; // The peak level of the window
INT32 smoothingTime; // Time constant of the pitch smoothing process
INT32 maxDelayTime; // Maximum delay, in milliseconds.
INT32 windowLength; // Number of coefficients for current window
INT32 maxDelaySamples; // Maximum delay in samples.
INT32 writeIndex; // Write offset in the delay buffer
INT32 maxGrainSize; // Maximum grain size in ms
INT32 maxDensity; // Max density in grains per sec
FLOAT32 maxRate; // Highest allowed rate of playback that can be specified
UINT32 pinID; // Specifies which control pins are available
INT32 stateHeap; // Heap in which to allocate state buffer memory.
INT32 maxOverlapGrains; // Number of max. overlapping grains per maxGrainSize
INT32 grainSizeSamples; // Length of each grain in samples
INT32 interonsetTime; // Time between temporally adjacent grain onsets
FLOAT32 windowRatio; // Sample ratio of the window coefficients
FLOAT32 smoothingCoeff; // Smoothing (pitch) coefficient
INT32 grainIndex; // Current used vector index
INT32 interonsetCnt; // Current interonset counter
FLOAT32 smoothedFRatio; // Current (smoothed) rate at which audio is read from the input buffer
FLOAT32* window; // Window coefficients
FLOAT32* window_coeffs; // Window coefficients
FLOAT32* delayBuffer; // State variable array.
INT32* GrainDelayIndex; // Curr delayline index of the intermediate vector element
FLOAT32* GrainDelayIndexF; // Curr delayline index fract of the intermediate vector element
FLOAT32* GrainDelayFStep; // Curr delayline step size of the intermediate vector element
INT32* GrainEnvIndex; // Curr envelope index of the intermediate vector element
FLOAT32* GrainEnvIndexF; // Curr envelope index fract of the intermediate vector element
FLOAT32* GrainEnvFStep; // Curr envelope step size of the intermediate vector element
INT32* GrainOffset; // Curr grain offset of the intermediate vector element
FLOAT32* GrainPanCoeff; // Curr panning coefficient of the intermediate vector element
INT32* GrainStatus; // Curr status ("active"/"inactive") of the intermediate vector element
} ModuleGranularSynthesisDelayClass;
Variables
Properties
Name | Type | Usage | isHidden | Default value | Range | Units |
grainSize | int | parameter | 0 | 100 | 1:100 | msec |
grainDensity | int | parameter | 0 | 10 | 1:100 | Â |
playDir | int | parameter | 0 | 0 | 0:2 | Â |
gain | float | parameter | 0 | 1 | 0:1 | Â |
smoothingTime | int | parameter | 0 | 100 | 0:1000 | msec |
maxDelayTime | int | const | 0 | 500 | 0:500 | msec |
windowLength | int | const | 0 | 32 | Unrestricted | Â |
maxDelaySamples | int | derived | 0 | 24000 | Unrestricted | samples |
writeIndex | int | state | 0 | 0 | Unrestricted | Â |
maxGrainSize | int | const | 1 | 100 | 0:100 | msec |
maxDensity | int | const | 1 | 100 | 0:100 | grains per sec |
maxRate | float | const | 1 | 5 | Unrestricted | Â |
pinID | uint | const | 1 | 1 | Unrestricted | Â |
stateHeap | int | const | 1 | 561 | Unrestricted | Â |
maxOverlapGrains | int | const | 1 | 10 | Unrestricted | Â |
grainSizeSamples | int | derived | 1 | 4800 | Unrestricted | Â |
interonsetTime | int | derived | 1 | 4800 | Unrestricted | Â |
windowRatio | float | derived | 1 | 1 | Unrestricted | Â |
smoothingCoeff | float | derived | 1 | 0.006644 | Unrestricted | Â |
grainIndex | int | state | 1 | 0 | Unrestricted | Â |
interonsetCnt | int | state | 1 | 0 | Unrestricted | Â |
smoothedFRatio | float | state | 1 | 1 | Unrestricted | Â |
window | float* | parameter | 1 | [35 x 1] | Unrestricted | Â |
window_coeffs | float* | parameter | 0 | [32 x 1] | Unrestricted | Â |
delayBuffer | float* | state | 1 | [1 x 24003] | Unrestricted | Â |
GrainDelayIndex | int* | state | 1 | [1 x 10] | Unrestricted | Â |
GrainDelayIndexF | float* | state | 1 | [1 x 10] | Unrestricted | Â |
GrainDelayFStep | float* | state | 1 | [1 x 10] | Unrestricted | Â |
GrainEnvIndex | int* | state | 1 | [1 x 10] | Unrestricted | Â |
GrainEnvIndexF | float* | state | 1 | [1 x 10] | Unrestricted | Â |
GrainEnvFStep | float* | state | 1 | [1 x 10] | Unrestricted | Â |
GrainOffset | int* | state | 1 | [1 x 10] | Unrestricted | Â |
GrainPanCoeff | float* | state | 1 | [1 x 10] | Unrestricted | Â |
GrainStatus | int* | state | 1 | [1 x 10] | Unrestricted | Â |
Pins
Input Pins
Name: in
Description: Input audio
Data type: float
Channel range: 1
Block size range: Unrestricted
Sample rate range: Unrestricted
Complex support: Real
Â
Name: fRatio
Description: Specifies playback ratio
Data type: float
Channel range: 1
Block size range: 1
Sample rate range: Unrestricted
Complex support: Real
Â
Name: delayPos
Description: Start point of the grain, located relative within the delayline between 0..1(maxDelay)
Data type: float
Channel range: 1
Block size range: Unrestricted
Sample rate range: Unrestricted
Complex support: Real
Â
Name: panMod
Description: Controls panning for each grain; relative distribution between 0(max left)..1(max right)
Data type: float
Channel range: 1
Block size range: Unrestricted
Sample rate range: Unrestricted
Complex support: Real
Output Pins
Name: audio
Description: Output data
Data type: float
Scratch Pins
Channel count: 1
Block size: 32
Sample rate: 48000
Â
Channel count: 1
Block size: 32
Sample rate: 48000
Â
Channel count: 1
Block size: 32
Sample rate: 48000
MATLAB Usage
File Name: granular_synthesis_delay_module.m