(8.D.2.7) WaveOneShotPlayerFlashFract32
Overview
One-shot Wave Player supporting pitch shifting
Discussion
This module outputs wave data triggered via an input pin. It extracts wave data from AWE Flash File System container on the target Flash device, 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. The input .trigger is a Boolean value which if set starts playback. Playback continues until the end of the file is reached and then it stops. Retrigger while being in the middle of the playback has no effect and will be ignored. The module supports multichannel such that, if the wave file has more channels than provided to the module argument then only channels up to output pin will be used. If the wave file has less channels than output pin channels, then the remaining output channels will be muted.
On windows (Native PC) or Linux platforms, file operations are used and make sure the file path exists in the Audio Weaver file search path. If not, please update the file serch path from File->Set File Search Path... in the Designer.
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. During the runtime, module may return positive error codes with the following meaning:
    1 - indicates pitch ratio is more than max supported     2 - indicates wave file has more than max supported
Type Definition
typedef struct _ModuleWaveOneShotPlayerFlashFract32
{
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)
FLOAT32 normRate; // Rate of data used to compute the ratio for normalized players
FLOAT32 maxRate; // Highest allowed rate of playback that can be specified
INT32 NCOFracBits; // Number of least-significant bits for the *fractional* part of the NCO word (word size: 32)
INT32 maxWaveChannels; // Maximum number of channels a wave file can have
FLOAT32 maxRatio; // Maximum pitch factor supported. Anything from fRatio pin above this clipped to maxRatio
INT32 waveLength; // Number of samples in currently loaded file
INT32 fsInstance; // AWE flash file system instance pointer
FLOAT32 fIndex; // Current index in the wave file
FLOAT32 fIndexFract; // Current fract index in the wave file
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
FLOAT32 currentFStep; // Current (smoothed) rate at which audio is read from the input buffer
INT32 triggerPrev; // State trigger signal to determine falling edge
INT32 triggerLatched; // State trigger denoting player is active
INT32 waveSR; // 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 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 fsValid; // Boolean which indicates if the Flash File System is valid.
INT32 waveBuffer; // State variable holds the start ofset of the wave file in flash file system.
UINT32 pinID; // Specifies which control pins are available.
INT32* fileName; // Name of wave file to playback
INT32* fileNamePrev; // Name of wave file to playback
void * muteModPtr; // Internal pointer to mute module to mute before reconfiguration
void * unMuteModPtr; // Internal pointer to mute module to unmute after reconfiguration
void * localWaveBuffer; // Internal pointer used only on Windows or Linux, which holds entire wave data
} ModuleWaveOneShotPlayerFlashFract32Class;
Variables
Properties
Name | Type | Usage | isHidden | Default value | Range | Units |
smoothingTime | int | parameter | 0 | 10 | 0:1000 | msec |
smoothingFactor | int | parameter | 0 | 4 | 1:512 | Â |
normRate | float | const | 0 | 1 | Unrestricted | Â |
maxRate | float | const | 0 | 2 | Unrestricted | Â |
NCOFracBits | int | const | 0 | 12 | Unrestricted | Â |
maxWaveChannels | int | const | 0 | 10 | Unrestricted | Â |
maxRatio | float | const | 0 | 10 | Unrestricted | Â |
waveLength | int | derived | 0 | 0 | Unrestricted | Â |
fsInstance | int | state | 0 | 0 | Unrestricted | Â |
fIndex | float | state | 0 | 0 | Unrestricted | Â |
fIndexFract | float | state | 0 | 0 | Unrestricted | Â |
errorCode | int | state | 0 | 0 | Unrestricted | Â |
isReady | int | state | 0 | 0 | Unrestricted | Â |
waitForMuteDone | int | state | 0 | 0 | Unrestricted | Â |
currentFStep | float | state | 0 | 1 | Unrestricted | Â |
triggerPrev | int | state | 0 | 0 | Unrestricted | Â |
triggerLatched | int | state | 0 | 0 | Unrestricted | Â |
waveSR | 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 | Unrestricted | Â |
NCOIntBits | int | derived | 1 | 20 | Unrestricted | Â |
formatF | float | derived | 1 | 0 | Unrestricted | Â |
formatI | float | derived | 1 | 0 | Unrestricted | Â |
fsValid | int | state | 1 | 0 | Unrestricted | Â |
waveBuffer | int | state | 1 | 0 | Unrestricted | Â |
pinID | uint | const | 1 | 1 | Unrestricted | Â |
fileName | int* | parameter | 1 | [14 x 1] | Unrestricted | Â |
fileNamePrev | int* | state | 1 | [14 x 1] | Unrestricted | Â |
muteModPtr | void * | state | 1 | 0 | Unrestricted | Â |
unMuteModPtr | void * | state | 1 | 0 | Unrestricted | Â |
localWaveBuffer | void * | state | 1 | Â | Unrestricted | Â |
Pins
Input Pins
Name: trigger
Description: Boolean trigger signal
Data type: int
Channel range: 1
Block size range: 1
Sample rate range: Unrestricted
Complex support: Real
Â
Name: fsValid
Description: Boolean indicates flash file system is ready
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: audio
Description: output data
Data type: fract32
Â
Name: isPlaying
Description: playing state
Data type: int
Scratch Pins
Channel count: 10
Block size: 2565
Sample rate: 48000
MATLAB Usage
File Name: wave_oneshot_player_flash_fract32_module.m