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));
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));
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, bytesPerSingleCh, sampRate,
85 raise EWriteError.Create('
\83w
\83b
\83_
\82ð
\8f\91\82«
\8d\9e\82ß
\82Ü
\82¹
\82ñ');
86 if wavDataWrite(fpIn, fpOut, posOfData, sizeOfData, bytesPerSingleCh) = -1
88 raise EWriteError.Create('
\83G
\83\89\81[
\94
\90¶');
91 Writeln(inFile, '
\82ð
\83I
\81[
\83v
\83\93\82Å
\82«
\82Ü
\82¹
\82ñ');
108 posOfData, sizeOfData: LongInt;
112 { TODO -oUser -cConsole
\83\81\83C
\83\93 :
\82±
\82±
\82É
\83R
\81[
\83h
\82ð
\8bL
\8fq
\82µ
\82Ä
\82
\82¾
\82³
\82¢ }
113 wavHdrRead(PChar(ParamStr(1)), sampRate, sampBits, posOfData, sizeOfData);
114 wavWrite(PChar(ParamStr(1)), PChar(ParamStr(2)), sampRate, sampBits,
115 posOfData, sizeOfData);
119 Writeln(E.ClassName, ': ', E.Message);