GLBasic User Manual

Main sections

GENSOUND()

id% = GENSOUND()



This command returns an index that can be used to open a resource with LOADSOUND without overwriting already loaded data.

If no more memory is available, -1 will be returned.

The obvious advantage of this approach is that you can write libraries that fit seamlessly into existing projects without interferring with with the existing code.
If using these commands to allocate indicies in any part of your code, you should use them throughout your whole program.


The example here:
LOADSOUND "Super.wav", 0, 1
PRINT "SUPER", 100, 100
SHOWSCREEN
PLAYSOUND 0, 0
MOUSEWAIT


Can be written as:
GLOBAL gSndSuper
gSndSuper = GENSOUND()
LOADSOUND "Super.wav", gSndSuper, 1
PRINT "SUPER", 100, 100
SHOWSCREEN
PLAYSOUND gSndSuper, 0
MOUSEWAIT

See also...