Load wav

From Bennu Wiki
Jump to: navigation, search


Definition

INT load_wav ( <STRING filename>, [ <POINTER id>] )

Loads a sound effect in the WAV format for later use with play_wav().

Parameters

STRING filename - The WAV file to be loaded, including a possible path.
POINTER id - Optional parameter, for loading a wav in the background.

Returns

INT : WaveID

-2 - Waiting for the file to be loaded, see notes.
-1 - There was an error loading the file.
>=0 - The waveID of the newly created sound.


the following applies for versions prior rc282:

INT : WaveID

-1 - Error: sound inactive; opening file
0 - Could not load wave file.
>0 - The WaveID.


Notes

The optional parameter id was introduced in version rc282 and allows you to load resources in the background. It used with the Offset operator. See example below:

      load_wav("archivo_gordo.wav", &idwav);
      while(idwav==-2)
            say("Big File Loading ....");
            frame;
      end
      if(idwav==-1)
          say("Something went wrong!!");
          exit(); // o return
      end

      say("Big file loaded ok!!");


Example

Program
Private
    int wave;
Begin
    wave = load_wav("my_wav.wav");
    play_wav(wave,0);
    Loop
        frame;
    End
End

Used in example: play_wav()


Sound Functions
Fade_music_in()Fade_music_off()Is_playing_song()Is_playing_wav()Load_song()Load_wav()Pause_song()Pause_wav()Play_song()Play_wav()Reserve_channels()Resume_song()Resume_wav()Reverse_stereo()Set_Wav_Volume()Set_channel_volume()Set_distance()Set_music_position()Set_panning()Set_position()Set_song_volume()Sound_close()Sound_init()Stop_song()Stop_wav()Unload_song()Unload_wav()