BBS: Inland Empire Archive Date: 03-31-93 (15:31) Number: 290 From: JOHN GALLAS Refer#: NONE To: PAUL CRUTCHFIELD Recvd: NO Subj: Quickbasic 4.5 Question] Conf: (2) Quik_Bas
PC> I wish to know the following: PC> Using Soundblaster, play music through sb speaker (Without .MOD, PC>.CMF, just memory stuff..like the PLAY "ABC" command except going PC>through the sb speaker. Try this: '-------------------------------clip here------------------------------- ' Sound Blaster Source Code ' Made by Brandon Callison ' Register 388h is the address/status port, and 389h is the data port. 'This is, of course, only for the FM music. (The cannels 1-11) which are 'compatible with Ad-Lib, Sound Blaster, SB Pro, Thunder Board, and many 'others. All boards advertised as compatible with Ad-Lib or Sound Blaster 'are compatible with this. Explainations of the mysterious code will be 'throughout the program. DEFINT A-Z DECLARE SUB SBStop () DECLARE SUB SBReset () DECLARE SUB SBOutPort (reg, x) DECLARE SUB SBPlayNote (freq#, oct) ' vvvvvvvvvvvvvvvvvvvvvvv ' The following are his variable declarations; I'm leaving them in so you ' can see what all the variables are for: ' 'float freq; /* Frequency */ 'int oct; /* Octave */ 'int reg; /* Register no. */ 'int x; /* Poke number to register */ 'int i; /* GLOBAL Dummy loop signal */ ' ' ^^^^^^^^^^^^^^^^^^^^^^^ SBReset SBPlayNote 277.2, 5 'Middle C sharp on octave 5 SLEEP 2 SBStop 'Must be called to cut sound END SUB SBOutPort (reg, x) OUT &H388, reg 'Outputs the register to be written to FOR I = 1 TO 6 reg = INP(&H388) NEXT I ' ^- This loop requires some explaining. The sound card must allow time 'to process it's code. 6 reads from the status port will cause it to wait 'for 2.3 microseconds. You MUST NOT make any outputs to the sound card port 'without waiting at least this amount of time in-between calls. The same 'applies below, except the wait is 23 microseconds, by 35 reads from the data 'port. OUT &H389, x FOR I = 1 TO 35 'Outputs the data into the register reg = INP(&H389) NEXT I END SUB SUB SBPlayNote (freq#, oct) freq2 = INT(1.31 * freq#) 'Convert from hz to raw frequency?!?! SBOutPort &H60, &HF0 SBOutPort &HC0, 1 SBOutPort &HA0, freq2 AND &HFF SBOutPort &HB0, ((freq2 AND &HFF00) / &H100) OR (oct * 4) OR 32 ' ^- for different channels, do anywhere from the register ' 0xB0 to 0xBA. (channels 1-11) END SUB SUB SBReset FOR I = 1 TO 244 ' The sound card has 244 data ports. Just clears OUT &H388, 0 ' all of them. NEXT I END SUB SUB SBStop SBOutPort &HB0, 0 ' As I said earlier for different channels END SUB * OLX 2.1 TD * "If you can't make it good, make it LOOK good." - B Gates --- Maximus 2.01wb * Origin: Command Line BBS =Mpls. MN= V.32bis [612-788-6685] (1:282/2007)
Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET