Skip to main content
Skip table of contents

GranularSynthesisWaveFFS

Overview

Synchronous Granular Synthesis Module Wave FFS

Discussion

This module implements (synchronous) granular synthesis functionality. The module extracts wave samples from AWE Flash File System container on control input pin fsInstance, based on WAVFILE argument. User has to specify the file name as an argument and can also change file name directly into fileName array as 32-bit packed data during run time.

At instantiation time the output block size and sample rate has to be specified.

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 WAV file is played back in backward direction,

The module has input pin named filePos 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 file length. The starting offset of each grain is determined internally and the value at that offset is read from filePos.

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.

Optional argument MUTMOD can be used to mute output before changing file in run time.

Optional argument UNMUTEMOD can be used to un-mute output after file is processed in run time.

If any errors occurs in the module, it is captured in the parameter .errorCodes. Please check in Errors.h for the meaning of error code returned.

Type Definition

CODE
typedef struct _ModuleGranularSynthesisWaveFFS
{
    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 windowLength;                           // Number of coefficients for current window
    INT32 waveLength;                             // Number of samples in currently loaded file
    INT32 fsInstance;                             // AWE flash file system instance pointer
    INT32 errorCode;                              // Captures errors that could arise in the module C code. Appears on the inspector
    INT32 isReady;                                // Boolean that indicates the module is not ready to output data
    INT32 waitForMuteDone;                        // Internal flag to check if the smooth mute is done
    INT32 maxGrainSize;                           // Maximum grain size in ms
    INT32 maxDensity;                             // Max density in grains per sec
    FLOAT32 normRate;                             // Rate of data used to compute the ratio for normalized players
    FLOAT32 maxRate;                              // Highest allowed rate of playback that can be specified
    UINT32 pinID;                                 // Specifies which control pins are available
    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 waveRatio;                            // Sample ratio of the wave samples
    FLOAT32 windowRatio;                          // Sample ratio of the window coefficients
    INT32 waveSampleRate;                         // Actual sample rate of the wave file.
    INT32 waveNumChannels;                        // Number of channels in the wave file.
    INT32 waveBit;                                // Wave data sample bit resolution.
    FLOAT32 scaleFactor;                          // Scale factor for playback rate
    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
    INT32* wavFileName;                           // Name of wave file to playback
    FLOAT32* window;                              // Window coefficients
    FLOAT32* window_coeffs;                       // Window coefficients
    INT32* wavFileNamePrev;                       // Name of wave file to playback
    INT32* GrainWavIndex;                         // Curr wave index of the intermediate vector element
    FLOAT32* GrainWavIndexF;                      // Curr wave index fract of the intermediate vector element
    FLOAT32* GrainWavFStep;                       // Curr wave 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
    void * muteModPtr;                            // Internal pointer to mute module to mute before reconfiguration
    void * unMuteModPtr;                          // Internal pointer to mute module to unmute after reconfiguration
    UINT32 * fsInstancePtr;                       // AWE flash file system instance pointer
    UINT32 * waveBuffer;                          // State variable holds the start address of the wave file in filesystem.
} ModuleGranularSynthesisWaveFFSClass;

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

windowLength

int

const

0

32

Unrestricted

waveLength

int

derived

0

0

Unrestricted

fsInstance

int

state

0

0

Unrestricted

errorCode

int

state

0

0

Unrestricted

isReady

int

state

0

0

Unrestricted

waitForMuteDone

int

state

0

0

Unrestricted

maxGrainSize

int

const

1

100

0:100

msec

maxDensity

int

const

1

100

0:100

grains per sec

normRate

float

const

1

1

Unrestricted

maxRate

float

const

1

5

Unrestricted

pinID

uint

const

1

1

Unrestricted

maxOverlapGrains

int

const

1

10

Unrestricted

grainSizeSamples

int

derived

1

4800

Unrestricted

interonsetTime

int

derived

1

4800

Unrestricted

waveRatio

float

derived

1

1

Unrestricted

windowRatio

float

derived

1

1

Unrestricted

waveSampleRate

int

derived

1

0

Unrestricted

waveNumChannels

int

derived

1

0

Unrestricted

waveBit

int

derived

1

0

Unrestricted

scaleFactor

float

derived

1

1

Unrestricted

smoothingCoeff

float

derived

1

0.05194

Unrestricted

grainIndex

int

state

1

0

Unrestricted

interonsetCnt

int

state

1

0

Unrestricted

smoothedFRatio

float

state

1

1

Unrestricted

wavFileName

int*

parameter

1

[14 x 1]

Unrestricted

window

float*

parameter

1

[35 x 1]

Unrestricted

window_coeffs

float*

parameter

0

[32 x 1]

Unrestricted

wavFileNamePrev

int*

state

1

[14 x 1]

Unrestricted

GrainWavIndex

int*

state

1

[1 x 10]

Unrestricted

GrainWavIndexF

float*

state

1

[1 x 10]

Unrestricted

GrainWavFStep

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

muteModPtr

void *

state

1

0

Unrestricted

unMuteModPtr

void *

state

1

0

Unrestricted

fsInstancePtr

UINT32 *

state

1

Unrestricted

waveBuffer

UINT32 *

state

1

Unrestricted

Pins

Input Pins

Name: fsInstance

Description: AWE file system instance pointer

Data type: int

Channel range: Unrestricted

Block size range: 1

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: filePos

Description: Start point of the grain, located relative within the samples between 0(start)..1(end)

Data type: float

Channel range: 1

Block size range: 256

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: 256

Sample rate range: Unrestricted

Complex support: Real

Output Pins

Name: audio

Description: Output data

Data type: float

Scratch Pins

Channel count: 1

Block size: 256

Sample rate: 48000

Channel count: 1

Block size: 256

Sample rate: 48000

Channel count: 1

Block size: 256

Sample rate: 48000

MATLAB Usage

File Name: granular_synthesis_wave_ffs_module.m

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.