Class waveFileVoice

Implementation of a voice which uses WAVE files as an audio source.

The sound files have to be mapped to the challenge and response sound keys of the checklist items.

See also:

Info:

  • Copyright: 2022 Patrick Lang
  • Author: Patrick Lang

Methods

waveFileVoice:new (name, challengeFilesDirectoryPath, responseFilesDirectoryPath) Creates a new voice.
waveFileVoice:setVolume (volume) Sets the volume of the voice.
waveFileVoice:activateChallengeSounds () Gets called when the voice is selected for providing the audio output for the challenges.
waveFileVoice:activateResponseSounds () Gets called when the voice is selected for providing the audio output for the responses and failures.
waveFileVoice:deactivateChallengeSounds () Gets called when the voice is no longer an active audio provider for the challenges.
waveFileVoice:deactivateResponseSounds () Gets called when the voice is no longer an active audio provider for the responses and failures.
waveFileVoice:playChallengeSound (key) Starts playing the challenge sound with the specified key.
waveFileVoice:playResponseSound (key) Starts playing the response sound with the specified key.
waveFileVoice:playFailSound () Starts playing a random fail sound If the voice is currently paused, then the pause is reset.
waveFileVoice:pause () Pauses the active sound.
waveFileVoice:resume () Resumes the active sound.
waveFileVoice:stop () Stops playing the active sound.
waveFileVoice:isFinished () Checks whether the active sound has finished playing.
waveFileVoice:addChallengeSoundFile (key, soundFileName) Maps a sound file to a challenge sound key.
waveFileVoice:addResponseSoundFile (key, soundFileName) Maps a sound file to a response sound key.
waveFileVoice:addFailSoundFile (soundFileName) Adds a sound file to the list of fail sounds.


Methods

waveFileVoice:new (name, challengeFilesDirectoryPath, responseFilesDirectoryPath)
Creates a new voice.

Parameters:

  • name string The name of the voice.
  • challengeFilesDirectoryPath string The path to the directory which contains the challenge sound files. Must not be empty. If this parameter is nil, then no challenge sound files can be added.
  • responseFilesDirectoryPath string The path to the directory which contains the response and fail sound files. Must not be empty. If this parameter is nil, then no response or fail sound files can be added.

Returns:

    waveFileVoice The created voice
waveFileVoice:setVolume (volume)
Sets the volume of the voice. A value of 1 means 100% (full volume), a value of 0.5 means 50% (half the volume). This function should be implemented in a derived voice class.

Parameters:

  • volume numer The volume to use.
waveFileVoice:activateChallengeSounds ()
Gets called when the voice is selected for providing the audio output for the challenges. Can be used to initialize the voice. This function does nothing in this implementation.
waveFileVoice:activateResponseSounds ()
Gets called when the voice is selected for providing the audio output for the responses and failures. Can be used to initialize the voice. This function does nothing in this implementation.
waveFileVoice:deactivateChallengeSounds ()
Gets called when the voice is no longer an active audio provider for the challenges. Can be used to release any resources. This function does nothing in this implementation.
waveFileVoice:deactivateResponseSounds ()
Gets called when the voice is no longer an active audio provider for the responses and failures. Can be used to release any resources. This function does nothing in this implementation.
waveFileVoice:playChallengeSound (key)
Starts playing the challenge sound with the specified key. If the voice is currently paused, then the pause is reset. If the key is not mapped to a sound file, then no sound is played.

Parameters:

  • key string The key of the challenge sound.

Raises:

An error is thrown if the voice was not activated.
waveFileVoice:playResponseSound (key)
Starts playing the response sound with the specified key. If the voice is currently paused, then the pause is reset. If the key is not mapped to a sound file, then no sound is played.

Parameters:

  • key string The key of the response sound.

Raises:

An error is thrown if the voice was not activated.
waveFileVoice:playFailSound ()
Starts playing a random fail sound If the voice is currently paused, then the pause is reset. If the voice does not contain a fail sound, then no sound is played.

Raises:

An error is thrown if the voice was not activated.
waveFileVoice:pause ()
Pauses the active sound. If there is no active sound or the voice is already paused, then this method does nothing.

Raises:

An error is thrown if the voice was not activated.
waveFileVoice:resume ()
Resumes the active sound. If there is no active sound or the voice is not paused, then this method does nothing.

Raises:

An error is thrown if the voice was not activated.
waveFileVoice:stop ()
Stops playing the active sound. If the voice is currently paused, then the pause is reset. If there is no active sound, then this method does nothing.

Raises:

An error is thrown if the voice was not activated.
waveFileVoice:isFinished ()
Checks whether the active sound has finished playing.

Returns:

    bool True if there is no active sound or the active sound has finished playing, otherwise false.
waveFileVoice:addChallengeSoundFile (key, soundFileName)
Maps a sound file to a challenge sound key. The sound cannot be used until the voice has been activated after the sound has been added.

Parameters:

  • key string The challenge sound key.
  • soundFileName string The name of the sound file.

Raises:

An error is thrown if the path to the directory which contains the challenge sound files was not set.
waveFileVoice:addResponseSoundFile (key, soundFileName)
Maps a sound file to a response sound key. The sound cannot be used until the voice has been activated after the sound has been added.

Parameters:

  • key string The challenge sound key.
  • soundFileName string The name of the sound file.

Raises:

An error is thrown if the path to the directory which contains the response and fail sound files was not set.
waveFileVoice:addFailSoundFile (soundFileName)
Adds a sound file to the list of fail sounds. The sound cannot be used until the voice has been activated after the sound has been added.

Parameters:

  • soundFileName string The name of the sound file.

Raises:

An error is thrown if the path to the directory which contains the response and fail sound files was not set.
generated by LDoc 1.4.6 Last updated 2022-05-28 12:58:52