BASS - Wykres natężenia dźwięku
type TFFT = array [0..512] of DWORD; type TGraph = class(TObject) Channel : DWORD; XPos, YPos : integer; Buffer : TFFT; Paint : TImage; Size : integer; Timer : TTimer; constructor Create(Canv : TImage; Ps : TPenStyle; Pc : TColor; Psz, Gw : integer); procedure Draw(Sender: TObject); procedure Start(Chan : DWORD); procedure Stop(); end; //............................................. constructor TGraph.Create(Canv : TImage; Ps : TPenStyle; Pc : TColor; Psz, Gw : integer); begin Paint := Canv; with Paint.Canvas.Pen do begin Style := Ps; Color := Pc; Width := Psz; end; Size := Gw; Timer := TTimer.Create(nil); Timer.Enabled := false; Timer.OnTimer := Draw; Timer.Interval := 33; end; procedure TGraph.Draw(Sender: TObject); var i, n : integer; begin if (BASS_ChannelIsActive(Channel) > 0) then begin Application.ProcessMessages; YPos := BASS_ChannelGetLevel(Channel) div 3000000; for i := 0 to size-1 do for n := 0 to Paint.Height do Paint.Canvas.Pixels[XPos+i, n] := clWhite; Paint.Canvas.LineTo(XPos, Paint.Height - YPos); if XPos >= Paint.Width then begin XPos := 0; Paint.Canvas.MoveTo(0,0); end else XPos := XPos + size; end; end; procedure TGraph.Start(Chan : DWORD); begin Timer.Enabled := true; Channel := Chan; end; procedure TGraph.Stop(); begin Timer.Enabled := false; end;
Użycie:
var Gr : TGraph; //----- Gr := TGraph.Create(Image1, psSolid, clBlack, 1, 5); //BASS_StreamCreateFile(...) //BASS_ChannelPlay(...) Gr.Start(Channel); //aby zakonczyc rysowanie: Gr.Stop;
być może coś robie źle ale wywala mi że nie zadeklarowano BASS_ChannelGetLevel więc nie wiem czy brakuje jakiegoś modułu czy to coś innego:/