home *** CD-ROM | disk | FTP | other *** search
/ Sound Sensations! / sound_sensations.iso / soundb / qb_sbkit / demovdr.bas < prev    next >
BASIC Source File  |  1990-07-01  |  2KB  |  127 lines

  1. '
  2. ' This program records a voice file TEMP.VOC
  3. '
  4.  
  5. ' $INCLUDE: 'SBC.BI'
  6. ' $INCLUDE: 'SBCSYS.BI'
  7. ' $INCLUDE: 'SBCVOICE.BI'
  8.  
  9. DECLARE   SUB  RECVOCFILE(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 Recording (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 RECVOCFILE("TEMP.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  RECVOCFILE(filename$)
  73.  
  74. ' This function create a file and record voice into it
  75.  
  76.      DIM  handle AS INTEGER, userkey AS INTEGER
  77.  
  78.      handle = DOSCREATE%(filename$)
  79.  
  80.      IF (handle <> 0) THEN
  81.  
  82.       SVDSPKER(INT(0))
  83.  
  84.       IF (SVDINPUT%(handle,(8000)) = 0) THEN
  85.  
  86.            WHILE CTVOICE% <> 0
  87.  
  88.             c$ = INKEY$
  89.  
  90.             IF (c$ <> "") THEN
  91.  
  92.              userkey = ASC(c$)
  93.  
  94.              IF userkey = 27 THEN
  95.                   CALL SVDSTOP
  96.              ENDIF
  97.  
  98.             ENDIF
  99.  
  100.            WEND
  101.  
  102.       ENDIF
  103.  
  104.      ENDIF
  105.  
  106. END SUB
  107.  
  108.  
  109. ' ------------------------------------------------------------------------ '
  110.  
  111.  
  112. SUB  SHOWERROR
  113.  
  114. ' This function show the error code from the driver
  115.  
  116.      DIM  errcode AS INTEGER
  117.  
  118.      errcode = SVDDRVERR%
  119.  
  120.      PRINT "Driver error ="; errcode
  121.  
  122.      IF (errcode <> 6) AND (errcode <> 2) THEN
  123.       PRINT "Dos error ="; SVDEXTERR%
  124.      ENDIF
  125.  
  126. END SUB
  127.