Module vn.sound

sound.lua Provides the 'built-in' VN sound functions.

Functions

changeVolume (sound, newvol, duration) Changes the volume of a currently playing sound/music/voice, possibly gradually over a period of time.
getFreeChannel (from, to) Returns a free sound channel between from and to (inclusive), or 0 if no such channel can be found.
music (filename, vol) Starts playback of looping background music.
musicStop (fadeTime) Stops music started with the music function.
sound (filename, loops, vol, ch, type) Starts playback of sound/voice/music
soundStop (ch, fadeTime) Stops the sound playing in the specified channel
voice (filename, loops, vol, ch) Plays a sound effect of type SoundType.VOICE.


Functions

changeVolume (sound, newvol, duration)
Changes the volume of a currently playing sound/music/voice, possibly gradually over a period of time.

Parameters:

  • sound: The sound/music/voice channel (or a Sound object) to change the volume of.
  • newvol: The target volume for the Sound
  • duration: The duration (in frames) it should take to gradually change the volume.
getFreeChannel (from, to)
Returns a free sound channel between from and to (inclusive), or 0 if no such channel can be found.

Parameters:

  • from: Must be a positive number
  • to: Must be >= from
music (filename, vol)
Starts playback of looping background music. This function calls sound internally with ch=0.

Parameters:

  • filename: Path to a valid audio file
  • vol: Loudness of the music between 0.0 and 1.0, default is 1.0

See also:

musicStop (fadeTime)
Stops music started with the music function.

Parameters:

  • fadeTime: Optional argument specifying the duration of a slow fade-out instead of stopping playback immediately.

See also:

sound (filename, loops, vol, ch, type)
Starts playback of sound/voice/music

Parameters:

  • filename: Path to a valid audio file
  • loops: The number of times the sound should repeat. Default is 1, use -1 for infinite looping.
  • vol: Loudness of the sound between 0.0 and 1.0, default is 1.0
  • ch: The sound channel to use for the sound, defaults to 1
  • type: The sound type: SoundType.SOUND, SoundType.MUSIC or SoundType.VOICE.

Return value:

    The sound channel of the new playing sound, or nil if for whatever reason no sound has been started.
soundStop (ch, fadeTime)
Stops the sound playing in the specified channel

Parameters:

  • ch: The channel of the sound that should be stopped.
  • fadeTime: Optional argument specifying the duration of a slow fade-out instead of stopping playback immediately.

See also:

voice (filename, loops, vol, ch)
Plays a sound effect of type SoundType.VOICE. This function calls sound internally.

Parameters:

  • filename:
  • loops:
  • vol:
  • ch: The audio channel to play the sound on, default is 101.

See also:

Valid XHTML 1.0!