10 WriteHeader in 'WriteHeader.pas';
12 function effect8BitWav(fpIn, fpOut: TFileStream; sizeOfData: LongInt): integer;
16 c: array [0 .. 1] of Byte;
21 s := sizeOfData / SizeOf(@c);
25 fpIn.ReadBuffer(c, SizeOf(@c));
26 j := (c[0] + c[1]) div 2;
28 fpOut.WriteBuffer(mix, SizeOf(@mix));
37 function effect16BitWav(fpIn, fpOut: TFileStream; sizeOfData: LongInt): integer;
41 c: array [0 .. 1] of ShortInt;
46 s := sizeOfData / SizeOf(@c);
50 fpIn.ReadBuffer(c, SizeOf(@c));
51 j := (c[0] + c[1]) div 2;
53 fpOut.WriteBuffer(mix, SizeOf(@mix));
62 function wavDataWrite(fpIn, fpOut: TFileStream; posOfData, sizeOfData: LongInt;
63 bytesPerSingleCh: SmallInt): integer;
65 fpIn.Position := posOfData;
66 fpOut.Position := posOfData;
67 if bytesPerSingleCh = 1 then
68 result := effect8BitWav(fpIn, fpOut, sizeOfData)
70 result := effect16BitWav(fpIn, fpOut, sizeOfData);
73 function wavWrite(inFile, outFile: PChar; sampRate: LongWord; sampBits: Byte;
74 posOfData, sizeOfData: LongInt): integer;
76 bytesPerSingleCh: Word;
77 fpIn, fpOut: TFileStream;
80 fpIn := TFileStream.Create(inFile, fmOpenRead);
81 fpOut := TFileStream.Create(outFile, fmCreate);
82 bytesPerSingleCh := sampBits div 8;
83 if waveHeaderWrite(fpOut, sizeOfData div 2, WAV_MONAURAL, sampRate, sampBits) <> 44 then
84 raise EWriteError.Create('
\83w
\83b
\83_
\82ð
\8f\91\82«
\8d\9e\82ß
\82Ü
\82¹
\82ñ');
85 if wavDataWrite(fpIn, fpOut, posOfData, sizeOfData, bytesPerSingleCh) = -1
87 raise EWriteError.Create('
\83G
\83\89\81[
\94
\90¶');
90 Writeln(inFile, '
\82ð
\83I
\81[
\83v
\83\93\82Å
\82«
\82Ü
\82¹
\82ñ');
107 posOfData, sizeOfData: LongInt;
111 { TODO -oUser -cConsole
\83\81\83C
\83\93 :
\82±
\82±
\82É
\83R
\81[
\83h
\82ð
\8bL
\8fq
\82µ
\82Ä
\82
\82¾
\82³
\82¢ }
112 wavHdrRead(PChar(ParamStr(1)), sampRate, sampBits, posOfData, sizeOfData);
113 wavWrite(PChar(ParamStr(1)), PChar(ParamStr(2)), sampRate, sampBits,
114 posOfData, sizeOfData);
118 Writeln(E.ClassName, ': ', E.Message);