-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdftThread.pas
More file actions
78 lines (65 loc) · 1.94 KB
/
dftThread.pas
File metadata and controls
78 lines (65 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
unit dftThread;
{$mode ObjFPC}{$H+}
{$include lcv.inc}
interface
uses
Classes, SysUtils, lcvtypes, math, unitDFT;
type
{ TDFTThread }
TDFTThread = class(TThread)
private
FParams: TDCDFTparameters;
FNofThreads: Integer;
FProgressCaptionProc: TProgressCaptionProc;
protected
procedure Execute; override;
public
property Params: TDCDFTparameters read FParams;
constructor Create(AParams: TDCDFTparameters;
NofThreads: Integer;
AOnTerminate: TNotifyEvent;
ProgressCaptionProc: TProgressCaptionProc);
end;
implementation
constructor TDFTThread.Create(AParams: TDCDFTparameters;
NofThreads: Integer;
AOnTerminate: TNotifyEvent;
ProgressCaptionProc: TProgressCaptionProc);
begin
inherited Create(True);
OnTerminate := AOnTerminate;
FreeOnTerminate := True;
FProgressCaptionProc := ProgressCaptionProc;
FNofThreads := NofThreads;
FParams := AParams;
end;
procedure TDFTThread.Execute;
var
FPUExceptionMask: TFPUExceptionMask;
begin
try
// Under Linux, all exceptions get masked (at least sometimes)
// For compatibility, we explicitly set the mask
FPUExceptionMask := GetExceptionMask;
SetExceptionMask([exDenormalized, exUnderflow, exPrecision]);
try
dcdft_proc(FParams.X, FParams.Y,
FParams.FrequencyMin, FParams.FrequencyMax, FParams.FrequencyResolution,
FParams.TrendDegree, FParams.TrigPolyDegree,
FNofThreads,
FProgressCaptionProc,
FParams.frequencies, FParams.power);
finally
SetExceptionMask(FPUExceptionMask);
end;
except
on E: Exception do begin
FParams.Error := E.Message;
if FParams.Error = '' then
FParams.Error := 'Unknown Error';
end
else
FParams.Error := 'Unknown Error';
end;
end;
end.