Document toolboxDocument toolbox

OneShotPlayerFract32

Overview

One shot player with trigger pin

Discussion

WAV file player in which playback is triggered via an input pin. The input .trigger is a Boolean value which, if set, starts playback. The trigger must be an impulse of length 1 frame, or the initial frame of the WAV will be repeated while .trigger remains set. When .trigger is reset to 0, playback continues from the second frame until it stops at end of the file. If .trigger is set again while in the middle of playback then playback will restart.

The second input pin fRatio determines the playback speed. If fRatio = 1.0 then playback is at the expected rate. fRatio > 1.0 causes the pitch to increase and fRatio < 1.0 causes the pitch to decrease.

The module supports only mono playback and first channel of the input wave file is used if it is a multi-channel wave file.

Type Definition

-Not Shown-

Variables

Properties

Name

Type

Usage

isHidden

Default value

Range

Units

wavLength

int

const

0

100400

Unrestricted

 

wavSR

int

const

0

48000

Unrestricted

 

nRate

float

const

0

1

Unrestricted

 

mRate

float

const

0

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

Description: Specifies the playback speed

Data type: float

Channel range: 1

Block size range: 1

Sample rate range: Unrestricted

Complex support: Real

Output Pins

Name: out

Description: Output audio

Data type: fract32

Scratch Pins

Channel count: 1

Block size: 1

Sample rate: 48000

 

Channel count: 1

Block size: 1

Sample rate: 48000

MATLAB Usage

File Name: one_shot_player_fract32_module.m

SYS = one_shot_player_fract32_module(NAME, BLOCKSIZE, SAMPLERATE, WAVFILE, NRATE, MRATE, FPIN) Creates a one shot player module which plays back a WAV file when triggered. Arguments: NAME - name of the module. BLOCKSIZE - block size of the module output. By default, BLOCKSIZE = 256. SAMPLERATE - sample rate of the output signal, in Hz. By default, SAMPLERATE = 48000. This does not have to match the sample rate of the WAVFILE. WAVFILE - WAV file containing the samples to playback. NRATE - normalized playback rate. This helps to scale the playback audio rate. For example, if the WAVFILE corresponds to 1500 RPM, then set NORMALIZEDRATE = 1500 and when the signal on the .fRate input pin equals 1500 then the WAVFILE will be played back at the original rate. MRATE - Maximum playback rate (relative to NRATE).

Â