Original Author Paul Laughton, 2011
Page 187
De Re BASIC!
The music stops playing when the program stops running. To simply start a music file playing and keep it
playing, keep the program running. This infinite loop will accomplish that:
Audio.load ptr, "my_music.mp3"
Audio.play ptr
Do
Pause 5000
Until 0
Audio.stop
Audio.stop terminates the currently-playing music file. The command will ignored is no file is playing. It
is best to precede each audio.play command with an audio.stop command.
Audio.pause
Pause is like stop except that the next audio.play for this file will resume the play at the point where the
play was paused.
Audio.loop
When the currently playing file reaches the end of file, the file will restart playing from the beginning of
the file. There must be a currently playing file when this command is executed.
Audio.volume <left_nexp>, <right_nexp>
Changes the volume of the left and right stereo channels. There must be a currently playing file when
this command is executed.
The values should range between 0.0 (lowest) to 1.0 (highest). The human ear perceives the level of
sound changes on a logarithmic scale. The ear perceives a 10db change as twice as loud. A 20db change
would be four times as loud.
A 1 db change would be about 0.89. One way to implement a volume control would be set up a volume
table with 1db level changes. The following code creates a 16 step table.
dim volume[16]
x =1
volume [1] = x
for i = 2 to 16
x = x * 0.89
volume [i] = x
next i
Your code can select volume values from the table for use in the audio.volume command. The loudest
volume would be volume[1].
Audio.position.current <nvar>
The current position in milliseconds of the currently playing file will be returned in <nvar>.