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

  1. ' $INCLUDE: 'SBC.BI'
  2. ' $INCLUDE: 'SBCSYS.BI'
  3. ' $INCLUDE: 'SBCMUSIC.BI'
  4.  
  5. DECLARE SUB  SETINSTBL (instrument%())
  6.  
  7. REM $DYNAMIC
  8. CLEAR
  9.  
  10. CLS
  11.  
  12. PRINT "SBK QuickBasic FM Low Level Example"
  13.  
  14. DIM instrument%(1 TO 128,1 TO 8)
  15.  
  16. ' Set I/O address
  17. CTIOADDX (&H220)
  18.  
  19. ' Check for Sound Blaster Card
  20. IF (SBCHKCRD% > 4) THEN
  21.  
  22.      ' Initialize driver
  23.      CALL SLINIT
  24.  
  25.      ' Setup the instrument table
  26.      CALL SETINSTBL(instrument%())
  27.  
  28.      ' Set the instrument table for driver
  29.      CALL SLINST(instrument%(1,1))
  30.  
  31.      CALL PLAYSCALE
  32.  
  33.      ' Reset driver before exit
  34.      CALL SLRESET
  35.  
  36. ELSE
  37.     PRINT "Sound Blaster Card not found"
  38. END IF
  39.  
  40. END
  41.  
  42.  
  43. ' ------------------------------------------------------------------------ '
  44.  
  45.  
  46. REM $STATIC
  47. SUB  SETINSTBL(instrument%())
  48.  
  49.      DIM  i AS INTEGER, j AS INTEGER, offset AS INTEGER, value AS INTEGER
  50.  
  51.      DEF SEG = VARSEG(instrument%(1,1))
  52.  
  53.      offset = VARPTR(instrument%(1,1))
  54.  
  55.      ' Set the instrument table with first 10 instrument defined in DATA
  56.  
  57.      FOR i = 1 to 10
  58.  
  59.       FOR j = 1 to 16
  60.  
  61.            READ value
  62.  
  63.            POKE offset,value
  64.            offset = offset + 1
  65.  
  66.       NEXT
  67.  
  68.      NEXT
  69.  
  70.      DEF SEG
  71.  
  72. DATA   &H21,&H11,&H4C,&H00,&HF1,&HF2,&H63,&H72
  73. DATA   &H00,&H00,&H04,&H00,&H00,&H00,&H00,&H00
  74.  
  75. DATA   &HA5,&HB1,&HD2,&H80,&H81,&HF1,&H03,&H05
  76. DATA   &H00,&H00,&H02,&H00,&H00,&H00,&H00,&H00
  77.  
  78. DATA   &H72,&H62,&H1C,&H05,&H51,&H52,&H03,&H13
  79. DATA   &H00,&H00,&H0E,&H00,&H00,&H00,&H00,&H00
  80.  
  81. DATA   &H11,&H01,&H8A,&H40,&HF1,&HF1,&H11,&HB3
  82. DATA   &H00,&H00,&H06,&H00,&H00,&H00,&H00,&H00
  83.  
  84. DATA   &H21,&H11,&H11,&H00,&HA3,&HC4,&H43,&H22
  85. DATA   &H02,&H00,&H0D,&H00,&H00,&H00,&H00,&H00
  86.  
  87. DATA   &H31,&HA1,&H1C,&H80,&H41,&H92,&H0B,&H3B
  88. DATA   &H00,&H00,&H0E,&H00,&H00,&H00,&H00,&H00
  89.  
  90. DATA   &H71,&H62,&HC5,&H05,&H6E,&H8B,&H17,&H0E
  91. DATA   &H00,&H00,&H02,&H00,&H00,&H00,&H00,&H00
  92.  
  93. DATA   &H41,&H91,&H83,&H00,&H65,&H32,&H05,&H74
  94. DATA   &H00,&H00,&H0A,&H00,&H00,&H00,&H00,&H00
  95.  
  96. DATA   &H32,&H16,&H87,&H80,&HA1,&H7D,&H10,&H33
  97. DATA   &H00,&H00,&H08,&H00,&H00,&H00,&H00,&H00
  98.  
  99. DATA   &H01,&H13,&H8D,&H00,&H51,&H52,&H53,&H7C
  100. DATA   &H01,&H00,&H0C,&H00,&H00,&H00,&H00,&H00
  101.  
  102. END SUB
  103.  
  104.  
  105. ' ------------------------------------------------------------------------ '
  106.  
  107.  
  108. SUB PLAYSCALE
  109.  
  110.      DIM  inst AS INTEGER, delay1 AS INTEGER, delay2 AS INTEGER, note AS INTEGER
  111.      DIM  notenum%(8)
  112.  
  113.      ' Setup the MIDI note number
  114.      FOR note = 1 TO 8
  115.       READ notenum%(note)
  116.      NEXT
  117.  
  118.      ' Play each instrument
  119.      FOR inst = 0 TO 9
  120.  
  121.       ' Set channel 0 instrument
  122.       CALL SLPROGRM((0),inst)
  123.  
  124.       ' Play a scale on channel 0
  125.       FOR note = 1 TO 8
  126.  
  127.            CALL SLNOTEON((0),notenum%(note),&h40)
  128.  
  129.            ' Delay
  130.            FOR delay1 = 1 TO 100
  131.             FOR delay2 = 1 TO 4000
  132.             NEXT
  133.            NEXT
  134.  
  135.            CALL SLNOTEOFF((0),notenum%(note),&h40)
  136.       NEXT
  137.  
  138.      NEXT
  139.  
  140. DATA   60, 62, 64, 65, 67, 69, 71, 72
  141. END SUB
  142.