hi HAL, you can get patch2 full to try i guess if u have the demo.
Here is the source I used to test most of the commands by making mini function wrappers around them.
I based my game using functions so its easier to manage the scope of things.
heres the source at one stage when I hadnt fully completed the 3d sound tests
u may need to make some sounds 60% to be audible
Try this in your current version
u will need media of your own and a mono wav for the 3d sound and a small mp3 file
rem ------------------------------------------------------------------------------
rem DARKBASIC PRO Sound Commands
rem indi 6th Oct 2002
rem
rem This is a basic saftey wrapping of functions for sound commands
rem
rem
rem set sound volume doesnt appear to work under 60%
rem I havent tested the 3d sounds properly yet
rem DBP patch 2
rem ------------------------------------------------------------------------------
rem ------------------------------------------------------------------------------
rem SETUP
rem ------------------------------------------------------------------------------
sync on
sync rate 0
set text font "verdana"
set text size 20
set text to bold
rem ------------------------------------------------------------------------------
rem SOUND USAGE
rem ------------------------------------------------------------------------------
Load_Snd("ping.wav",1)
Load_Snd("ding.wav",2)
Clone_Snd(3,2)
Set_Snd_Speed(1,4000)
Set_Snd_Speed(2,3000)
Set_Snd_Speed(3,1000)
Set_Snd_Volume(1,40)
Set_Snd_Volume(2,50)
Set_Snd_Volume(3,60)
Set_Snd_Pan(2,-10000)
Set_Snd_Pan(3,10000)
Play_Snd(1)
Play_Snd(2)
Play_Snd(3)
Pause_Snd(3)
Resume_Snd(3)
Loop_Snd(1)
Loop_Snd(2)
Loop_Snd(3)
Load_Music("Supertramp_Logical.mp3",1)
Set_Music_Volume(1,30)
Play_Music(1)
Load_3DSnd("ping.wav",4)
rem ------------------------------------------------------------------------------
rem 3D SOUND OBJECT USAGE
rem ------------------------------------------------------------------------------
snd3Dx = 0
snd3Dy = 0
snd3Dz = 0
make object cube 1,10
position object 1,snd3Dx,snd3Dy,snd3Dz
Listen3Dx = 0
Listen3Dy = 0
Listen3Dz = 80
make object cube 2,10
point object 2,snd3Dx,snd3Dy,snd3Dz
position object 2,Listen3Dx,Listen3Dy,Listen3Dz
position listener Listen3Dx,Listen3Dy,Listen3Dz
rem TEMP MATRIX FOR VISUAL REFERENCE
make matrix 1,100,100,10,10
position matrix 1,0,0,0
position camera 0,50,-50
point camera 0,0,0
rem ------------------------------------------------------------------------------
rem ------------------------------------------------------------------------------
rem DEBUG OUTPUT
rem ------------------------------------------------------------------------------
SndSpeed1 = Get_Snd_Speed(1)
SndVolume1 = Get_Snd_Volume(1)
SndPan1 = Get_Snd_Pan(1)
SndSpeed2 = Get_Snd_Speed(2)
SndVolume2 = Get_Snd_Volume(2)
SndPan2 = Get_Snd_Pan(2)
SndSpeed3 = Get_Snd_Speed(3)
SndVolume3 = Get_Snd_Volume(3)
SndPan3 = Get_Snd_Pan(3)
MusicSpeed1 = Get_Music_Speed(1)
MusicVolume1 = Get_Music_Volume(1)
ink rgb(255,255,255),1
do
if inkey$()="1"
Play_Snd(1)
endif
if inkey$()="2"
Play_Snd(2)
endif
if inkey$()="3"
Play_Snd(3)
endif
if inkey$()="4"
Play_3DSnd(4)
endif
if upkey()=1
z = z + 1
endif
if downkey()=1
z = z - 1
endif
position object 2,object position x(1),object position y(1),object position z(1)+z
if inkey$()="q" then gosub EndProg
text 10,50,"sound functions"
text 50,110,"sound 1 Spd = "+STR$(SndSpeed1)
text 50,130,"sound 1 Vol = "+STR$(SndVolume1)
text 50,150,"sound 1 Pan = "+STR$(SndPan1)
text 50,210,"sound 2 Spd = "+STR$(SndSpeed2)
text 50,230,"sound 2 Vol = "+STR$(SndVolume2)
text 50,250,"sound 2 Pan = "+STR$(SndPan2)
text 50,310,"sound 3 Spd = "+STR$(SndSpeed3)
text 50,330,"sound 3 Vol = "+STR$(SndVolume3)
text 50,350,"sound 3 Pan = "+STR$(SndPan3)
text 50,410,"music 1 Spd = "+STR$(MusicSpeed1)
text 50,430,"music 1 Vol = "+STR$(MusicVolume1)
center text object screen x(1),object screen y(1),"3dsound"
center text object screen x(2),object screen y(2),"listener"
text 50,550,"press [Q] to exit"
sync
loop
EndProg:
Delete_Snd(1)
Delete_Snd(2)
delete object 1
delete object 2
end
return
rem ------------------------------------------------------------------------------
rem SOUND FUNCTIONS
rem ------------------------------------------------------------------------------
rem LOAD SOUND : LOAD SOUND Filename,Sound Number
function Load_Snd(SndFile$,SndNum)
rem if the file exists
if file exist(SndFile$)=1
load sound SndFile$,SndNum
else
rem Error File Check
ErrMsg$ = " * Error :: File : " +SndName$ + " does not exist. Press any Key to Exit"
cls
ink rgb(255,255,255),1
text 10,10,ErrMsg$
sync
suspend for key
end
endif
endfunction
rem PLAY SOUND : PLAY SOUND Sound Number
function Play_Snd(SndNum)
rem if the file exists
if sound exist(SndNum)=1
play sound SndNum
else
rem Error File Check
ErrMsg$ = "*Error- Sound num : " +STR$(SndNum) + " does not exist. Press any Key to Exit"
cls
ink rgb(255,255,255),1
text 10,10,ErrMsg$
sync
suspend for key
end
endif
endfunction
rem PAUSE SOUND : PAUSE SOUND Sound Number
function Pause_Snd(SndNum)
if sound exist(SndNum)=1
if sound playing(SndNum)=1
pause sound SndNum
endif
endif
endfunction
rem LOOP SOUND : LOOP SOUND Sound Number,StartPos,EndPos,InitialPos
function Loop_Snd(SndNum)
if sound exist(SndNum)=1
if sound playing(SndNum)=1
loop sound SndNum
endif
endif
endfunction
rem RESUME SOUND : RESUME SOUND Sound Number
function Resume_Snd(SndNum)
if sound exist(SndNum)=1
if sound paused(SndNum)=1
resume sound SndNum
endif
endif
endfunction
rem DELETE SOUND : DELETE SOUND Sound Number
function Delete_Snd(SndNum)
rem if the file exists
if sound exist(SndNum)=1
delete sound SndNum
else
rem Error File Check
ErrMsg$ = "*Error- Sound num : " +STR$(SndNum) + " could not be deleted. Press any Key to Exit"
cls
ink rgb(255,255,255),1
text 10,10,ErrMsg$
sync
suspend for key
end
endif
endfunction
rem STOP SOUND : STOP SOUND Sound Number
function Stop_Snd(SndNum)
rem if the file exists
if sound playing(SndNum)=1
stop sound SndNum
endif
endfunction
rem CLONE SOUND : CLONE SOUND Destination Sound,Source Sound
function Clone_Snd(DestNum,SorcNum)
if sound exist(DestNum)=1
rem Error File Check
ErrMsg$ = "*Error- Clone Sound Dest Num : " +STR$(DestNum) + " already exists. Press any Key to Exit"
cls
ink rgb(255,255,255),1
text 10,30,ErrMsg$
sync
suspend for key
end
endif
rem if the file exists
if sound exist(SorcNum)=1
clone sound DestNum,SorcNum
else
rem Error File Check
ErrMsg$ = "*Error- Clone Sound Source Num : " +STR$(SorcNum) + " does not exist. Press any Key to Exit"
cls
ink rgb(255,255,255),1
text 10,10,ErrMsg$
sync
suspend for key
end
endif
endfunction
rem SET SOUND SPEED : SET SOUND SPEED Sound Number,Frequency Value
function Set_Snd_Speed(SndNum,Freq)
if sound exist(SndNum)=1
set sound speed SndNum,Freq
endif
endfunction
rem SET SOUND VOLUME : SET SOUND VOLUME Sound Number,Volume Number
function Set_Snd_Volume(SndNum,Vol)
if sound exist(SndNum)=1
set sound volume SndNum,Vol
endif
endfunction
rem SET SOUND PAN : SET SOUND PAN Sound Number,Pan Value
function Set_Snd_Pan(SndNum,Pan)
if sound exist(SndNum)=1
set sound pan SndNum,Pan
endif
endfunction
rem SOUND SPEED : Return Integer=SOUND SPEED(Sound Number)
function Get_Snd_Speed(SndNum)
if sound exist(SndNum)=1
SndSpeed = sound speed(SndNum)
endif
endfunction SndSpeed
rem SOUND VOLUME : Return Integer=SOUND VOLUME(Sound Number)
function Get_Snd_Volume(SndNum)
if sound exist(SndNum)=1
SndVol = sound volume(SndNum)
endif
endfunction SndVol
rem SOUND PAN : Return Integer=SOUND PAN(Sound Number)
function Get_Snd_Pan(SndNum)
if sound exist(SndNum)=1
SndPan = sound pan(SndNum)
endif
endfunction SndPan
rem ------------------------------------------------------------------------------
rem END SOUND FUNCTIONS
rem ------------------------------------------------------------------------------
rem ------------------------------------------------------------------------------
rem 3DSOUND FUNCTIONS
rem ------------------------------------------------------------------------------
rem LOAD 3DSOUND : LOAD 3DSOUND Filename,3DSOUND Number
function Load_3DSnd(SndFile$,SndNum)
rem if the file exists
if file exist(SndFile$)=1
load 3DSOUND SndFile$,SndNum
else
rem Error File Check
ErrMsg$ = " * Error :: 3dsnd File : " +SndFile$ + " does not exist. Press any Key to Exit"
cls
ink rgb(255,255,255),1
text 10,10,ErrMsg$
sync
suspend for key
end
endif
endfunction
rem PLAY 3DSOUND : PLAY 3DSOUND 3DSOUND Number
function Play_3DSnd(SndNum)
rem if the file exists
if SOUND exist(SndNum)=1
play SOUND SndNum
else
rem Error File Check
ErrMsg$ = "*Error- 3DSOUND num : " +STR$(SndNum) + " does not exist. Press any Key to Exit"
cls
ink rgb(255,255,255),1
text 10,10,ErrMsg$
sync
suspend for key
end
endif
endfunction
rem PAUSE 3DSOUND : PAUSE 3DSOUND 3DSOUND Number
function Pause_3DSnd(SndNum)
if SOUND exist(SndNum)=1
if SOUND playing(SndNum)=1
pause SOUND SndNum
endif
endif
endfunction
rem LOOP 3DSOUND : LOOP 3DSOUND 3DSOUND Number,StartPos,EndPos,InitialPos
function Loop_3DSnd(SndNum)
if SOUND exist(SndNum)=1
if SOUND playing(SndNum)=1
loop SOUND SndNum
endif
endif
endfunction
rem RESUME 3DSOUND : RESUME 3DSOUND 3DSOUND Number
function Resume_3DSnd(SndNum)
if SOUND exist(SndNum)=1
if SOUND paused(SndNum)=1
resume SOUND SndNum
endif
endif
endfunction
rem DELETE 3DSOUND : DELETE 3DSOUND 3DSOUND Number
function Delete_3DSnd(SndNum)
rem if the file exists
if SOUND exist(SndNum)=1
delete SOUND SndNum
else
rem Error File Check
ErrMsg$ = "*Error- 3DSOUND num : " +STR$(SndNum) + " could not be deleted. Press any Key to Exit"
cls
ink rgb(255,255,255),1
text 10,10,ErrMsg$
sync
suspend for key
end
endif
endfunction
rem STOP 3DSOUND : STOP 3DSOUND 3DSOUND Number
function Stop_3DSnd(SndNum)
rem if the file exists
if SOUND playing(SndNum)=1
stop SOUND SndNum
endif
endfunction
rem SET 3DSOUND SPEED : SET 3DSOUND SPEED 3DSOUND Number,Frequency Value
function Set_3DSnd_Speed(SndNum,Freq)
if SOUND exist(SndNum)=1
set SOUND speed SndNum,Freq
endif
endfunction
rem SET 3DSOUND VOLUME : SET 3DSOUND VOLUME 3DSOUND Number,Volume Number
function Set_3DSnd_Volume(SndNum,Vol)
if SOUND exist(SndNum)=1
set SOUND volume SndNum,Vol
endif
endfunction
rem 3DSOUND SPEED : Return Integer=3DSOUND SPEED(3DSOUND Number)
function Get_3DSnd_Speed(SndNum)
if SOUND exist(SndNum)=1
SndSpeed = SOUND speed(SndNum)
endif
endfunction SndSpeed
rem 3DSOUND VOLUME : Return Integer=3DSOUND VOLUME(3DSOUND Number)
function Get_3DSnd_Volume(SndNum)
if SOUND exist(SndNum)=1
SndVol = SOUND volume(SndNum)
endif
endfunction SndVol
rem ------------------------------------------------------------------------------
rem END 3DSOUND FUNCTIONS
rem ------------------------------------------------------------------------------
rem ------------------------------------------------------------------------------
rem Music FUNCTIONS
rem ------------------------------------------------------------------------------
rem LOAD Music : LOAD Music Filename,Music Number
function Load_Music(MusicFile$,MusicNum)
rem if the file exists
if file exist(MusicFile$)=1
load Music MusicFile$,MusicNum
else
rem Error File Check
ErrMsg$ = " * Error :: File : " +MusicFile$ + " does not exist. Press any Key to Exit"
cls
ink rgb(255,255,255),1
text 10,10,ErrMsg$
sync
suspend for key
end
endif
endfunction
rem PLAY Music : PLAY Music Music Number
function Play_Music(MusicNum)
rem if the file exists
if Music exist(MusicNum)=1
play Music MusicNum
else
rem Error File Check
ErrMsg$ = "*Error- Music num : " +STR$(MusicNum) + " does not exist. Press any Key to Exit"
cls
ink rgb(255,255,255),1
text 10,10,ErrMsg$
sync
suspend for key
end
endif
endfunction
rem PAUSE Music : PAUSE Music Music Number
function Pause_Music(MusicNum)
if Music exist(MusicNum)=1
if Music playing(MusicNum)=1
pause Music MusicNum
endif
endif
endfunction
rem LOOP Music : LOOP Music Music Number,StartPos,EndPos,InitialPos
function Loop_Music(MusicNum)
if Music exist(MusicNum)=1
if Music playing(MusicNum)=1
loop Music MusicNum
endif
endif
endfunction
rem RESUME Music : RESUME Music Music Number
function Resume_Music(MusicNum)
if Music exist(MusicNum)=1
if Music paused(MusicNum)=1
resume Music MusicNum
endif
endif
endfunction
rem DELETE Music : DELETE Music Music Number
function Delete_Music(MusicNum)
rem if the file exists
if Music exist(MusicNum)=1
delete Music MusicNum
else
rem Error File Check
ErrMsg$ = "*Error- Music num : " +STR$(MusicNum) + " could not be deleted. Press any Key to Exit"
cls
ink rgb(255,255,255),1
text 10,10,ErrMsg$
sync
suspend for key
end
endif
endfunction
rem STOP Music : STOP Music Music Number
function Stop_Music(MusicNum)
rem if the file exists
if Music playing(MusicNum)=1
stop Music MusicNum
endif
endfunction
rem SET Music SPEED : SET Music SPEED Music Number,Frequency Value
function Set_Music_Speed(MusicNum,Freq)
if Music exist(MusicNum)=1
set Music speed MusicNum,Freq
endif
endfunction
rem SET Music VOLUME : SET Music VOLUME Music Number,Volume Number
function Set_Music_Volume(MusicNum,Vol)
if Music exist(MusicNum)=1
set Music volume MusicNum,Vol
endif
endfunction
rem Music SPEED : Return Integer=Music SPEED(Music Number)
function Get_Music_Speed(MusicNum)
if Music exist(MusicNum)=1
MusicSpeed = Music speed(MusicNum)
endif
endfunction MusicSpeed
rem Music VOLUME : Return Integer=Music VOLUME(Music Number)
function Get_Music_Volume(MusicNum)
if Music exist(MusicNum)=1
MusicVol = Music volume(MusicNum)
endif
endfunction MusicVol
rem ------------------------------------------------------------------------------
rem END Music FUNCTIONS
rem ------------------------------------------------------------------------------
rem ------------------------------------------------------------------------------
rem STANDARD FUNCTIONS FROM DBP
rem STEREO or MONO WAV SOUNDS
rem ------------------------------------------------------------------------------
rem LOAD SOUND : LOAD SOUND Filename,Sound Number
rem DELETE SOUND : DELETE SOUND Sound Number
rem CLONE SOUND : CLONE SOUND Destination Sound,Source Sound
rem PAUSE SOUND : PAUSE SOUND Sound Number
rem LOOP SOUND : LOOP SOUND Sound Number
rem STOP SOUND : STOP SOUND Sound Number
rem PAUSE SOUND : PAUSE SOUND Sound Number
rem RESUME SOUND : RESUME SOUND Sound Number
rem SET SOUND PAN : SET SOUND PAN Sound Number,Pan Value
rem SET SOUND SPEED : SET SOUND SPEED Sound Number,Frequency Value
rem SET SOUND VOLUME : SET SOUND VOLUME Sound Number,Volume Number
rem SOUND EXIST : Return Integer=SOUND EXIST(Sound Number)
rem SOUND TYPE : Return Integer=SOUND TYPE(Sound Number)
rem SOUND PLAYING : Return Integer=SOUND PLAYING(Sound Number)
rem SOUND LOOPING : Return Integer=SOUND LOOPING(Sound Number)
rem SOUND PAUSED : Return Integer=SOUND PAUSED(Sound Number)
rem SOUND PAN : Return Integer=SOUND PAN(Sound Number)
rem SOUND SPEED : Return Integer=SOUND SPEED(Sound Number)
rem SOUND VOLUME : Return Integer=SOUND VOLUME(Sound Number)
rem ------------------------------------------------------------------------------
rem ------------------------------------------------------------------------------
rem MUSIC CD AND MP# COMMANDS
rem ------------------------------------------------------------------------------
rem LOAD MUSIC : LOAD MUSIC Filename,Music Number
rem DELETE MUSIC : DELETE MUSIC Music Number
rem PLAY MUSIC : PLAY MUSIC Music Number
rem MUSIC : LOOP MUSIC Music Number
rem MUSIC : STOP MUSIC Music Number
rem PAUSE MUSIC : PAUSE MUSIC Music Number
rem RESUME MUSIC : RESUME MUSIC Music Number
rem SET MUSIC SPEED : SET MUSIC SPEED Music Number,Speed
rem SET MUSIC VOLUME : SET MUSIC VOLUME Music Number,Volume
rem MUSIC EXIST : Return Integer=MUSIC EXIST(Music Number)
rem MUSIC PLAYING : Return Integer=MUSIC PLAYING(Music Number)
rem MUSIC LOOPING : Return Integer=MUSIC LOOPING(Music Number)
rem MUSIC PAUSED : Return Integer=MUSIC PAUSED(Music Number)
rem MUSIC SPEED : Return Integer=MUSIC SPEED(Music Number)
rem MUSIC VOLUME : Return Integer=MUSIC VOLUME(Music Number)
rem ------------------------------------------------------------------------------
rem ------------------------------------------------------------------------------
rem NOT MADE YET : 3D MONO WAV SOUNDS and LISTENING COMMANDS
rem ------------------------------------------------------------------------------
rem LOAD 3DSOUND : LOAD 3DSOUND Filename,Sound Number
rem POSITION SOUND : POSITION SOUND Sound Number,X,Y,Z
rem SOUND POSITION X : Return Float=SOUND POSITION X(Sound Number)
rem SOUND POSITION Y : Return Float=SOUND POSITION Y(Sound Number)
rem SOUND POSITION Z : Return Float=SOUND POSITION Z(Sound Number)
rem POSITION LISTENER : POSITION LISTENER X,Y,Z
rem ROTATE LISTENER : ROTATE LISTENER X,Y,Z
rem SCALE LISTENER : SCALE LISTENER Scaling Factor
rem LISTENER POSITION X : Return Float=LISTENER POSITION X()
rem LISTENER POSITION Y : Return Float=LISTENER POSITION Y()
rem LISTENER POSITION Z : Return Float=LISTENER POSITION Z()
rem *** HAVENT TESTED *** LISTENER ANGLE X : Return Float=LISTENER ANGLE X()
rem *** HAVENT TESTED *** LISTENER ANGLE Y : Return Float=LISTENER ANGLE Y()
rem *** HAVENT TESTED *** LISTENER ANGLE Z : Return Float=LISTENER ANGLE Z()
rem *** HAVENT TESTED *** LOAD CDMUSIC : LOAD CDMUSIC Track Number,Music Number
rem *** HAVENT TESTED *** GET NUMBER OF CD TRACKS : Return Integer=GET NUMBER OF CD TRACKS()
rem *** HAVENT TESTED *** RECORD SOUND : RECORD SOUND Sound Number
rem *** HAVENT TESTED *** STOP RECORDING SOUND : STOP RECORDING SOUND
rem *** HAVENT TESTED *** SAVE SOUND : SAVE SOUND Filename,Sound Number
rem ------------------------------------------------------------------------------
indi is part of Team Lunarpixel
multimedia logisitics and interactive media