OneShotPlayer
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 speed to increase and fRatio < 1.0 causes the speed to decrease. Any negative fRatio value is replaced with a zero internally.
The module supports only mono playback and first channel of the input wave file is used if it is a multi-channel wave file. Internally the module stores wave data as float values.
Module Pack
Advanced
ClassID
classID =
Type Definition
typedef struct _ModuleOneShotPlayer
{
ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure
} ModuleOneShotPlayerClass;
Variables
Properties
| Name | Type | Usage | isHidden | Default Value | Range | Units |
|---|---|---|---|---|---|---|
| wavLength | int | const | 0 | 100415 | 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 | float |
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_module.m
SYS=one_shot_player_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).
Copyright (c) 2026 DSP Concepts, Inc.