Smart questions
Smart answers
Smart people

Member Login

Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Donate Today!

Do you enjoy these
technical forums?
Donate Today! Click Here

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

QBasic FAQ

Sound effects

How to access the FM music chips on a Sound Blaster card
Posted: 23 Dec 00

You can pick up at my site below:

The Zip file includes source code in both Basic and C showing how to use the FM music chips on the soundblaster and compatable cards. This is NOT a demo / code example of how to play WAV files. Included is a working execuable file (For DOS) and the Jeffrey S. Lee AdLib/Sound Blaster programming FAQ.

Or, try out the code below:

DECLARE SUB wradlib (address%, byte%)
DECLARE SUB rstlib ()

PRINT "Resetting Adlib/SB Card!"
CALL rstlib
PRINT "Ready to play..."

'In this group of Calls, play around with the 2nd hex number (The byte%
' variable) for special effects.

CALL wradlib(&H1, &H20)    'Enable Waveform control
CALL wradlib(&H20, &HE0)   'Set modulator settings
CALL wradlib(&H40, &H80)   'Set the modulator's level to max and
                           'set scaling factor to 1.5db/8ve
CALL wradlib(&H60, &HF2)    'Set attack & decay to med-slow
CALL wradlib(&H80, &H77)   'Set sustain to min. & Release to med.
CALL wradlib(&HA0, &H0)    'Set default note (Not really neccesary)
CALL wradlib(&HC0, &H4)    'Set feedback and Algorithm.
CALL wradlib(&H23, &HC1)   'Set mod. freq. Multiple, etc. of 2nd Op.
CALL wradlib(&H43, &H0)    'Set volume of 2nd operator to max.
CALL wradlib(&H63, &HF5)   'Set attack & decay of 2nd operator
CALL wradlib(&H83, &H77)   'Set sustain to min. & Release of 2nd. Op.
CALL wradlib(&HBD, &H80)   'Set AM depth to the max.
CALL wradlib(&HE0, &H0)    'Setup waveforms for 1st. Op.
CALL wradlib(&HE3, &H0)    'Setup waveforms for 2nd. Op.
CALL wradlib(&HB0, &H22)   'Turn on the voice, set octave, etc..

' Following code will turn your keyboard into a Musical Keyboard
PRINT "Hit Escape key to stop"
DO WHILE note% <> 54
   SLEEP                      'Wait for next keypress
   a$ = INKEY$
   IF a$ = "" THEN a$ = CHR$(127)
   note% = ASC(a$) * 2        'Scale the number for a wider freq. range
   CALL wradlib(&HB0, &H11)   'Turn sound off
   CALL wradlib(&HA0, note%)  'Setup the frequency of the note
   CALL wradlib(&HB0, &H31)   'Turn on the sound
CALL wradlib(&HB0, &H11)      'Turn sound off

SUB rstlib

'This SUB sets all Adlib registers to zero

FOR t% = 1 TO &H8
CALL wradlib(t%, 0)

FOR t% = &H20 TO &H35
CALL wradlib(t%, 0)

FOR t% = &H40 TO &H55
CALL wradlib(t%, 0)

FOR t% = &H60 TO &H75
CALL wradlib(t%, 0)

FOR t% = &H80 TO &H95
CALL wradlib(t%, 0)

FOR t% = &HA0 TO &HA8
CALL wradlib(t%, 0)

FOR t% = &HB0 TO &HB8
CALL wradlib(t%, 0)

CALL wradlib(&HBD, 0)

FOR t% = &HC0 TO &HC8
CALL wradlib(t%, 0)

FOR t% = &HE0 TO &HF5
CALL wradlib(t%, 0)


SUB wradlib (address%, byte%)

'This SUB sends the data (byte%) to the subport specified by address%
'All subports are accessed via IO addresses &H388 and &H389

OUT &H388, address%
FOR t% = 1 TO 6
        q% = INP(&H388) 'Delay to give Adlib time to process code

OUT &H389, byte%
FOR t% = 1 TO 35
        q% = INP(&H388) 'Delay to give Adlib time to process code


Back to QBasic FAQ Index
Back to QBasic Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close