Document toolboxDocument toolbox

WAVInterpOneShotSource

Overview

Periodic one shot WAV playback with linear interpolation

Discussion

This module outputs blocks of audio data by interpolating from the upstream wave data. The input pin .ptr is a pointer to the upstream wave data module, which is periodic_streaming_module. Input pin .trigger is a boolean to initiate playback. When it goes from 1->0 then the module starts generating output audio by interpolating the wave data. The input pin .fRatio controls the playback speed as a decimal ratio, where 1.0 is the default speed, increasing above 1.0 speeds up the playback speed, and decreasing below 1.0 slows down the playback speed. Any negative fRatio value will be replaced with a zero internally. This module assumes the wave data from upstream module is a float data type.

Type Definition

typedef struct _ModuleWAVInterpOneShotSource { ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure FLOAT32 smoothingTime; // Time constant of the smoothing process INT32 circularBufferSize; // Size of the upstream circular buffer. INT32 extensionSize; // Size of the extension region of the circular buffer FLOAT32 currentFRatio; // Specifies rate at which audio is read from the input buffer FLOAT32 smoothingCoeff; // Smoothing coefficient FLOAT32 fIndex; // state index INT32 psObjectID; // Object ID of the upstream PeriodicStreaming module ModuleInstanceDescriptor ** psObjectPtr; // Points to the upstream PeriodicStreaming module } ModuleWAVInterpOneShotSourceClass;

Variables

Properties

Name

Type

Usage

isHidden

Default value

Range

Units

smoothingTime

float

parameter

0

10

0:1000

msec

circularBufferSize

int

const

0

0

Unrestricted

 

extensionSize

int

parameter

0

0

Unrestricted

 

currentFRatio

float

parameter

1

1

Unrestricted

 

smoothingCoeff

float

derived

1

0.03278

Unrestricted

 

fIndex

float

state

1

0

Unrestricted

 

psObjectID

int

state

1

-1

Unrestricted

 

psObjectPtr

ModuleInstanceDescriptor **

state

1

 

Unrestricted

 

Pins

Input Pins

Name: ptr

Description: Pointer to the streaming transfer object

Data type: int

Channel range: 1

Block size range: 1

Sample rate range: Unrestricted

Complex support: Real

 

Name: trigger

Description: Boolean trigger signal

Data type: int

Channel range: 1

Block size range: 1

Sample rate range: Unrestricted

Complex support: Real

 

Name: fRatio

Description: Specifies sample rate ratio

Data type: float

Channel range: 1

Block size range: 1

Sample rate range: Unrestricted

Complex support: Real

Output Pins

Name: out

Description: output data

Data type: float

MATLAB Usage

File Name: wav_interp_oneshot_source_module.m

M=wav_interp_oneshot_source_module(NAME, NUMCHANNELS, BLOCKSIZE, SAMPLERATE) Creates a source module that connects to a streaming buffer module and outputs blocks of data. The function includes linear interpolation allowing playback to be slowed down and speeded up. This version uses float wave data and a float fIndex register for efficient implementation. This version is a "one shot player" in which the playback is triggered by an input pin and then stops after the WAV data has been played once. Arguments: NAME - name of the module. NUMCHANNELS - number of interleaved channels in each output pin. By default, NUMCHANNELS = 1; BLOCKSIZE - number of samples per output channel. By default, BLOCKSIZE = 32. SAMPLERATE - sample rate of the output signal, in Hz. By default, SAMPLERATE = 48000.

Â