home *** CD-ROM | disk | FTP | other *** search
- Unit spx_dma;
-
- {$O+,X+,S- }
- { SPX Library Version 2.0 Copyright 1993 Scott D. Ramsay }
- { sprite data. Requires Turbo Vision unit: MEMORY }
-
- { Digital sound for Sound Blaster and compatibles via DMA }
- { Only supports mono wav and voc files. :( }
-
- Interface
-
- Uses crt,dos,spx_dos,spx_fnc,memory;
-
- const
- DEFAULT_BUFFER : word = $2000;
- DEFAULT_IRQ : byte = 5;
- DEFAULT_DMA : byte = 1;
- spxDMAnoerror = 0;
- spxDMAnoSB = -1; { unable to init sound blaster card }
- spxDMAnomem = -2; { unable to allocate DMA buffers }
- spxDMAplaying = -3; { sound still playing }
- spxDMAcomplete = -4; { sound is complete }
- spxDMAdiskerr = -5; { error reading sound file }
- spxDMAnotinit = -6; { PdigiInfo not initalized }
-
- type
- PdigiInfo = ^TdigiInfo;
- TdigiInfo = record
- hz, { sample rate }
- fhandle : word; { dos file handle }
- spoint, { start point in file }
- fsize : longint; { sample size in file }
- inmem : pointer; { use if fhandle = 0 }
- fln : string; { audio file name }
- dspoint : longint; { internal use do not modify }
- tsize : word; { internal use do not modify }
- playmode : byte; { internal use do not modify }
- end;
- PWAVHDR = ^TWAVHDR;
- TWAVHDR = record
- riff : array[0..3] of char; { "RIFF" }
- fln1 : longint; { filesize-8 }
- WaveFmt : array[0..7] of char; { "WAVEfmt"#32 }
- NoClue : array[0..7] of byte; { I have no idea }
- Sampl1, { Sample rates }
- Sampl2 : longint; { in Hz }
- NoClue2 : longint; { I have no idea 2 }
- data : array[0..3] of char; { "data" }
- fln2 : longint; { filesize-44 }
- end;
- PVOCHDR = ^TVOCHDR;
- TVOCHDR = record
- ftypedes : array[0..$13] of char;
- doff,ver,
- id : word;
- end;
- INT3 = array[0..2] of byte;
- PVOCDHDR = ^TVOCDHDR;
- TVOCDHDR = record
- kind : byte; { 1 = Voice Data }
- blklen : INT3;
- tc : byte; { time constant }
- pack : byte; { compression: 0 = 8-bit raw }
- end;
-
- var
- irq,dma : byte;
- base,
- BufferSize : word;
- InitError : integer;
-
- function open_wav(filename:string):PdigiInfo; { open wav for reading }
- function open_voc(filename:string):PdigiInfo; { open voc for reading }
- function load_wav(filename:string):PdigiInfo; { load 64k or smaller wav in mem }
- function load_voc(filename:string):PdigiInfo; { load 64k or smaller voc in mem }
- function play_digi(p:PdigiInfo;rstart:boolean):integer; { play PdigiInfo }
- procedure cleanup_digi(var p:PdigiInfo); { remove from mem/close file }
-
-