Вот компонент:
[code:1]unit hiBASS_ChlVisibleOcilloRec;
interface
uses Windows,Kol,Share,Debug,BASS;
type
THIBASS_ChlVisibleOcilloRec = class(TDebug)
private
VisBuff:PBitmap;
public
_prop_BackColor:TColor;
_prop_Offset:integer;
_prop_Pen:TColor;
_prop_Mode:byte;
_prop_Res:byte;
_prop_FrameClear:boolean;
_data_BackBitmap:THI_Event;
_data_ChannelHandle:THI_Event;
_data_WindowsHandle:THI_Event;
_event_OnLeValue:THI_Event;
_event_OnRiValue:THI_Event;
procedure _work_doDraw(var _Data:TData; Index:word);
end;
implementation
Type TWaveData = array [ 0..2048] of DWORD;
procedure THIBASS_ChlVisibleOcilloRec._work_doDraw;
var i, YPos,Ri,Le : LongInt; X,Y,R,L : SmallInt; YVal : single;
WaveData:TWaveData;
h:cardinal;
Scr:PBitmap;
begin
VisBuff := ReadBitmap(_Data,_data_WindowsHandle,nil);
//h := ReadInteger(_Data,_data_ChannelHandle,0);
h := RECORDCHAN;
scr := ReadBitmap(_Data,_data_BackBitmap,nil);
if _prop_FrameClear then
begin
VisBuff.Canvas.Pen.Color := _prop_BackColor;
VisBuff.Canvas.Brush.Color := _prop_BackColor;
VisBuff.Canvas.Rectangle(0, 0, VisBuff.Width, VisBuff.Height);
if Scr <> nil then
Scr.Draw(VisBuff.Canvas.Handle,0,0);
end;
if BASS_ChannelIsActive(h) <> BASS_ACTIVE_PLAYING then Exit;
BASS_ChannelGetData(h, @WaveData, 2048);
//BASS_ChannelGetData(h, @FFTData, BASS_DATA_FFT1024 or BASS_DATA_FFT_NOWINDOW);
X := 0;
Y := VisBuff.Height div 2;
Ri := 0;
Le := 0;
VisBuff.Canvas.Pen.Color := _prop_Pen;
R := SmallInt(LOword(WaveData[0]));
L := SmallInt(HIword(WaveData[0]));
YPos := Trunc(((R + L) / (2 * 65535)) * _prop_Offset) ;
VisBuff.Canvas.MoveTo(X , Y + YPos);
for i := 1 to 256*_prop_Res do
begin
R := SmallInt(LOword(WaveData[i]));
Ri := Ri+abs(R);
//begin
// _hi_OnEvent(_event_onRiValue,abs(R));
//end;
L := SmallInt(HIword(WaveData[i]));
Le := Le+abs(L);
//begin
//_hi_OnEvent(_event_onLeValue,abs(L));
//end;
YPos := Trunc(((R + L) / (2 * 65535)) * _prop_Offset) ;
case _prop_Mode of
0: VisBuff.Canvas.lineto(X + i*5, Y + YPos);
1:
begin
VisBuff.Canvas.MoveTo(X + i, Y);
VisBuff.Canvas.lineto(X + i, Y + YPos);
end;
2 : VisBuff.Pixels[X + i, Y + YPos] := _prop_Pen;
end;
end;
begin
_hi_OnEvent(_event_onRiValue,Ri/100000);
_hi_OnEvent(_event_onLeValue,Le/100000);
end;
end;
end.[/code:1]
Ответов: 209
Рейтинг: 3
|
|||
карма: 0 |
|