C
czly
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TMainfrm.LinkWave(waveFiles: string);
var
Files: TStringList;
n1, n2, n3, n, WaveLen: Integer;
SoureFile: TFileStream;
a1, a2, a3: byte;
begin
Files := TStringList.Create;
Files.CommaText := WaveFiles;
WaveFile := TMemoryStream.Create;
try
SoureFile := TFileStream.Create(Files.Strings[0], fmOpenRead);
//打开其中一个声音文件
WaveFile.CopyFrom(SoureFile, 59);
//读取声音文件头
WaveLen := 0;
//记录声音长度
WaveFile.Size := 0;
for n := 0 to Files.Count - 1do
begin
if Assigned(SoureFile) then
begin
SoureFile.Free;
SoureFile := nil;
end;
try
SoureFile := TFileStream.Create(Files.Strings[n], fmOpenRead);
SoureFile.Position := 54;
SoureFile.read(a1, 1);
SoureFile.read(a2, 1);
SoureFile.read(a3, 1);
WaveLen := WaveLen + (ord(a3) * 65536) + (ord(a2) * 256) + ord(a1);
SoureFile.Position := 59;
WaveFile.CopyFrom(SoureFile, SoureFile.Size - 60);
except
// on E: Exceptiondo
// WriteLog(e.Message);
end;
end;
WaveFile.Position := 4;
n1 := (WaveFile.Size - 8) div 65536;
n2 := (WaveFile.Size - 8 - n1 * 65536) div 256;
n3 := WaveFile.Size - 8 - n1 - n2 * 256;
WaveFile.WriteBuffer(n3, 1);
WaveFile.WriteBuffer(n2, 1);
WaveFile.WriteBuffer(n1, 1);
n1 := WaveLen div 65536;
n2 := (WaveLen - n1 * 65536) div 256;
n3 := WaveLen - n1 - n2 * 256;
WaveFile.Position := 54;
WaveFile.WriteBuffer(n3, 1);
WaveFile.WriteBuffer(n2, 1);
WaveFile.WriteBuffer(n1, 1);
WaveFile.Position := 46;
WaveFile.WriteBuffer(n3, 1);
WaveFile.WriteBuffer(n2, 1);
WaveFile.WriteBuffer(n1, 1);
//PlaySound(WaveFile.Memory, 0, SND_ASYNC + SND_MEMORY);
except
//on E: Exceptiondo
// WriteLog(e.Message);
end;
freeAndNil(Files);
// freeAndNil(WaveFile);
if Assigned(SoureFile) then
freeAndNil(SoureFile);
end;
var
Files: TStringList;
n1, n2, n3, n, WaveLen: Integer;
SoureFile: TFileStream;
a1, a2, a3: byte;
begin
Files := TStringList.Create;
Files.CommaText := WaveFiles;
WaveFile := TMemoryStream.Create;
try
SoureFile := TFileStream.Create(Files.Strings[0], fmOpenRead);
//打开其中一个声音文件
WaveFile.CopyFrom(SoureFile, 59);
//读取声音文件头
WaveLen := 0;
//记录声音长度
WaveFile.Size := 0;
for n := 0 to Files.Count - 1do
begin
if Assigned(SoureFile) then
begin
SoureFile.Free;
SoureFile := nil;
end;
try
SoureFile := TFileStream.Create(Files.Strings[n], fmOpenRead);
SoureFile.Position := 54;
SoureFile.read(a1, 1);
SoureFile.read(a2, 1);
SoureFile.read(a3, 1);
WaveLen := WaveLen + (ord(a3) * 65536) + (ord(a2) * 256) + ord(a1);
SoureFile.Position := 59;
WaveFile.CopyFrom(SoureFile, SoureFile.Size - 60);
except
// on E: Exceptiondo
// WriteLog(e.Message);
end;
end;
WaveFile.Position := 4;
n1 := (WaveFile.Size - 8) div 65536;
n2 := (WaveFile.Size - 8 - n1 * 65536) div 256;
n3 := WaveFile.Size - 8 - n1 - n2 * 256;
WaveFile.WriteBuffer(n3, 1);
WaveFile.WriteBuffer(n2, 1);
WaveFile.WriteBuffer(n1, 1);
n1 := WaveLen div 65536;
n2 := (WaveLen - n1 * 65536) div 256;
n3 := WaveLen - n1 - n2 * 256;
WaveFile.Position := 54;
WaveFile.WriteBuffer(n3, 1);
WaveFile.WriteBuffer(n2, 1);
WaveFile.WriteBuffer(n1, 1);
WaveFile.Position := 46;
WaveFile.WriteBuffer(n3, 1);
WaveFile.WriteBuffer(n2, 1);
WaveFile.WriteBuffer(n1, 1);
//PlaySound(WaveFile.Memory, 0, SND_ASYNC + SND_MEMORY);
except
//on E: Exceptiondo
// WriteLog(e.Message);
end;
freeAndNil(Files);
// freeAndNil(WaveFile);
if Assigned(SoureFile) then
freeAndNil(SoureFile);
end;