home *** CD-ROM | disk | FTP | other *** search
- unit frmfft;
-
- {===========================================================
- Please note, that the program FFT uses the unit RChart,
- which is not supplied with the FOURIER package. If you
- don't have it, you can download the shareware version from
- one of the following WWW sites:
- http://qspr03.tuwien.ac.at/lo/
- http://www.lohninger.com/
- ===========================================================}
-
- interface
-
- uses
- WinTypes, WinProcs, Messages, SysUtils, Classes, Graphics, Controls,
- Forms, Dialogs, StdCtrls, RChart, Fourier, Buttons;
-
- type
- TForm1 = class(TForm)
- RChart1: TRChart;
- RChart2: TRChart;
- ScrollBar1: TScrollBar;
- SBFreq1: TScrollBar;
- Label1: TLabel;
- FFT1: TFastFourier;
- BButExit: TBitBtn;
- Label2: TLabel;
- CBLogY: TCheckBox;
- CBoxWind: TComboBox;
- Label3: TLabel;
- procedure ScrollBar1Change(Sender: TObject);
- procedure SBFreq1Change(Sender: TObject);
- procedure BButExitClick(Sender: TObject);
- procedure FormActivate(Sender: TObject);
- procedure CBLogYClick(Sender: TObject);
- procedure CBoxWindChange(Sender: TObject);
- private
- procedure StartFFT;
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
-
- (**************************************************************)
- procedure TForm1.StartFFT;
- (**************************************************************)
-
- var
- i : integer;
- y : double;
- pmax : double;
-
- begin
- RChart1.ClearGraf;
- RChart1.DataColor := clBlue;
- RChart1.MoveTo (0,0);
- FFT1.ClearImag;
- for i:=1 to FFT1.SpectrumSize do
- begin
- y := 10*(sin(i*(100-SbFreq1.Position)/100)+sin(i/13)+cos(i/2)+
- 0.06*(random(100-ScrollBar1.Position)-0.5*(100-ScrollBar1.Position)));
- FFT1.RealSpec[i] := y; { real value }
- RChart1.DrawTo (i,y);
- end;
- RChart1.ShowGraf;
-
- FFT1.Transform;
-
- RChart2.ClearGraf;
- RChart2.DataColor := clRed;
- pmax := FFT1.PowerMax;
- if pmax > 0 then
- begin
- RChart2.MoveTo (2,FFT1.powerSpec[2]/pmax);
- for i:=2 to FFT1.SpectrumSize do
- begin
- y := FFT1.powerSpec[i]/pmax;
- RChart2.DrawTo (i,y);
- end;
- end;
- RChart2.ShowGraf;
- end;
-
- (**************************************************************)
- procedure TForm1.ScrollBar1Change(Sender: TObject);
- (**************************************************************)
-
- begin
- STartFFT;
- end;
-
- (**************************************************************)
- procedure TForm1.SBFreq1Change(Sender: TObject);
- (**************************************************************)
-
- begin
- StartFFT;
- end;
-
- (**************************************************************)
- procedure TForm1.BButExitClick(Sender: TObject);
- (**************************************************************)
-
- begin
- close;
- end;
-
- (**************************************************************)
- procedure TForm1.FormActivate(Sender: TObject);
- (**************************************************************)
-
- begin
- CBoxWind.Text := 'None';
- StartFFT;
- end;
-
- (**************************************************************)
- procedure TForm1.CBLogYClick(Sender: TObject);
- (**************************************************************)
-
- begin
- RChart2.LogScaleY := CBLogY.Checked;
- if RChart2.LogScaleY
- then RChart2.DecPlaceY := -1
- else RChart2.DecPlaceY := 2;
- end;
-
- (**************************************************************)
- procedure TForm1.CBoxWindChange(Sender: TObject);
- (**************************************************************)
-
- begin
- if CBoxWind.Text = 'Rectangle' then
- FFT1.WeightingWindow := fwRectangle;
- if CBoxWind.Text = 'Triangle' then
- FFT1.WeightingWindow := fwTriangle;
- if CBoxWind.Text = 'Gaussian' then
- FFT1.WeightingWindow := fwGauss;
- if CBoxWind.Text = 'Hamming' then
- FFT1.WeightingWindow := fwHamming;
- if CBoxWind.Text = 'Blackman' then
- FFT1.WeightingWindow := fwBlackman;
- if CBoxWind.Text = 'cos2' then
- FFT1.WeightingWindow := fwCos2;
- StartFFT;
- end;
-
- end.
-
-
-
-
-