INTELLIGENT WORK FORUMS FOR COMPUTER PROFESSIONALS
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!
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.
Partner With Us!
"Best Of Breed" Forums Add Stickiness To Your Site

(Download This Button Today!)
Feedback
"...I think the forum is a great idea, especially for those of us in consulting engineering. Keep up the good work!..."
Geography
Where in the world do Tek-Tips members come from?
|
Sound effects
|
How to access the FM music chips on a Sound Blaster card
Posted: 23 Dec 00
|
You can pick up Blaster.zip at my site below:
http://www3.bc.sympatico.ca/Kim_Christensen/program.html
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 ()
CLS 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 LOOP 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) NEXT
FOR t% = &H20 TO &H35 CALL wradlib(t%, 0) NEXT
FOR t% = &H40 TO &H55 CALL wradlib(t%, 0) NEXT
FOR t% = &H60 TO &H75 CALL wradlib(t%, 0) NEXT
FOR t% = &H80 TO &H95 CALL wradlib(t%, 0) NEXT
FOR t% = &HA0 TO &HA8 CALL wradlib(t%, 0) NEXT
FOR t% = &HB0 TO &HB8 CALL wradlib(t%, 0) NEXT
CALL wradlib(&HBD, 0)
FOR t% = &HC0 TO &HC8 CALL wradlib(t%, 0) NEXT
FOR t% = &HE0 TO &HF5 CALL wradlib(t%, 0) NEXT
END SUB
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 NEXT
OUT &H389, byte% FOR t% = 1 TO 35 q% = INP(&H388) 'Delay to give Adlib time to process code NEXT
END SUB
|
Back to QBasic FAQ Index
Back to QBasic Forum |
|
 |
|