'=========================================================================== ' Subject: PB .WAV PLAYER Date: 03-27-96 (00:00) ' Author: Dave Navarro, Jr. Code: PB ' Origin: www.powerbasic.com/source Packet: SOUND.ABC '=========================================================================== '============================================================================= ' Source code snippet: PowerBASIC for DOS ' ' Original found at http://www.fys.ruu.nl/~bergmann/basic.html ' converted to PowerBASIC by Dave Navarro, Jr. ' additional work by unknown author on CompuServe ' ' Play wave files through the SoundBlaster. ' '============================================================================= DEFINT A-Z MaxTicks& = 1193180 SHARED WritePort%, MaxTicks& '-Div.Init (maybe you get the filename from command line? CLS FILES ("*.WAV") INPUT "Select Wave File"; VocFile$ VocFile% = FREEFILE '-open the voc-file OPEN VocFile$ FOR BINARY AS #VocFile% TestPort$ = ENVIRON$("BLASTER") IF TestPort$ > "" THEN PortAddress$ = "&H" + MID$(TestPort$, 2, 3) PortAddress = VAL(PortAddress$) WritePort = PortAddress + 12 ELSE WritePort = &H22C END IF '-parameters for copy-to-soundblaster Bytes& = LOF(VocFile%) 'number of bytes X$ = SPACE$(40) 'riff file header stuff GET #VocFile, , X$ Speed = ASC(MID$(X$, 26, 1)) * 256 OR ASC(MID$(X$, 25, 1)) 'Playrate in Bytes per second. 'We are assuming an 8 bit *.Wav File Here ' And my 386-16 will hang in there at 11025 BPS under DOS Clocks = MaxTicks& \ Speed 'using an integer divide. Close enough 'and doesn't pull in floating point math pack 'Maxticks are for the "normal" PC Clock at '18.206 + ticks per second. 'We'll use this to time the play rate. Bytes& = Bytes& - 40 BytesRemaining& = Bytes& 'number of remaining bytes BufferMax% = &H3F00 'largest buffer Buffer$ = SPACE$(BufferMax%) 'create buffer SetVoice 1 'Soundblaster on '-read {BufferMax%} bytes from disc, output on SB DO BytesRemaining& = BytesRemaining& - BufferLen% IF BytesRemaining& = 0 THEN EXIT DO 'nothing left over? IF BytesRemaining& > BufferMax% THEN 'how many bytes? BufferLen% = BufferMax% ELSE BufferLen% = BytesRemaining& 'remaining (