home *** CD-ROM | disk | FTP | other *** search
/ DarkBasic Professional / DarkBasicPro.iso / data1.cab / Lang_Files_(English) / Help / examples / sound / sound2-example.dba < prev   
Encoding:
Text File  |  2004-09-22  |  3.1 KB  |  109 lines

  1. rem Sound Functionality
  2.  
  3. rem Sound Values
  4. SoundNumber=1+rnd(4)
  5. SecondSound=6+rnd(4)
  6. 3DSoundNumber=11+rnd(4)
  7.  
  8. rem Main loop
  9. while mouseclick()=0
  10.  
  11. rem Random values
  12. Volume=50+rnd(50)
  13. Speed=100+rnd(99900)
  14. Pan=-10000+rnd(20000)
  15. StartPos=1000+rnd(2000)
  16. LXPos=rnd(10)-5
  17. LYPos=rnd(10)-5
  18. LZPos=rnd(10)-5
  19. XPos=rnd(500)-250
  20. YPos=rnd(500)-250
  21. ZPos=rnd(500)-250
  22. YAngle#=wrapvalue(YAngle#+0.1)
  23. StartPos=rnd(500)
  24. EndPos=StartPos+500+rnd(500)
  25. InitPos=rnd(2000)
  26.  
  27. rem Sound Loading
  28. if sound exist(SoundNumber)=0 then load sound "sound\smash.wav",SoundNumber
  29. if sound exist(3DSoundNumber)=0 then load 3dsound "sound\tube.wav",3DSoundNumber
  30.  
  31. rem 2D Sound Control
  32. if rnd(100)=1 then play sound 3DSoundNumber
  33. if rnd(500)=1 then play sound SoundNumber
  34. if rnd(500)=1 then play sound SoundNumber,StartPos
  35. if rnd(500)=1 then stop sound SoundNumber
  36. if rnd(500)=1 then loop sound SoundNumber
  37. if rnd(500)=1 then loop sound SoundNumber,StartPos
  38. if rnd(500)=1 then loop sound SoundNumber,StartPos,EndPos
  39. if rnd(500)=1 then loop sound SoundNumber,StartPos,EndPos,InitPos
  40. if rnd(500)=1 then pause sound SoundNumber
  41. if rnd(500)=1 then resume sound SoundNumber
  42. if rnd(500)=1 then set sound volume SoundNumber,Volume
  43. if rnd(500)=1 then set sound speed SoundNumber,SPeed
  44. if rnd(500)=1 then set sound pan SoundNumber,Pan
  45.  
  46. if sound exist(SecondSound)=1 then delete sound SecondSound
  47. if rnd(500)=1 then clone sound SecondSound,SoundNumber
  48.  
  49. rem 3D Sound Control
  50. if sound exist(3DSoundNumber)=1
  51.  if rnd(500)=1 then position sound 3DSoundNumber,XPos,YPos,ZPos
  52.  if rnd(500)=1 then position listener LXPos,LYPos,LZPos
  53.  if rnd(500)=1 then rotate listener 0,YAngle#,0
  54.  if rnd(500)=1 then scale listener 0.1
  55. endif
  56.  
  57. rem Recording a Sound
  58. if rnd(500)=1
  59.  print "Recording..."
  60.  Duration=2000+rnd(3000)
  61.  if rnd(1)=1
  62.   record sound SoundNumber,Duration
  63.  else
  64.   record sound SoundNumber
  65.  endif
  66.  wait Duration
  67.  stop recording sound
  68.  if sound exist(SoundNumber)=1
  69.   save sound "mysound.wav",SoundNumber
  70.  endif
  71. endif
  72.  
  73. rem Sound Data
  74. cls
  75. print "Sound Data"
  76. print
  77. print "exist:";sound exist(SoundNumber)
  78. if sound exist(SoundNumber)=1
  79.  print "type:";sound type(SoundNumber)
  80.  print "playing:";sound playing(SoundNumber)
  81.  print "looping:";sound looping(SoundNumber)
  82.  print "paused:";sound paused(SoundNumber)
  83.  print "volume:";sound volume(SoundNumber)
  84.  print "speed:";sound speed(SoundNumber)
  85.  print "pan:";sound pan(SoundNumber)
  86. endif
  87. if sound exist(3DSoundNumber)=1
  88.  print "positionx:";sound position x(3DSoundNumber)
  89.  print "positiony:";sound position y(3DSoundNumber)
  90.  print "positionz:";sound position z(3DSoundNumber)
  91. endif
  92. print
  93. print "Listener Data"
  94. print
  95. print "positionx:";listener position x()
  96. print "positiony:";listener position y()
  97. print "positionz:";listener position z()
  98. print "anglex:";listener angle x()
  99. print "angley:";listener angle y()
  100. print "anglez:";listener angle z()
  101.  
  102. rem End loop
  103. endwhile
  104.  
  105. rem Delete sounds
  106. if sound exist(SoundNumber)=1 then delete sound SoundNumber
  107. if sound exist(SecondSound)=1 then delete sound SecondSound
  108. if sound exist(3DSoundNumber)=1 then delete sound 3DSoundNumber
  109.