procedure TTrack.DrawWave;
type OneBit = array[0..0] of Shortint;
OneBitArray =^OneBit;
TwoBit = array[0..0] of Smallint;
TwoBitArray =^TwoBit;
var ByteRead : integer;
Wave16 : TwoBitArray;
Wave8 : OneBitArray;
Up,Down,Oldy,Lever : Integer;
k : real;
procedure Draw8BitWav(X,Y,W,H,Count,pos,Add:Integer);
var i,j,Bit8 : integer; // 区域 总量 偏移 累加
begin
k:=H/255;
Lever:=Y+H;
Getmem(Wave8,Count);
OldY:=y+H div 2;
for i:=X to X+W-1 do
begin
ByteRead:=FileStream.Read(Wave8^,Count);
if ByteRead=0 then break;
j:=Pos;
//************************
Up:=0 ;Down:=256;
Lever:=Y+H;
While j< count do
begin
if Wave8[j]<0 then Bit8:=256+Wave8[j]
else Bit8:=Wave8[j];
if Bit8>Up then
Up:=Bit8;
if Bit8<Down then
Down:=Bit8;
j:=j+add;
end;
up:=round(up*k);
Down:=round(Down*k);
if Up=Down then Down:=Down-1;
Up:=Lever-Up;
Down:=Lever-Down;
ViewImg.Canvas.MoveTo(i,Up);
ViewImg.Canvas.LineTo(i,Down);
ViewImg.Canvas.MoveTo(i,OldY);
ViewImg.Canvas.LineTo(i,Up);
if Up-1=Down then OldY:=Up else
OldY:=(Up+Down)div 2;
if Byteread<Count then break;
end;
Line(ViewImg.Canvas,x,Y+H div 2,x+w,Y+H div 2,0,1,clred);
Freemem(Wave8,Count);
end;
procedure Draw16BitWav(X,Y,W,H,Count,pos,Add:Integer);
var i,j,Bit16: integer; // 区域 总量 偏移 累加
begin
k:=H/65535;
Lever:=Y+H;
OldY:=Y+H div 2;
Getmem(Wave16,Count);
for i:=X to X+W-1 do
begin
ByteRead:=FileStream.Read(Wave16^,Count);
if ByteRead=0 then break;
j:=pos;
//***************
Up:=0 ;Down:=65535;
While j< count div 2 do
begin
Bit16:=Wave16[j]+32767;
if Bit16>Up then
Up:=Bit16;
if Bit16<Down then
Down:=Bit16;
j:=j+add;
end;
up:=round(up*k);
Down:=round(Down*k);
if Up=Down then Down:=Down-1;
Up:=Lever-Up;
Down:=Lever-Down;
ViewImg.Canvas.MoveTo(i,Up);
ViewImg.Canvas.LineTo(i,Down);
ViewImg.Canvas.MoveTo(i,OldY);
ViewImg.Canvas.LineTo(i,Up);
if Up-1=Down then OldY:=Up else
OldY:=(Up+Down)div 2;
if ByteRead<Count then break;
end;
Line(ViewImg.Canvas,x,Lever-h div 2,x+w,Lever-h div 2,0,1,clred);
Freemem(Wave16,Count);
end;
begin
if Not IsLoad then Exit;Fill(ViewImg.Canvas,Wx,Wy,Wx+Ww,Wy+Wh,$0);
ViewImg.Canvas.Pen.Color:=cllime;if FileStream.Size>=VBeg then
begin
FileStream.Position:=VBeg;
case TypeFmt of
1 : begin ////////////// 111111111111
Draw8BitWav(WX,WY,WW,WH,Zoom,0,1);
end;
2 : begin ////////////// 222222222222
Draw16BitWav(WX,WY,WW,WH,Zoom*2,0,1);
end;
3 : begin ////////////// 333333333333
Draw8BitWav(WX,WY,WW,WH div 2,Zoom*2,0,2);
FileStream.Position:=VBeg;
ViewImg.Canvas.Pen.Color:=cllime;
Draw8BitWav(WX,WY+WH div 2,WW,WH div 2,Zoom*2,1,2);
end;
4 : begin ////////////// 444444444444
Draw16BitWav(WX,WY,WW,WH div 2,Zoom*4,0,2);
FileStream.Position:=VBeg;
ViewImg.Canvas.Pen.Color:=cllime;
Draw16BitWav(WX,WY+WH div 2,WW,WH div 2,Zoom*4,1,2);
end;
end;
end;
Setselect(SeleBeg,SeleEnd);
BitBlt(Canvas.handle,Wx,Wy,Ww,Wh+RulerH,ViewImg.canvas.handle,Wx,Wy,SRCCOPY);
end;
type OneBit = array[0..0] of Shortint;
OneBitArray =^OneBit;
TwoBit = array[0..0] of Smallint;
TwoBitArray =^TwoBit;
var ByteRead : integer;
Wave16 : TwoBitArray;
Wave8 : OneBitArray;
Up,Down,Oldy,Lever : Integer;
k : real;
procedure Draw8BitWav(X,Y,W,H,Count,pos,Add:Integer);
var i,j,Bit8 : integer; // 区域 总量 偏移 累加
begin
k:=H/255;
Lever:=Y+H;
Getmem(Wave8,Count);
OldY:=y+H div 2;
for i:=X to X+W-1 do
begin
ByteRead:=FileStream.Read(Wave8^,Count);
if ByteRead=0 then break;
j:=Pos;
//************************
Up:=0 ;Down:=256;
Lever:=Y+H;
While j< count do
begin
if Wave8[j]<0 then Bit8:=256+Wave8[j]
else Bit8:=Wave8[j];
if Bit8>Up then
Up:=Bit8;
if Bit8<Down then
Down:=Bit8;
j:=j+add;
end;
up:=round(up*k);
Down:=round(Down*k);
if Up=Down then Down:=Down-1;
Up:=Lever-Up;
Down:=Lever-Down;
ViewImg.Canvas.MoveTo(i,Up);
ViewImg.Canvas.LineTo(i,Down);
ViewImg.Canvas.MoveTo(i,OldY);
ViewImg.Canvas.LineTo(i,Up);
if Up-1=Down then OldY:=Up else
OldY:=(Up+Down)div 2;
if Byteread<Count then break;
end;
Line(ViewImg.Canvas,x,Y+H div 2,x+w,Y+H div 2,0,1,clred);
Freemem(Wave8,Count);
end;
procedure Draw16BitWav(X,Y,W,H,Count,pos,Add:Integer);
var i,j,Bit16: integer; // 区域 总量 偏移 累加
begin
k:=H/65535;
Lever:=Y+H;
OldY:=Y+H div 2;
Getmem(Wave16,Count);
for i:=X to X+W-1 do
begin
ByteRead:=FileStream.Read(Wave16^,Count);
if ByteRead=0 then break;
j:=pos;
//***************
Up:=0 ;Down:=65535;
While j< count div 2 do
begin
Bit16:=Wave16[j]+32767;
if Bit16>Up then
Up:=Bit16;
if Bit16<Down then
Down:=Bit16;
j:=j+add;
end;
up:=round(up*k);
Down:=round(Down*k);
if Up=Down then Down:=Down-1;
Up:=Lever-Up;
Down:=Lever-Down;
ViewImg.Canvas.MoveTo(i,Up);
ViewImg.Canvas.LineTo(i,Down);
ViewImg.Canvas.MoveTo(i,OldY);
ViewImg.Canvas.LineTo(i,Up);
if Up-1=Down then OldY:=Up else
OldY:=(Up+Down)div 2;
if ByteRead<Count then break;
end;
Line(ViewImg.Canvas,x,Lever-h div 2,x+w,Lever-h div 2,0,1,clred);
Freemem(Wave16,Count);
end;
begin
if Not IsLoad then Exit;Fill(ViewImg.Canvas,Wx,Wy,Wx+Ww,Wy+Wh,$0);
ViewImg.Canvas.Pen.Color:=cllime;if FileStream.Size>=VBeg then
begin
FileStream.Position:=VBeg;
case TypeFmt of
1 : begin ////////////// 111111111111
Draw8BitWav(WX,WY,WW,WH,Zoom,0,1);
end;
2 : begin ////////////// 222222222222
Draw16BitWav(WX,WY,WW,WH,Zoom*2,0,1);
end;
3 : begin ////////////// 333333333333
Draw8BitWav(WX,WY,WW,WH div 2,Zoom*2,0,2);
FileStream.Position:=VBeg;
ViewImg.Canvas.Pen.Color:=cllime;
Draw8BitWav(WX,WY+WH div 2,WW,WH div 2,Zoom*2,1,2);
end;
4 : begin ////////////// 444444444444
Draw16BitWav(WX,WY,WW,WH div 2,Zoom*4,0,2);
FileStream.Position:=VBeg;
ViewImg.Canvas.Pen.Color:=cllime;
Draw16BitWav(WX,WY+WH div 2,WW,WH div 2,Zoom*4,1,2);
end;
end;
end;
Setselect(SeleBeg,SeleEnd);
BitBlt(Canvas.handle,Wx,Wy,Ww,Wh+RulerH,ViewImg.canvas.handle,Wx,Wy,SRCCOPY);
end;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货