[id] = CreateMusic(id, pitch, fmt)
CreateMusic()will automatically select an identifier and return it to you. You also have to specify the desired playback frequency for the music in the
pitchargument as well as the encoding of the PCM data in the
fmtargument. Currently, the following formats are supported:
Before you call this function, you have to install a callback function of
FillMusicBuffer using the InstallEventHandler()
function. This callback will then be called whenever the audio server needs
new PCM data. To deliver the new PCM data to the audio server, your callback
has to call the FillMusicBuffer() function.
See FillMusicBuffer for details.
Once you have created the music object using
CreateMusic(), you can then use all the regular
commands from the music library to work with the new music. For instance, you can use
PlayMusic() to start playback and PauseMusic() to pause the music object.
Make sure that you always use a main loop that calls WaitEvent() when you use this
function because the callback function of
CreateMusic() will always be called
by WaitEvent()! If you do not use a WaitEvent() loop, your
callback will never get called and thus no sound will ever play!
Please note that this is a lowlevel function that runs pretty close on the
hardware level. Thus, your callback function should never block your script
for a longer time. It should return as soon as possible. Never call any functions
that could block the script in
CreateMusic() callback functions. For instance,
calling Wait() or SystemRequest() in a music
callback is a very bad idea.