10 WriteHeader in 'WriteHeader.pas';
12 function effect8BitWav(fpIn, fpOut: TFileStream; sizeOfData: Word): integer;
16 c: array [0 .. 1] of Byte;
20 s := sizeOfData / SizeOf(c);
24 fpIn.ReadBuffer(c, SizeOf(c));
26 fpOut.WriteBuffer(c, SizeOf(c));
31 Writeln(c[0], ',', c[1]);
36 function effect16BitWav(fpIn, fpOut: TFileStream; sizeOfData: integer)
41 c: array [0 .. 1] of ShortInt;
45 s := sizeOfData / SizeOf(c);
49 fpIn.ReadBuffer(c, SizeOf(c));
51 fpOut.WriteBuffer(c, SizeOf(c));
56 Writeln(c[0], ',', c[1]);
61 function wavDataWrite(fpIn, fpOut: TFileStream; posOfData, sizeOfData: LongInt;
62 bytesPerSingleCh: SmallInt): integer;
64 fpIn.Seek(posOfData, soFromCurrent);
65 if bytesPerSingleCh = 1 then
66 result := effect8BitWav(fpIn, fpOut, sizeOfData)
68 result := effect16BitWav(fpIn, fpOut, sizeOfData);
71 function wavWrite(inFile, outFile: PChar; sampRate: LongWord; sampBits: Word;
72 posOfData, sizeOfData: integer): integer;
74 bytesPerSingleCh: Word;
75 fpIn, fpOut: TFileStream;
78 if FileExists(inFile) = true then
79 fpIn := TFileStream.Create(inFile, fmOpenRead)
83 Writeln(inFile, '
\82ð
\83I
\81[
\83v
\83\93\82Å
\82«
\82Ü
\82¹
\82ñ');
86 fpOut := TFileStream.Create(outFile, fmCreate);
87 bytesPerSingleCh := sampBits div 8;
88 if waveHeaderWrite(fpOut, sizeOfData, bytesPerSingleCh, sampRate, sampBits)
92 Writeln('
\83w
\83b
\83_
\82ð
\8f\91\82«
\8d\9e\82ß
\82Ü
\82¹
\82ñ');
95 if wavDataWrite(fpIn, fpOut, posOfData, sizeOfData, bytesPerSingleCh) = -1
99 Write('
\83G
\83\89\81[
\94
\90¶');
110 sampRate, sampBits: SmallInt;
111 posOfData, sizeOfData: LongWord;
115 { TODO -oUser -cConsole
\83\81\83C
\83\93 :
\82±
\82±
\82É
\83R
\81[
\83h
\82ð
\8bL
\8fq
\82µ
\82Ä
\82
\82¾
\82³
\82¢ }
116 wavHdrRead(PChar(ParamStr(1)), sampRate, sampBits, posOfData, sizeOfData);
117 wavWrite(PChar(ParamStr(1)), PChar(ParamStr(2)), sampRate, sampBits,
118 posOfData, sizeOfData);
122 Writeln(E.ClassName, ': ', E.Message);