home *** CD-ROM | disk | FTP | other *** search
/ PC World 2000 August / PCWorld_2000-08_cd.bin / Software / TemaCD / xbasic / xbpro.exe / xb / asound.x < prev    next >
Text File  |  1999-11-28  |  2KB  |  61 lines

  1. '
  2. ' ####################
  3. ' #####  PROLOG  #####
  4. ' ####################
  5. '
  6. PROGRAM    "asound"
  7. VERSION    "0.0000"
  8. '
  9. IMPORT    "xst"                        ' XBasic standard library
  10. IMPORT    "winmm"                    ' one of the win32 API libraries
  11. IMPORT    "kernel32"            ' one of the win32 API libraries
  12. '
  13. ' this program needs file "winmm.dec" in your XBasic directory
  14. '
  15. DECLARE FUNCTION  Entry ()
  16. '
  17. '
  18. ' ######################
  19. ' #####  Entry ()  #####
  20. ' ######################
  21. '
  22. FUNCTION  Entry ()
  23. '
  24. ' This loop plays a series of beeps by calling the
  25. ' Beep() function in the win32 "kernel32" API library.
  26. ' Windows95/98 ignore frequency and duration arguments.
  27. '
  28.     duration = 10
  29.     FOR frequency = 100 TO 1000 STEP 200
  30.         result = Beep (frequency, duration)
  31.         PRINT result, duration, frequency
  32.         XstSleep (1000)
  33.     NEXT
  34. '
  35. '
  36. ' But Windows95/98 do play WAV files, so you can make
  37. ' your program play a variety of interesting sounds.
  38. ' This loop plays a series of WAV sound files that are
  39. ' in my windows sound directory.  Not every file this
  40. ' loop tries to play exists, but that's okay because
  41. ' it just returns a 0 (failed) instead of 1 (success)
  42. ' and moves on to the next sound.  If your system does
  43. ' not have the specified WAV files, find a WAV file on
  44. ' your system and replace it in the following line.
  45. ' result = sndPlaySoundA (&"c:/windows/media/sound/sound1.wav", sync)
  46. ' Note: XBasic understands "/" as directory separators,
  47. ' but if you prefer "\" characters, you must double up,
  48. ' as in "c:\\windows\\media\\sound\\sound1.wav".
  49. '
  50.     sync = 0
  51.     async = 1
  52.     sound$ = "c:/windows/media/sound/sound"
  53. '
  54.     FOR i = 1 TO 59
  55.         play$ = sound$ + STRING$ (i)
  56.         result = sndPlaySoundA (&play$, sync)
  57.         PRINT result, play$
  58.     NEXT
  59. END FUNCTION
  60. END PROGRAM
  61.