LoadSound()

Syntax

Result = LoadSound(#Sound, Filename$ [, Flags])
Description
Load a WAV (in PCM format, ADPCM is not supported) or any other format supported by the SoundPlugin library into memory. The following functions can be used to enable automatically more sound format:

UseFLACSoundDecoder()
UseOGGSoundDecoder()

Parameters

#Sound A number to identify the new sound. #PB_Any can be used to auto-generate this number.
Filename$ The filename to use to load the sound.
Flags (optional) It can be the following value:
  #PB_Sound_Streaming: Enable sound streaming playback (only supported for FLAC and OGG))

Return value

Nonzero if the sound has been successfully loaded, zero otherwise.

Example

  If InitSound()           ; Initialize Sound system
    UseOGGSoundDecoder()   ; Use ogg files
    
    ; Loads a sound from a file
    If LoadSound(0, #PB_Compiler_Home +"Examples/3D/Data/Siren.ogg")
      PlaySound(0, #PB_Sound_Loop) ; Start playing the sound in a loop
      
      MessageRequester("Info", "Ok to stop.")
      
      FreeSound(0) ; The sound is freed
    EndIf
    End
  Else
    Debug "Warning! The sound environment couldn't be initialized. So no sound commands can be used..."
  EndIf

See Also

CatchSound(), FreeSound(), PlaySound()

Supported OS

All

<- IsSound() - Sound Index - PauseSound() ->