Help ! Sound Blaster Pro 
Author Message
 Help ! Sound Blaster Pro

IA>HI,
IA>        Can anyone lead a way for me to connect the Sound Blaster Card ?
IA>Like DMA Channel , Interrupt, OR any Qbasic code that can control the
IA>sound card to play a tune ?
IA>        I had tried the Interruptx command but still no success ,
IA>help me please !

IA>Regards,
IA>---L.K.ANG---

here's one that'll work with Qbasic (and QuickBASIC).

DECLARE SUB TickPause (Ticks%)

Notes$ = "C#D D#E F F#G G#A A# B C "
DEFINT X-Z
CONST SemiTone = 1.05946: KeyOn = 32
HE$ = "0123456789ABCDEF"
AddressPort = &H388
DataPort = &H389

OUT AddressPort, &H4: OUT DataPort, &H60
OUT AddressPort, &H4: OUT DataPort, &H80
T1 = INP(AddressPort)
OUT AddressPort, &H2: OUT DataPort, &HFF
OUT AddressPort, &H4: OUT DataPort, &H21
TickPause 11
T2 = INP(AddressPort)
IF (T1 AND &HE0) = 0 AND (T2 AND &HE0) = &HC0 THEN
    PRINT "AdLib soundcard (or compatible) found!"
  ELSE PRINT "No soundcard found. Using PC speaker."
END IF

'Clear AdLib's Registers.

FOR ClrPort = 0 TO 244:
    OUT AddressPort, clport: OUT DataPort, 0
NEXT ClrPort

'Init Sound Card

OUT AddressPort, &H20: OUT DataPort, &H1
OUT AddressPort, &H40: OUT DataPort, &H10
OUT AddressPort, &H60: OUT DataPort, &HF0
OUT AddressPort, &H80: OUT DataPort, &HF0
OUT AddressPort, &H23: OUT DataPort, &H1
OUT AddressPort, &H43: OUT DataPort, &H0
OUT AddressPort, &H63: OUT DataPort, &HF0
OUT AddressPort, &H83: OUT DataPort, &H77

CLS

FOR Octave = 4 TO 4
 Csharp = 363
 PRINT "---"
 PRINT "Octave "; Octave
     FOR Scale = 0 TO 11
        PRINT MID$(Notes$, (1 + Scale * 2), 2)
        PLAY "o3l7" + MID$(Notes$, (1 + Scale * 2), 2)
        Temp$ = HEX$((Csharp * SemiTone ^ Scale) + .5)
        H$ = "00" + RIGHT$(Temp$, 2)
         GOSUB Hx2
        B0$ = LEFT$(Temp$, 1): B0 = VAL(B0$)
        OUT AddressPort, &HA0: OUT DataPort, A0
        OUT AddressPort, &HB0: OUT DataPort, KeyOn + Octave * 4 + B0
        TickPause 4.5
        OUT AddressPort, &HB0: OUT DataPort, &H0
     NEXT Scale
 PRINT "---"
NEXT Octave

END

Hx2: D = 0: Q = 3
FOR M = 1 TO 4
 FOR W = 0 TO 15
 IF MID$(H$, M, 1) = MID$(HE$, W + 1, 1) THEN GOTO Hout
 NEXT W
Hout:  D1 = W * (16 ^ (Q)): D = D + D1: Q = Q - 1
NEXT M
A0 = INT(D): RETURN

'Notes*
'
'Bytes A0-B8 - Octave / F-Number / Key-On
'
'        7     6     5     4     3     2     1     0
'     ZDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD?
'     3        F-Number (least significant byte)      3  (A0-A8)
'     3                                               3

'
'        7     6     5     4     3     2     1     0
'     ZDDDDDDDDDDDBDDDDDBDDDDDDDDDDDDDDDDDBDDDDDDDDDDD?
'     3  Unused   3 Key 3    Octave       3 F-Number  3  (B0-B8)
'     3           3 On  3                 3 most sig. 3

'
'          bit   5  - Channel is voiced when set, silent when clear.
'          bits 4-2 - Octave (0-7).  0 is lowest, 7 is highest.
'          bits 1-0 - Most significant bits of F-number.
'
'     In octave 4, the F-number values for the chromatic scale and their
'     corresponding frequencies would be:
'
'        F Number     Frequency     Note   F-H  F-NUMBER L
'        DDDDDDDD     DDDDDDDDD     DDDD   DDD  DDDDDDDDDD
'           16B          277.2       C#    01   01101011
'           181          293.7       D     01   10000001
'           198          311.1       D#    01   10011000
'           1B0          329.6       E     01   10110000
'           1CA          349.2       F     01   11001010
'           1E5          370.0       F#    01   11100101
'           202          392.0       G     10   00000010
'           220          415.3       G#    10   00100000
'           241          440.0       A     10   01000001
'           263          466.2       A#    10   01100011
'           287          493.9       B     10   10000111
'           2AE          523.3       C     10   10101110
'

DEFSNG X-Z
SUB TickPause (Ticks%) STATIC
DEFINT A-Z

    ' Ticks%        The number of ticks to delay.  There are 18.2 ticks
    '               per second.  This routine returns the ticks as an
    '               integer - it does not use QB's floating point
routine.

    TestTick = 0

    DEF SEG = zero
    WHILE TestTick < Ticks

        lastTick = Tick
        Tick = PEEK(&H46C)     'Get a tick from the clock.

        '   ---- Prevents endless loop when rolling past midnight.
        IF lastTick <> Tick THEN TestTick = TestTick + 1

    WEND
    DEF SEG

END SUB

'it's also attached
============================ Automated Message ============================
There was a file attached to this message on the Bulletin Board System.
This file attachment has been routed in subsequent messages.
This file has been detected to be a binary file.  Because of this,
the file has been converted to 7-bit ASCII using UUENCODE.  You will
need UUDECODE to translate the attachment(s) back into binary format.
============================= End of Message ==============================

--
        ***Gary's Place BBS - 412 326-4039 - Internet e-mail and news***        



Thu, 31 Jul 1997 08:31:03 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Help ! Sound Blaster Pro

2. Help, Sound blaster pro !

3. A: Sound Blaster Sound

4. Sound Blaster Sound

5. QBasic Sound Programs using Sound Blaster and Adlib Cards Here

6. Help with Sound Blaster programming

7. Need help accessing A Sound Blaster compatible from Qbasic

8. Sound Blaster help for QB

9. HELP Sound Blaster

10. Sound blaster programming

11. Sound Blaster

12. Sound Blaster support in QBasic 4.0 - 7.1

 

 
Powered by phpBB® Forum Software