home *** CD-ROM | disk | FTP | other *** search
/ Sound Sensations! / sound_sensations.iso / soundb / qb_sbkit / demovdp.bas < prev    next >
BASIC Source File  |  1990-07-02  |  3KB  |  138 lines

  1. '
  2. ' This program output the voice file DEMO.VOC
  3. '
  4.  
  5. ' $INCLUDE: 'SBC.BI'
  6. ' $INCLUDE: 'SBCSYS.BI'
  7. ' $INCLUDE: 'SBCVOICE.BI'
  8.  
  9. DECLARE   SUB  OUTVOCFILE(filename$)
  10. DECLARE   SUB  SHOWERROR()
  11.  
  12. REM $DYNAMIC
  13. CLEAR
  14.  
  15. ' Following statements free memory for the Disk Double Buffer
  16. ' Two 32K buffers are released by BASIC
  17. DUMMY = SETMEM(-16400)
  18. DUMMY = SETMEM(-16400)
  19. DUMMY = SETMEM(-16400)
  20. DUMMY = SETMEM(-16400)
  21.  
  22. CLS
  23.  
  24. PRINT "SBK QuickBasic Voice Output (disk version) Example"
  25.  
  26. ' Set I/O address
  27. CTIOADDX (&H220)
  28.  
  29. ' Detect Sound Blaster Card
  30. IF ((SBCHKCRD% AND 4) = 4) THEN
  31.  
  32.      ' Detect interrupt
  33.      IF (SBSCNINT% > 0) THEN
  34.  
  35.       ' Initial the driver, with 64K buffer as double buffer
  36.       IF ( SVDINIT%((16)) = 0 ) THEN
  37.  
  38.            ' Off DAC speaker
  39.            CALL SVDSPKER(INT(0))
  40.  
  41.            ' Output the voice file
  42.            CALL OUTVOCFILE("DEMO.VOC")
  43.  
  44.            ' Terminate the driver
  45.            CALL SVDEXIT
  46.  
  47.       ELSE
  48.            CALL SHOWERROR
  49.       ENDIF
  50.  
  51.      ELSE
  52.       PRINT "Interrupt error."
  53.      END IF
  54.  
  55. ELSE
  56.     PRINT "Sound Blaster Card not found"
  57. END IF
  58.  
  59. ' Return the memory to BASIC
  60. DUMMY = SETMEM(16400)
  61. DUMMY = SETMEM(16400)
  62. DUMMY = SETMEM(16400)
  63. DUMMY = SETMEM(16400)
  64.  
  65. END
  66.  
  67.  
  68. ' ------------------------------------------------------------------------ '
  69.  
  70.  
  71. REM %STATIC
  72. SUB  OUTVOCFILE(filename$)
  73.  
  74.      DIM  handle AS INTEGER, userkey AS INTEGER
  75.  
  76.      ' Open the file using DOS function
  77.      handle = DOSOPEN%(filename$)
  78.  
  79.      IF (handle <> 0) THEN
  80.  
  81.       ' Turn on speaker
  82.       SVDSPKER(INT(1))
  83.  
  84.       ' Start the output
  85.       IF (SVDOUTPUT%(handle) = 0) THEN
  86.  
  87.            WHILE CTVOICE% <> 0
  88.  
  89.             c$ = INKEY$
  90.  
  91.             IF c$ <> "" THEN
  92.  
  93.              userkey = INT(ASC(LEFT$(c$, 1)))
  94.  
  95.              SELECT CASE userkey
  96.                   CASE ASC("S"), ASC("s"), 27
  97.                    CALL SVDSTOP
  98.                   CASE ASC("P"), ASC("p")
  99.                    CALL SVDPAUSE
  100.                   CASE ASC("C"), ASC("c")
  101.                    CALL SVDCONT
  102.                   CASE ASC("B"), ASC("b")
  103.                    SVDBREAK(INT(1))
  104.              END SELECT
  105.  
  106.             END IF
  107.  
  108.            WEND
  109.  
  110.       ELSE
  111.            CALL SHOWERROR
  112.       ENDIF
  113.      ELSE
  114.       PRINT "Open " +filename$ + "error."
  115.      ENDIF
  116.  
  117. END SUB
  118.  
  119.  
  120. ' ------------------------------------------------------------------------ '
  121.  
  122.  
  123. SUB  SHOWERROR
  124.  
  125. ' This function show the error code from the driver
  126.  
  127.      DIM  errcode AS INTEGER
  128.  
  129.      errcode = SVDDRVERR%
  130.  
  131.      PRINT "Driver error ="; errcode
  132.  
  133.      IF (errcode <> 6) AND (errcode <> 2) THEN
  134.       PRINT "Dos error ="; SVDEXTERR%
  135.      ENDIF
  136.  
  137. END SUB
  138.