Category : Pascal Source Code
Archive   : W2VSRC.ZIP
Filename : WAV2VOC.PAS

 
Output of file : WAV2VOC.PAS contained in archive : W2VSRC.ZIP
{ WAV2VOC converter, by William Garrison 1993

If you wish to contact me concerning this program I can be reached at:
3625 Double Rock Lane
Baltimore, MD 21234

I would NOT like to thank Microsoft and Creative Labs for NOT giving me
cheap sad godawful documentation to their archaic file formats, and
making me dig for a year to find it.
}



{$M 2048,0,655360} { I really only need 64k }
USES
CRT;
TYPE
WaveData = Array[1..1] of Byte;
WaveHeaderData = Record
RIFF : Array[1..4] of Char;
TotalLength : LongInt;
WAVE : Array[1..4] of Char;
fmt : Array[1..4] of Char;
fmtLength : LongInt;
FormatTag,
Channels : Word;
SamplesPerSec,
AvgBytesPerSec : LongInt;
BlockAlign,
BitsPerSample : Word;
DATA : Array[1..4] of Char;
DataLength : LongInt;
End;
VOCHeaderData = Record
Title : Array[1..19] of Char;
ID : Byte;
Offset,
Ver1,
Ver2 : Word;
End;
VoiceBlock = Record
BType : Byte;
Length : Array[1..3] of Byte;
SR,
Pack : Byte;
End; { Do these exist? }
CONST { / \ }
ChanType : Array[1..4] of String[20] = ('mono','stereo','3-way','surround');
SBPath : String[80] = '\SB\VOXKIT\';
Endbyte : Byte = 0;
VAR
VOCOut,
Data : File;
WaveHeader : WaveHeaderData;
VOCHeader : VOCHeaderData;
Block : Voiceblock;
Info : ^WaveData;
TSize,
Size : LongInt;
Name,Out : String[40];
BEGIN
ClrScr;
Write('Wave file name: '); Readln(Name);
Write('VOC file name: '); Readln(Out);
Assign(Data,Name+'.WAV');
Assign(VOCOut,Out+'.VOC');
Reset(Data,1);
Rewrite(VOCOut,1);
Blockread(Data,WaveHeader,Sizeof(WaveHeader));
With WaveHeader do Begin
Writeln('Wave format data: ');
Writeln(' Format: ',8*FormatTag,'-bit ',ChanType[Channels]);
Writeln(' Sampling rate: ',SamplesperSec)
End;
TSize:=FileSize(Data)-SizeOf(WaveHeader);
With VOCHeader do Begin
Title:='Creative Voice File';
ID:=$1A;
Offset:=$1A;
Ver1:=$010A;
Ver2:=$1129 { supposed to be complement of($010A)+$1234}
End;
BlockWrite(VOCOut,VOCHeader,SizeOf(VOCHeader));

Repeat
If TSize>65535 then Size:=65535 else Size:=TSize;
GetMem(Info,Size);
BlockRead(Data,Info^,Size);
With Block do Begin
BType:=1;
Length[1]:=Size mod 256;
Length[2]:=Size div 256;
Length[3]:=Size div 65536;
SR:=256-1000000 DIV (WaveHeader.SamplesPerSec*WaveHeader.Channels);
Pack:=0
End;
BlockWrite(VOCOut,Block,Sizeof(Block));
BlockWrite(VOCOut,Info^,Size-2);
FreeMem(Info,Size);
Dec(TSize,Size)
Until TSize=0;
BlockWrite(VOCOut,Endbyte,1);
BlockWrite(VOCOut,Endbyte,1);
BlockWrite(VOCOut,Endbyte,1);
Close(VOCOut)
END.

  3 Responses to “Category : Pascal Source Code
Archive   : W2VSRC.ZIP
Filename : WAV2VOC.PAS

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/