Document toolboxDocument toolbox

(8.D.2.7) Wave Loop Player

About This Guide

This application note describes the Wave Loop Player module in AudioWeaver and demonstrates its uses.

The Wave Loop Player module is a WAV file player. The module plays out the .wav file in a loop mode. The module can be found in Sound Design->WavePlayer-> Wave Loop Player in the Module Bar on the left-hand side of the AudioWeaver Designer.

 

Figure 1: Wave Loop Player module location

Module Functional Description

The Wave Loop Player module is WAV file player. This module has three different variants along with their Fract32 versions.

  • Wave Loop Player RAM

  • Wave Loop Player RAM Fract32

  • Wave Loop Player Flash

  • Wave Loop Player Flash Fract32

  • Wave Loop Player FFS

  • Wave Loop Player FFS Fract32

 

Wave Loop Player RAM & Fract32

The RAM based Wave Loop Player reads the audio data embedded from samples stored within the module.

Figure 2: Wave Loop Player RAM

 

Input/output Pins:

The Wave Loop Player RAM has two input and one output pins.

fRatio input pin is a control value and is used to trigger the audio playback file. It is a Boolean value pin and requires a Low to High input for the playback to start and continues until the end of the WAV file and then stops. Retriggering while being in the middle of the playback has no effect and is ignored.

 

Audio output pin is the first output pin in this module and produces the processed audio samples from the wave files.

isPlaying is the second optional output pin which is a Boolean flag indicating the playback state. The value is set to 1 if playback is ongoing and 0 if not.

Variables:

The variables are the first tab in Module properties which is Rt Click on the module View Properties.

Figure 3: View Properties

Arguments:

Arguments can be found Rt Click View Properties second tab in the properties as shown. The following table shows the list of arguments in the Wave One Shot Player RAM module, explanations’ along with their respective default values.

Figure 4: Argument Tab for Wave Loop Player RAM

 

Arguments

Description

Default Value

numChannels

Number of interleaved channels in the audio output pin.

By default, numChannels = 1.

blockSize

Number of samples per output channel.

By default, blockSize = 256.

sampleRate

Sample rate of the output signal, in Hz.

By default, SAMPLERATE = 48000.

fileName

Name of the wave file to be played.

By default, WAVFILE = ''.

InterpolationMode

interpolation method.

Linear

Cubic

By default, INTERP = linear. (Only in floating point variant)

normalizedPlaybackRate

normalized playback rate.

By default, NRATE = 1.

maxPlabackRate

Maximum playback rate (relative to NRATE).

By default, MRATE = 1.

isplayingpin

Boolean that provides the current playback state (PLAYING=1, STOPPED=0)

 

enablePin

Does the module have an enable input pin

By default, False

 

Workings

In the example shown below, we are using a Sine 1kHz wav file in the Wave Loop Player RAM module. Input the wave file path into the argument filename. For input to the fRatio we are using a controlled pitch to convert the continuous sine tone into intermediate bursts. The Pulse Gen module is onTime at 31msec which is used as a trigger for the Triggered Pulse generator. Both the triggered pulse and the continuous sine tone out from the Wave Loop Player are given to the controlled scalar module. The triggered pulse acts as the control to the scalar module input which the sine tone in our case. The output is the trigger-controlled bursts of sine tone.

 

Figure 5: Wave Loop Player RAM Example

 

 

Wave Loop Player FFS & Fract32

Figure 6: Wave Loop Player FFS

Wave Loop Player FFS works on both AWE Core and AWE CoreOS provided that the target has enough memory to accommodate FFS container (.bin).

Input/output Pins:

The Wave One Loop Player FFS has three input and one output pins. The added input pin is explained below whereas the rest remain the same as for RAM.

  • fsInstance is the second input pin and is an integer data type. This input pin provides the instance address of the flash file system wrapper and must be valid to be ready to use.

Variables:

The variables are the first tab in Module properties which is Rt Click on the module View Properties. In this case the variables are the same as in the case of RAM module.

 

Arguments:

Arguments can be found Rt Click View Properties second tab in the properties.

Arguments

Description

Default Value

numChannels

Number of interleaved channels in the audio output pin.

By default, numChannels = 1.

blockSize

Number of samples per output channel.

By default, blockSize = 256.

sampleRate

Sample rate of the output signal, in Hz.

By default, SAMPLERATE = 48000.

fileName

Name of the wave file to be played.

By default, WAVFILE = ''.

InterpolationMode

interpolation method.

Linear

Cubic

By default, INTERP = linear. (Only in floating point variant)

normalizedPlaybackRate

normalized playback rate. 1 corresponds to 1x playback rate.

By default, NRATE = 1.

maxPlabackRate

Maximum playback rate (relative to NRATE).

By default, MRATE = 1.

fracbits

Number of least-significant bits for the *fractional* part of the NCO word (word size: 32).

By default: 12 bits. (Only in fixed point variant)

isplayingpin

Boolean that provides the current playback state (PLAYING=1, STOPPED=0)

By default: False

muteMod

Used to mute output before changing file in run time.

By default: Blank

unMuteMod

Used to unmute after reconfiguration.

By default: Blank

 

Workings

We are using the same example as for the RAM variant for the Wave Loop Player. In this case we the Sine wave file is being fed through the FFS Wrapper as a .bin file. The output is the same as compared to the RAM variant. The triggered pulse acts as the control to the scalar module input which the sine tone in our case. The output is the trigger-controlled bursts of sine tone.

Figure 7: Wave Loop Player FFS Example

 

 

 

Wave Loop Player Flash & Fract32

This Wave One Shot Player variant extracts wave data from AWE Flash File System container on the target Flash device, based on wavfile argument. User must 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.

 

Figure 8: Wave Loop Player Flash

 

Input/output Pins:

The Wave One Shot Player FFS has three input and one output pins. The added input pin is explained below whereas the rest remain the same as for RAM.

  • fsValid is the second input pin and is an integer data type. Boolean indicates flash file system is ready.

 

Variables:

The variables are the first tab in Module properties which is Rt Click on the module View Properties. In this case the variables are the same as in the case of RAM module.

 

 

Arguments:

Arguments can be found Rt Click View Properties second tab in the properties.

Arguments

Description

Default Value

numChannels

Number of interleaved channels in the audio output pin.

By default, numChannels = 1.

blockSize

Number of samples per output channel.

By default, blockSize = 256.

sampleRate

Sample rate of the output signal, in Hz.

By default, SAMPLERATE = 48000.

fileName

Name of the wave file to be played.

By default, WAVFILE = ''.

InterpolationMode

interpolation method.

Linear

Cubic

By default, INTERP = linear. (Only in floating point variant)

normalizedPlaybackRate

normalized playback rate.

By default, NRATE = 1.

maxPlabackRate

Maximum playback rate (relative to NRATE).

By default, MRATE = 1.

fracbits

Number of least-significant bits for the *fractional* part of the NCO word (word size: 32).

By default, 12 bits. (Only in fixed point variant)

isplayingpin

Boolean that provides the current playback state (PLAYING=1, STOPPED=0)

By default, False

muteMod

Used to mute output before changing file in run time.

By default, Blank

unMuteMod

Used to unmute after reconfiguration.

By default, Blank

maxWaveChannels

Max number of channels a wave file can have.

By default, maxWaveChannels = 10.

maxRatio

Max pitch factor supported.

By default, maxRatio = 10.

 

Workings

For Wave Loop Player Flash module, we need AWE Pro version with MATLAB. The example ‘WaveLoopPlayer_Flash.awd ‘ uses TableSource module with the names of all the wav files in order which is then fed via the Arrayset module to the WaveLoopPlayer’s fileName argument. To fill the TableSource module with the list of wave files in an excel sheet called ‘Create_wavemapping_table ‘ as shown below in figure 9.

The ‘create_wavemapping_table.m’ script reads the list if wave names in the excel sheet and converts them into appropriate format to be loaded into the TableSource coefficient’s table which looks like figure 10. The MATLAB script then saves a new awd with the loaded coefficients under the name _mapped.awd

Figure 9: Create_wavemapping_table excel sheet

Figure 10: List of Wave names loaded into TableSource coefficients.

%% Params % Update AWD filename here awd_filename = 'WaveOneShotPlayer_Flash'; awd_path = ''; %% Background sounds % Reading in Excel File [xlsnum, xlstxt, xlsraw] = xlsread('Wavefile_Index_Mapping_Loop.xlsx'); % Creating Wavemappingtable values for AudioWeaver Layout rows = size(xlsnum,1); name_table_background = zeros(7,rows); for i=2:rows+1 indx = xlsraw{i,1:1}; if isnan(xlsraw{i,1:1}) name = ''; else name = convertStringsToChars(xlsraw{i,2:2}); end name_table_background(1:7,indx+1) = string_cast_uint32(name,7); end %% Write AWD % Open AudioWeaver Layout gsys = load_awd([awd_path, awd_filename, '.awd']); % Set Wavemappingtable values in Layout gsys.SYS.TableSource.coeff = name_table_background; % Get the current date and time current_datetime = datetime('now', 'Format', 'yyMMMdd_Hmm'); % Convert the datetime to a string datetime_string = char(current_datetime); % Construct the new file name with date and time new_filename = [awd_filename, '_', datetime_string, '']; % Save new AWD file with applied Values save_awd([awd_path, new_filename, '_mapped.awd'],gsys); fprintf(1, 'Done\n'); disp('Finished') return

When the _mapped.awd is run, the wave files are played in a loop by the Wave Loop Player Flash in the order fed in the excel sheet. The input index can be changed by changing the router channels to play the corresponding wave file as shown in figs 11 and 12.

Figure 11: Wave One Shot Player Flash Example

Figure 12: Wave Loop Player Flash example with Sawtooth Wave

Â