WriteHeader in 'WriteHeader.pas',
spWav in 'spWav.pas';
-function cut(fpIn, fpOut: TFileStream; sp: SpParam): integer;
-var
- Buffer: array of ShortInt;
- size: integer;
-begin
- result := 0;
- size := (sp.endpos - sp.startpos + 1) * sp.channels * sp.samplePerSec *
- sp.bitsPerSample div 8;
- SetLength(Buffer, size);
- try
- fpIn.ReadBuffer(Pointer(Buffer)^, size);
- fpOut.WriteBuffer(Pointer(Buffer)^, size);
- Finalize(Buffer);
- except
- result := -1;
- end;
-end;
-
function checkRange(var sp: SpParam): integer;
begin
result := 0;
end;
function wavDataWrite(fpIn, fpOut: TFileStream; const sp: SpParam): integer;
+var
+ Buffer: array of ShortInt;
begin
+ result := 0;
fpIn.Position := sp.posOfData;
- result := cut(fpIn, fpOut, sp);
+ try
+ GetMem(Pointer(Buffer), sp.sizeOfData);
+ except
+ Writeln('\83\81\83\82\83\8a\82ª\8am\95Û\82Å\82«\82Ü\82¹\82ñ');
+ result := -1;
+ end;
+ if fpIn.Read(Pointer(Buffer)^, sp.sizeOfData) = -1 then
+ begin
+ Writeln('\93Ç\82Ý\8d\9e\82Ý\82É\8e¸\94s');
+ result := -1;
+ end;
+ if fpOut.Write(Pointer(Buffer)^, sp.sizeOfData) = -1 then
+ begin
+ Writeln('\8f\91\82«\8d\9e\82Ý\82É\8e¸\94s');
+ result := -1;
+ end;
+ FreeMem(Pointer(Buffer));
end;
function wavWrite(inFile, outFile: PChar; var sp: SpParam): integer;
result := 0;
end;
+procedure usage;
+begin
+ Writeln('\88ø\90\94<\93ü\97Í\83t\83@\83C\83\8b\96¼><\8fo\97Í\83t\83@\83C\83\8b\96¼><\91¬\93x\94{\97¦>');
+end;
+
var
sp: SpParam;
begin
try
{ TODO -oUser -cConsole \83\81\83C\83\93 : \82±\82±\82É\83R\81[\83h\82ð\8bL\8fq\82µ\82Ä\82\82¾\82³\82¢ }
- sp.startpos := StrToInt(ParamStr(3));
- sp.endpos := StrToInt(ParamStr(4));
- if sp.startpos > sp.endpos then
+ if ParamCount <> 3 then
begin
- Writeln('\8aJ\8en\95b\82Í\8fI\97¹\95b\82ð\92´\82¦\82Ä\82Í\82È\82è\82Ü\82¹\82ñ');
+ usage;
Exit;
end;
if wavHdrRead(PChar(ParamStr(1)), sp) = -1 then
Exit;
+ sp.samplePerSec := StrToInt(ParamStr(3)) * sp.samplePerSec;
if wavWrite(PChar(ParamStr(1)), PChar(ParamStr(2)), sp) = -1 then
Exit;
Writeln('\8a®\97¹');