29-01-2015, 11:44 AM
لا يزال الكود ناقص
تحويل الكود الموجود
تحويل الكود الموجود
كود :
procedure ScanPeaks(p:Pointer);cdecl;
var decoder,pos,a,size:LongWord;
spp,todo:Single;
info:Pointer;
peak,level:array[0..1]of Single;
begin
decoder:=LongWord(p);
pos:=0;
spp:=BASS_ChannelBytes2Seconds(decoder,bpp); // seconds per pixel
while (killscan = 0) do
begin
if (spp>1)then // more than 1 second per pixel, break it down...
begin
todo:=spp;
peak[0]:=0;
peak[1]:=peak[0];
while (todo>0)do
begin
if todo<1 then
step := todo
else
step := 1;
BASS_ChannelGetLevelEx(decoder,level,step,BASS_LEVEL_STEREO); // scan peaks
if (peak[0]<level[0])then peak[0]:=level[0];
if (peak[1]<level[1])then peak[1]:=level[1];
Dec(todo,step);
end;
end
else
BASS_ChannelGetLevelEx(decoder,peak,spp,BASS_LEVEL_STEREO); // scan peaks
a := 0;
while a<peak[0]*(HEIGHT div 2) do
begin
wavebuf[(HEIGHT div 2-1-a)*WIDTH+pos]:=1+a;
Inc(a);
end;
a := 0;
while a<peak[1]*(HEIGHT div 2) do
begin
wavebuf[(HEIGHT div 2+1+a)*WIDTH+pos]=1+a; // draw right peak
Inc(a);
end;
Inc(pos);
if (pos>=WIDTH)then break; // reached end of display
if (BASS_ChannelIsActive(decoder) = 0)then break; // reached end of channel
end;
if (killscan = 0) then
begin
BASS_ChannelSetPosition(decoder,(QWORD)-1,BASS_POS_BYTE or BASS_POS_SCAN); // build seek table (scan to end)
size:=BASS_ChannelGetAttributeEx(decoder,BASS_ATTRIB_SCANINFO,0,0); // get seek table size
if (size)then // got it
begin
info := GetMemory(size); // allocate a buffer
BASS_ChannelGetAttributeEx(decoder,BASS_ATTRIB_SCANINFO,info,size); // get the seek table
BASS_ChannelSetAttributeEx(chan,BASS_ATTRIB_SCANINFO,info,size); // apply it to the playback channel
FreeMemory(info);
end;
end;
BASS_StreamFree(decoder); // free the decoder
scanthread:=0;
end;
