Load song

From Bennu Wiki
Jump to navigation Jump to search


Definition

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

Loads a song for later use with play_song().

There are multiple filetypes you can load using this function. Included are:

  • OGG Vorbis (.ogg). Good quality for songs and doesn't take too much space (it's similar to *.mp3).
  • MIDI (.mid). Takes very low space, but it's limited to samples of the soundcard.
  • Modules (.xm, .it, .s3m, .mod). Like MIDI, but Modules also contain the samples themselves.

Parameters

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

Returns

INT : SongID

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


the following applies for versions prior rc282:

INT : SongID

-1 - Could not load music file (errormessage in console).
>=0 - The SongID.


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_song("archivo_gordo.ogg", &idsong);
      while(idsong==-2)
            say("Big File Loading ....");
            frame;
      end
      if(idsong==-1)
          say("Something went wrong!!");
          exit(); // o return
      end

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


Example

Program example;
Private
    int song;
Begin
    song = load_song("my_song.ogg");
    play_song(song,0);
    Repeat
        frame;
    Until(key(_ESC))
OnExit
    unload_song(song);
End

Used in example: play_song(), key(), unload_song()


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_channel_volume()Set_distance()Set_music_position()Set_panning()Set_position()Set_song_volume()Set_Wav_Volume()Sound_close()Sound_init()Stop_song()Stop_wav()Unload_song()Unload_wav()