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
|
//------------------------------------------------------------------------------
//This Source Code Form is subject to the terms of the Mozilla Public
//License, v. 2.0. If a copy of the MPL was not distributed with this
//file, You can obtain one at http://mozilla.org/MPL/2.0/.
//------------------------------------------------------------------------------
unit Ini;
{$MODE Delphi}
interface
uses
SysUtils, IniFiles, Math;
const
SEC_STN = 'Station';
SEC_BND = 'Band';
SEC_TST = 'Contest';
SEC_SYS = 'System';
DEFAULTBUFCOUNT = 1;
DEFAULTBUFSIZE = 512;
DEFAULTRATE = 11025;
type
TRunMode = (rmStop, rmPileup, rmSingle, rmWpx, rmHst);
var
Call: string = 'DX';
HamName: string;
Wpm: integer = 30;
BandWidth: integer = 500;
Pitch: integer = 600;
Qsk: boolean = true;
Rit: integer = 0;
BufSize: integer = DEFAULTBUFSIZE;
Activity: integer = 2;
Qrn: boolean = true;
Qrm: boolean = true;
Qsb: boolean = true;
Flutter: boolean = true;
Lids: boolean = true;
Duration: integer = 30;
RunMode: TRunMode = rmStop;
HiScore: integer;
CompDuration: integer = 60;
SaveWav: boolean = false;
CallsFromKeyer: boolean = false;
procedure FromIni;
procedure ToIni;
implementation
uses
Main, Contest;
procedure FromIni;
var
F: string;
V: integer;
begin
F := ChangeFileExt(GetAppConfigFile(false), '.ini');
ForceDirectories(ExtractFilePath(F));
with TIniFile.Create(F) do
try
MainForm.SetMyCall(ReadString(SEC_STN, 'Call', Call));
MainForm.SetPitch(ReadInteger(SEC_STN, 'Pitch', 3));
MainForm.SetBw(ReadInteger(SEC_STN, 'BandWidth', 9));
HamName := ReadString(SEC_STN, 'Name', '');
if HamName <> '' then
MainForm.Caption := MainForm.Caption + ': ' + HamName;
Wpm := ReadInteger(SEC_STN, 'Wpm', Wpm);
Wpm := Max(10, Min(120, Wpm));
MainForm.SpinEdit1.Value := Wpm;
Tst.Me.Wpm := Wpm;
MainForm.SetQsk(ReadBool(SEC_STN, 'Qsk', Qsk));
CallsFromKeyer := ReadBool(SEC_STN, 'CallsFromKeyer', CallsFromKeyer);
Activity := ReadInteger(SEC_BND, 'Activity', Activity);
MainForm.SpinEdit3.Value := Activity;
MainForm.CheckBox4.Checked := ReadBool(SEC_BND, 'Qrn', Qrn);
MainForm.CheckBox3.Checked := ReadBool(SEC_BND, 'Qrm', Qrm);
MainForm.CheckBox2.Checked := ReadBool(SEC_BND, 'Qsb', Qsb);
MainForm.CheckBox5.Checked := ReadBool(SEC_BND, 'Flutter', Flutter);
MainForm.CheckBox6.Checked := ReadBool(SEC_BND, 'Lids', Lids);
MainForm.ReadCheckBoxes;
Duration := ReadInteger(SEC_TST, 'Duration', Duration);
MainForm.SpinEdit2.Value := Duration;
HiScore := ReadInteger(SEC_TST, 'HiScore', HiScore);
CompDuration := Max(1, Min(60, ReadInteger(SEC_TST, 'CompetitionDuration', CompDuration)));
//buffer size
V := ReadInteger(SEC_SYS, 'BufSize', 0);
if V = 0 then
begin V := 3; WriteInteger(SEC_SYS, 'BufSize', V); end;
V := Max(1, Min(5, V));
BufSize := 64 shl V;
Tst.Filt.SamplesInInput := BufSize;
Tst.Filt2.SamplesInInput := BufSize;
V := ReadInteger(SEC_STN, 'SelfMonVolume', 0);
MainForm.VolumeSlider1.Value := V / 80 + 0.75;
SaveWav := ReadBool(SEC_STN, 'SaveWav', SaveWav);
finally
Free;
end;
end;
procedure ToIni;
var
F: string;
V: integer;
begin
F := ChangeFileExt(GetAppConfigFile(false), '.ini');
ForceDirectories(ExtractFilePath(F));
with TIniFile.Create(F) do
try
WriteString(SEC_STN, 'Call', Call);
WriteInteger(SEC_STN, 'Pitch', MainForm.ComboBox1.ItemIndex);
WriteInteger(SEC_STN, 'BandWidth', MainForm.ComboBox2.ItemIndex);
WriteInteger(SEC_STN, 'Wpm', Wpm);
WriteBool(SEC_STN, 'Qsk', Qsk);
WriteInteger(SEC_BND, 'Activity', Activity);
WriteBool(SEC_BND, 'Qrn', Qrn);
WriteBool(SEC_BND, 'Qrm', Qrm);
WriteBool(SEC_BND, 'Qsb', Qsb);
WriteBool(SEC_BND, 'Flutter', Flutter);
WriteBool(SEC_BND, 'Lids', Lids);
WriteInteger(SEC_TST, 'Duration', Duration);
WriteInteger(SEC_TST, 'HiScore', HiScore);
WriteInteger(SEC_TST, 'CompetitionDuration', CompDuration);
V := Round(80 * (MainForm.VolumeSlider1.Value - 0.75));
WriteInteger(SEC_STN, 'SelfMonVolume', V);
WriteBool(SEC_STN, 'SaveWav', SaveWav);
finally
Free;
end;
end;
end.
|