主题:关于人声消除,这里有源代码
这个好象是天津中学的一个同学写的,希望水能给解释以下为什么。
(纯pascal哦)
Program vocal_remover;
var fp1, fp2: text;
inf, ouf: string;
hd, sz: string[4];
ch: char; i: longint;
j: integer; a1, a2, a1n, a2n: longint;
tmp, fsz, riffsz, chucksz, datasz, sprt, dwavbs, ftsz: longint;
wfmttag, channel, wblkagn, bits: word;
begin
writeln('Vocal Remover 0.01 By zzc');
if ParamCount>1 then begin
inf:=ParamStr(1); ouf:=ParamStr(2);
end;
if ParamCount<2 then begin
write('Input Filename: '); readln(inf);
write('Output Filename: '); readln(ouf);
end;
if (inf='') or (ouf='') then begin
if inf='' then writeln('Error: No input file!');
if ouf='' then writeln('Error: No output file!');
exit;
end;
assign(fp1,inf); assign(fp2,ouf);
{$I-} reset(fp1);
{$I+} if ioresult<>0 then begin
writeln('Cannot open ',inf,'!'); exit; end;
{$I-} rewrite(fp2);
{$I+} if ioresult<>0 then begin
writeln('Cannot write ',inf,'!'); close(fp1); exit; end;
writeln('Start checking files...');
riffsz:=0;
for i:=1 to 4 do begin
read(fp1,ch); hd:=hd+ch; end;
if hd<>'RIFF' then begin
writeln('This is not a standard RIFF file!');
close(fp1); close(fp2); erase(fp2); exit;
end;
for i:=1 to 4 do
read(fp1,sz[5-i]);
for i:=1 to 4 do riffsz:=(riffsz*256)+ord(sz[i]);
hd:=''; for i:=1 to 4 do begin
read(fp1,ch); hd:=hd+ch; end;
If hd<>'WAVE' then begin
writeln('This is not a wave file!');
close(fp1); close(fp2); erase(fp2); exit; end;
hd:=''; for i:=1 to 4 do begin
read(fp1,ch); hd:=hd+ch; end;
If hd<>'fmt ' then begin
writeln('This is a compressed wave file!');
close(fp1); close(fp2); erase(fp2); exit; end;
for i:=1 to 4 do
read(fp1,sz[5-i]);
for i:=1 to 4 do chucksz:=(chucksz*256)+ord(sz[i]);
for i:=1 to 2 do begin
read(fp1,ch); sz[i]:=ch;
end;
wfmttag:=ord(sz[2])*256+ord(sz[1]);
if wfmttag<>1 then begin
writeln('This is not a Microsoft PCM file!');
close(fp1); close(fp2); erase(fp2); exit; end;
for i:=1 to 2 do begin
read(fp1,ch); sz[i]:=ch;
end;
channel:=ord(sz[2])*256+ord(sz[1]);
if channel<>2 then begin
writeln('This program can only process stereo wave files!');
close(fp1); close(fp2); erase(fp2); exit;
end;
//note
for i:=1 to 4 do
read(fp1,sz[5-i]);
for i:=1 to 4 do sprt:=(sprt*256)+ord(sz[i]);
for i:=1 to 4 do
read(fp1,sz[5-i]);
for i:=1 to 4 do dwavbs:=(dwavbs*256)+ord(sz[i]);
for i:=1 to 2 do begin
read(fp1,ch); sz[i]:=ch;
end;
wblkagn:=ord(sz[2])*256+ord(sz[1]);
for i:=1 to 2 do begin
read(fp1,ch); sz[i]:=ch;
end;
bits:=ord(sz[2])*256+ord(sz[1]);
if (bits<>16) and (bits<>8) then begin
writeln('This program can only process 8 bit or 16 bit wave files!');
close(fp1); close(fp2); erase(fp2); exit;
end;
for i:=1 to chucksz-16 do begin
read(fp1,ch); end; hd:='';
for i:=1 to 4 do begin
read(fp1,ch); hd:=hd+ch; end;
if hd<>'data' then begin
for i:=1 to 4 do
read(fp1,sz[5-i]);
for i:=1 to 4 do ftsz:=(ftsz*256)+ord(sz[i]);
for i:=1 to ftsz do
begin read(fp1,ch); end;
hd:=''; for i:=1 to 4 do begin
read(fp1,ch); hd:=hd+ch; end;
end;
if hd<>'data' then begin
writeln('Error: No data struct!');
close(fp1); close(fp2); erase(fp2); exit; end;
for i:=1 to 4 do
read(fp1,sz[5-i]);
for i:=1 to 4 do datasz:=(datasz*256)+ord(sz[i]);
(纯pascal哦)
Program vocal_remover;
var fp1, fp2: text;
inf, ouf: string;
hd, sz: string[4];
ch: char; i: longint;
j: integer; a1, a2, a1n, a2n: longint;
tmp, fsz, riffsz, chucksz, datasz, sprt, dwavbs, ftsz: longint;
wfmttag, channel, wblkagn, bits: word;
begin
writeln('Vocal Remover 0.01 By zzc');
if ParamCount>1 then begin
inf:=ParamStr(1); ouf:=ParamStr(2);
end;
if ParamCount<2 then begin
write('Input Filename: '); readln(inf);
write('Output Filename: '); readln(ouf);
end;
if (inf='') or (ouf='') then begin
if inf='' then writeln('Error: No input file!');
if ouf='' then writeln('Error: No output file!');
exit;
end;
assign(fp1,inf); assign(fp2,ouf);
{$I-} reset(fp1);
{$I+} if ioresult<>0 then begin
writeln('Cannot open ',inf,'!'); exit; end;
{$I-} rewrite(fp2);
{$I+} if ioresult<>0 then begin
writeln('Cannot write ',inf,'!'); close(fp1); exit; end;
writeln('Start checking files...');
riffsz:=0;
for i:=1 to 4 do begin
read(fp1,ch); hd:=hd+ch; end;
if hd<>'RIFF' then begin
writeln('This is not a standard RIFF file!');
close(fp1); close(fp2); erase(fp2); exit;
end;
for i:=1 to 4 do
read(fp1,sz[5-i]);
for i:=1 to 4 do riffsz:=(riffsz*256)+ord(sz[i]);
hd:=''; for i:=1 to 4 do begin
read(fp1,ch); hd:=hd+ch; end;
If hd<>'WAVE' then begin
writeln('This is not a wave file!');
close(fp1); close(fp2); erase(fp2); exit; end;
hd:=''; for i:=1 to 4 do begin
read(fp1,ch); hd:=hd+ch; end;
If hd<>'fmt ' then begin
writeln('This is a compressed wave file!');
close(fp1); close(fp2); erase(fp2); exit; end;
for i:=1 to 4 do
read(fp1,sz[5-i]);
for i:=1 to 4 do chucksz:=(chucksz*256)+ord(sz[i]);
for i:=1 to 2 do begin
read(fp1,ch); sz[i]:=ch;
end;
wfmttag:=ord(sz[2])*256+ord(sz[1]);
if wfmttag<>1 then begin
writeln('This is not a Microsoft PCM file!');
close(fp1); close(fp2); erase(fp2); exit; end;
for i:=1 to 2 do begin
read(fp1,ch); sz[i]:=ch;
end;
channel:=ord(sz[2])*256+ord(sz[1]);
if channel<>2 then begin
writeln('This program can only process stereo wave files!');
close(fp1); close(fp2); erase(fp2); exit;
end;
//note
for i:=1 to 4 do
read(fp1,sz[5-i]);
for i:=1 to 4 do sprt:=(sprt*256)+ord(sz[i]);
for i:=1 to 4 do
read(fp1,sz[5-i]);
for i:=1 to 4 do dwavbs:=(dwavbs*256)+ord(sz[i]);
for i:=1 to 2 do begin
read(fp1,ch); sz[i]:=ch;
end;
wblkagn:=ord(sz[2])*256+ord(sz[1]);
for i:=1 to 2 do begin
read(fp1,ch); sz[i]:=ch;
end;
bits:=ord(sz[2])*256+ord(sz[1]);
if (bits<>16) and (bits<>8) then begin
writeln('This program can only process 8 bit or 16 bit wave files!');
close(fp1); close(fp2); erase(fp2); exit;
end;
for i:=1 to chucksz-16 do begin
read(fp1,ch); end; hd:='';
for i:=1 to 4 do begin
read(fp1,ch); hd:=hd+ch; end;
if hd<>'data' then begin
for i:=1 to 4 do
read(fp1,sz[5-i]);
for i:=1 to 4 do ftsz:=(ftsz*256)+ord(sz[i]);
for i:=1 to ftsz do
begin read(fp1,ch); end;
hd:=''; for i:=1 to 4 do begin
read(fp1,ch); hd:=hd+ch; end;
end;
if hd<>'data' then begin
writeln('Error: No data struct!');
close(fp1); close(fp2); erase(fp2); exit; end;
for i:=1 to 4 do
read(fp1,sz[5-i]);
for i:=1 to 4 do datasz:=(datasz*256)+ord(sz[i]);