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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
|
{Different settings}
unit roptions;
interface
//----- Presets -----
type
tPreset = record
name :PWideChar;
preset:array [0..9] of shortint;
end;
var
Presets: array of tPreset;
OldEQPreset:integer;
procedure LoadPresets;
procedure SavePresets;
procedure FreePresets;
procedure FreeSettings;
procedure LoadSettings;
procedure SaveCommonSettings;
procedure SaveTechSettings;
implementation
uses
windows,
common,dbsettings,mircontacts,m_api,
rglobal;
const
optRecPath :PAnsiChar = 'RecordPath';
optStatusTmpl :PAnsiChar = 'StatusTmpl';
optLoop :PAnsiChar = 'Loop';
optShuffle :PAnsiChar = 'Shuffle';
optPlayFirst :PAnsiChar = 'PlayFromFirst';
optContRec :PAnsiChar = 'ContRec';
optConnect :PAnsiChar = 'AutoConnect';
optAutoMute :PAnsiChar = 'AutoMute';
optOffline :PAnsiChar = 'asOffline';
optEQ_OFF :PAnsiChar = 'eqoff';
optForcedMono :PAnsiChar = 'ForcedMono';
optPreBuf :PAnsiChar = 'PreBuf';
optBuffer :PAnsiChar = 'Buffer';
optTimeout :PAnsiChar = 'Timeout';
optNumTries :PAnsiChar = 'NumTries';
optDevice :PAnsichar = 'Device';
{
const
optVolume :PAnsiChar = 'Volume';
}
//----- Presets -----
const
optOldPreset:pAnsiChar='oldpreset';
optPresets :pAnsiChar='numpreset';
optPreset :pAnsiChar='preset_';
optPreDescr :pAnsiChar='predescr_';
const
PresetMax = 17;
procedure InitPresets;
type
tP = array [0..9] of AnsiChar;
begin
StrDupW(Presets[00].name,'Acoustic' ); tP(Presets[00].preset):=#$01#$02#$00#$00#$00#$00#$00#$01#$01#$03;
StrDupW(Presets[01].name,'Blues' ); tP(Presets[01].preset):=#$01#$02#$01#$00#$00#$00#$00#$00#$00#$FE;
StrDupW(Presets[02].name,'Classical'); tP(Presets[02].preset):=#$01#$04#$01#$00#$00#$00#$00#$00#$01#$01;
StrDupW(Presets[03].name,'Country' ); tP(Presets[03].preset):=#$00#$00#$01#$01#$00#$00#$01#$01#$01#$01;
StrDupW(Presets[04].name,'Dance' ); tP(Presets[04].preset):=#$04#$03#$02#$01#$FF#$FF#$02#$04#$05#$05;
StrDupW(Presets[05].name,'Folk' ); tP(Presets[05].preset):=#$FF#$00#$00#$01#$01#$00#$01#$01#$01#$00;
StrDupW(Presets[06].name,'Grunge' ); tP(Presets[06].preset):=#$01#$00#$FF#$00#$00#$02#$01#$FF#$FE#$FD;
StrDupW(Presets[07].name,'Jazz' ); tP(Presets[07].preset):=#$00#$01#$02#$03#$03#$01#$01#$03#$04#$05;
StrDupW(Presets[08].name,'Metall' ); tP(Presets[08].preset):=#$FE#$00#$00#$00#$00#$03#$02#$04#$06#$05;
StrDupW(Presets[09].name,'New Age' ); tP(Presets[09].preset):=#$03#$03#$00#$00#$00#$00#$00#$00#$02#$02;
StrDupW(Presets[10].name,'Opera' ); tP(Presets[10].preset):=#$00#$01#$02#$04#$01#$02#$00#$00#$00#$00;
StrDupW(Presets[11].name,'Rap' ); tP(Presets[11].preset):=#$00#$04#$04#$00#$00#$00#$01#$04#$05#$07;
StrDupW(Presets[12].name,'Reggae' ); tP(Presets[12].preset):=#$03#$00#$FD#$00#$05#$00#$02#$03#$04#$05;
StrDupW(Presets[13].name,'Rock' ); tP(Presets[13].preset):=#$00#$02#$04#$00#$00#$00#$02#$04#$05#$06;
StrDupW(Presets[14].name,'Speech' ); tP(Presets[14].preset):=#$FE#$02#$00#$00#$00#$00#$FF#$FE#$FD#$FC;
StrDupW(Presets[15].name,'Swing' ); tP(Presets[15].preset):=#$FF#$00#$00#$02#$02#$00#$02#$02#$03#$03;
StrDupW(Presets[16].name,'Techno' ); tP(Presets[16].preset):=#$05#$08#$FF#$FE#$FD#$FF#$04#$06#$06#$06;
end;
procedure LoadPresets;
var
num,preset,descr:array [0..63] of AnsiChar;
i:integer;
p,pd:pAnsiChar;
begin
p :=StrCopyE(preset,optPreset);
pd:=StrCopyE(descr ,optPreDescr);
i:=DBReadByte(0,PluginName,optPresets);
if i=0 then
begin
SetLength(Presets,PresetMax);
InitPresets;
OldEQPreset:=-1;
end
else
begin
OldEQPreset:=integer(DBReadByte(0,PluginName,optOldPreset,byte(-1)));
SetLength(Presets,i);
for i:=0 to HIGH(Presets) do
begin
StrCopy(p ,IntToStr(num,i)); DBReadStruct (0,PluginName,preset,@Presets[i].preset,10);
StrCopy(pd,num); Presets[i].name:=DBReadUnicode(0,PluginName,descr);
end;
end;
end;
procedure SavePresets;
var
num,preset,descr:array [0..63] of AnsiChar;
i,j:integer;
p,pd:pAnsiChar;
begin
p :=StrCopyE(preset,optPreset);
pd:=StrCopyE(descr ,optPreDescr);
j:=DBReadByte(0,PluginName,optPresets);
for i:=0 to HIGH(Presets) do
begin
StrCopy(p ,IntToStr(num,i)); DBWriteStruct (0,PluginName,preset,@Presets[i].preset,10);
StrCopy(pd,num); DBWriteUnicode(0,PluginName,descr ,Presets[i].name);
end;
while j>Length(Presets) do
begin
dec(j);
StrCopy(p ,IntToStr(num,j)); DBDeleteSetting(0,PluginName,preset);
StrCopy(pd,num); DBDeleteSetting(0,PluginName,descr);
end;
DBWriteByte(0,PluginName,optOldPreset,OldEQPreset);
DBWriteByte(0,PluginName,optPresets ,Length(Presets));
end;
procedure FreePresets;
var
i:integer;
begin
for i:=0 to HIGH(Presets) do
mFreeMem(Presets[i].name);
end;
//----- Common settings -----
procedure FreeSettings;
begin
mFreeMem(recpath);
mFreeMem(StatusTmpl);
mFreeMem(usedevice);
end;
procedure LoadSettings;
var
szTemp:array [0..7] of AnsiChar;
i:integer;
begin
//-- record
recpath:=DBReadUnicode(0,PluginName,optRecPath);
if recpath=nil then
recpath:=GetDefaultRecPath;
//-- mRadio settings
doLoop :=DBReadByte(0,PluginName,optLoop);
doShuffle :=DBReadByte(0,PluginName,optShuffle);
doContRec :=DBReadByte(0,PluginName,optContRec);
PlayFirst :=DBReadByte(0,PluginName,optPlayFirst);
AuConnect :=DBReadByte(0,PluginName,optConnect);
AuMute :=DBReadByte(0,PluginName,optAutoMute);
AsOffline :=DBReadByte(0,PluginName,optOffline);
StatusTmpl:=DBReadUnicode(0,PluginName,optStatusTmpl,'%radio_title%');
//-- Tech settings
usedevice :=DBReadString(0,PluginName,optDevice);
sPreBuf :=DBReadWord(0,PluginName,optPreBuf ,75);
sBuffer :=DBReadWord(0,PluginName,optBuffer ,5000);
sTimeout :=DBReadWord(0,PluginName,optTimeout,5000);
isEQ_OFF :=DBReadByte(0,PluginName,optEQ_OFF);
gVolume :=integer(shortint(DBReadByte(0,PluginName,optVolume,50)));
ForcedMono:=DBReadByte(0,PluginName,optForcedMono);
NumTries :=DBReadByte(0,PluginName,optNumTries,1);
if NumTries<1 then NumTries:=1;
// volume changes
if AuMute<>0 then
begin
gVolume:=ABS(gVolume);
if DBReadByte(0,'Skin','UseSound')=0 then
CallService(MS_RADIO_MUTE,0,0);
end;
//-- Equalizer
szTemp[0]:='E';
szTemp[1]:='Q';
szTemp[2]:='_';
szTemp[4]:=#0;
for i:=0 to 9 do
begin
szTemp[3]:=AnsiChar(ORD('0')+i);
eq[i].param.fGain:=DBReadByte(0,PluginName,szTemp,15)-15;
end;
if AuConnect<>BST_UNCHECKED then
ActiveContact:=LoadContact(PluginName,optLastStn)
else
ActiveContact:=0;
end;
procedure SaveCommonSettings;
begin
DBWriteByte(0,PluginName,optLoop ,doLoop);
DBWriteByte(0,PluginName,optShuffle ,doShuffle);
DBWriteByte(0,PluginName,optContRec ,doContRec);
DBWriteByte(0,PluginName,optPlayFirst,PlayFirst);
DBWriteByte(0,PluginName,optConnect ,AuConnect);
DBWriteByte(0,PluginName,optAutoMute ,AuMute);
DBWriteByte(0,PluginName,optOffline ,AsOffline);
DBWriteUnicode(0,PluginName,optStatusTmpl,StatusTmpl);
DBWriteUnicode(0,PluginName,optRecPath ,recpath);
end;
procedure SaveTechSettings;
var
szTemp:array [0..7] of AnsiChar;
i:integer;
begin
DBWriteWord(0,PluginName,optTimeout,sTimeout);
DBWriteWord(0,PluginName,optBuffer,sBuffer);
DBWriteWord(0,PluginName,optPreBuf,sPreBuf);
DBWriteByte(0,PluginName,optForcedMono,ForcedMono);
DBWriteByte(0,PluginName,optNumTries,NumTries);
DBWriteByte(0,PluginName,optEQ_OFF ,isEQ_OFF);
DBWriteString(0,PluginName,optDevice,usedevice);
szTemp[0]:='E';
szTemp[1]:='Q';
szTemp[2]:='_';
szTemp[4]:=#0;
for i:=0 to 9 do
begin
szTemp[3]:=AnsiChar(ORD('0')+i);
DBWriteByte(0,PluginName,szTemp,trunc(eq[i].param.fGain)+15);
end;
end;
end.
|