-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofiles.pas
More file actions
169 lines (138 loc) · 5.11 KB
/
Copy pathprofiles.pas
File metadata and controls
169 lines (138 loc) · 5.11 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
unit profiles;
{$include 'compileroptions.inc'}
interface
uses
Classes, SysUtils, Types, Math, IniFiles, FileCtrl, FileUtil, utils;
type
{ TProfile }
TProfile = class
private
FName: String;
FRevolutionsPerSecond: Double;
FRecordingGrooveWidth: Double;
FRecordingGrooveThickness: Double;
FLeadOutGrooveThickness: Double;
FOuterSize: Double;
FInnerSize: Double;
FLabelOuterSize: Double;
FConcentricGroove: Double;
FMinConcentricGroove: Double;
FMaxConcentricGroove: Double;
FStylusSetDown: Double;
FFirstMusicGroove: Double;
FLastMusicGroove: Double;
FAdapterSize: Double;
FMono: Boolean;
FCorrectAngleCount: Integer;
FCorrectCoordinateCount: Integer;
public
constructor Create(AFN: String);
property Name: String read FName;
property RevolutionsPerSecond: Double read FRevolutionsPerSecond;
property RecordingGrooveWidth: Double read FRecordingGrooveWidth;
property RecordingGrooveThickness: Double read FRecordingGrooveThickness;
property LeadOutGrooveThickness: Double read FLeadOutGrooveThickness;
property OuterSize: Double read FOuterSize;
property InnerSize: Double read FInnerSize;
property LabelOuterSize: Double read FLabelOuterSize;
property ConcentricGroove: Double read FConcentricGroove;
property MinConcentricGroove: Double read FMinConcentricGroove;
property MaxConcentricGroove: Double read FMaxConcentricGroove;
property StylusSetDown: Double read FStylusSetDown;
property FirstMusicGroove: Double read FFirstMusicGroove;
property LastMusicGroove: Double read FLastMusicGroove;
property AdapterSize: Double read FAdapterSize;
property Mono: Boolean read FMono;
property CorrectAngleCount: Integer read FCorrectAngleCount;
property CorrectCoordinateCount: Integer read FCorrectCoordinateCount;
end;
TProfileArray = array of TProfile;
{ TProfiles }
TProfiles = class
private
FProfiles: TProfileArray;
FCurrentProfileRef: TProfile;
public
constructor Create(ADir: String);
destructor Destroy; override;
property Profiles: TProfileArray read FProfiles;
property CurrentProfileRef: TProfile read FCurrentProfileRef write FCurrentProfileRef;
end;
implementation
{ TProfile }
constructor TProfile.Create(AFN: String);
const
CSection = 'Profile';
var
ini: TIniFile;
function GetValue(AIdent: string): Double;
begin
Result := ini.ReadFloat(CSection, AIdent, NaN);
Assert(not IsNan(Result), AFN + ': ' + AIdent + ' Not found!');
end;
begin
FName := ChangeFileExt(ExtractFileName(AFN), '');;
ini := TIniFile.Create(AFN, [ifoFormatSettingsActive]);
try
ini.FormatSettings := InvariantFormatSettings;
FRevolutionsPerSecond := GetValue('RevolutionsPerMinute') / 60.0;
FRecordingGrooveWidth := GetValue('RecordingGrooveWidth');
FRecordingGrooveThickness := GetValue('RecordingGrooveThickness');
FLeadOutGrooveThickness := GetValue('LeadOutGrooveThickness');
FOuterSize := GetValue('OuterSize');
FInnerSize := GetValue('InnerSize');
FLabelOuterSize := GetValue('LabelOuterSize');
FConcentricGroove := GetValue('ConcentricGroove');
FMinConcentricGroove := GetValue('ConcentricGrooveLowTol') * -1 + FConcentricGroove;
FMaxConcentricGroove := GetValue('ConcentricGrooveHighTol') + FConcentricGroove;
FStylusSetDown := GetValue('StylusSetDown');
FFirstMusicGroove := GetValue('FirstMusicGroove');
FLastMusicGroove := GetValue('LastMusicGroove');
FAdapterSize := GetValue('AdapterSize');
FMono := ini.ReadBool(CSection, 'Mono', True);
FCorrectAngleCount := ini.ReadInteger(CSection, 'CorrectAngleCount', 36);
FCorrectCoordinateCount := ini.ReadInteger(CSection, 'CorrectCoordinateCount', 4);
finally
ini.Free;
end;
end;
{ TProfiles }
function CompareProfile(Item1, Item2, UserParameter: Pointer): Integer;
var
p1: ^TProfile absolute Item1;
p2: ^TProfile absolute Item2;
begin
Result := CompareValue(p1^.OuterSize, p2^.OuterSize);
if Result = 0 then
Result := CompareValue(p1^.RevolutionsPerSecond, p2^.RevolutionsPerSecond);
if Result = 0 then
Result := CompareValue(Ord(p1^.Mono), Ord(p2^.Mono));
end;
constructor TProfiles.Create(ADir: String);
var
Info: TSearchRec;
begin
ADir := IncludeTrailingPathDelimiter(ADir);
if FindFirst(ADir + '*.ini', faNormal, Info) = 0 then
begin
repeat
SetLength(FProfiles, Length(FProfiles) + 1);
FProfiles[High(FProfiles)] := TProfile.Create(ADir + Info.Name);
until FindNext(Info) <> 0;
FindClose(Info);
end;
if Length(FProfiles) > 0 then
begin
QuickSort(FProfiles[0], 0, High(FProfiles), SizeOf(TProfile), @CompareProfile);
FCurrentProfileRef := FProfiles[0];
end;
end;
destructor TProfiles.Destroy;
var
iProfile: Integer;
begin
for iProfile := 0 to High(FProfiles) do
FProfiles[iProfile].Free;
inherited Destroy;
end;
end.