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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
|
{Options dialog}
function ImportOneStation(group:PAnsiChar;section:pointer):int;
var
p:pWideChar;
pc:pAnsiChar;
begin
result:=0;
pc:=GetParamSectionStr(section,'URL');
if pc<>nil then
begin
result:=CallService(MS_DB_CONTACT_ADD,0,0);
if result<>0 then
begin
CallService(MS_PROTO_ADDTOCONTACT,result,lparam(PluginName));
DBWriteString(result,PluginName,optStationURL,pc);
DBWriteString(result,PluginName,optFirstName ,pc);
pc:=GetParamSectionStr(section,optBitrate,'0');
DBWriteString(result,PluginName,optBitrate,pc);
DBWriteWord (result,PluginName,optAge ,StrToInt(pc));
pc:=GetParamSectionStr(section,'Name',GetSectionName(section));
DBWriteString(result,strCList ,optMyHandle,pc);
DBWriteString(result,PluginName,optNick ,pc);
pc:=GetParamSectionStr(section,optGenre,'unknown');
DBWriteString(result,PluginName,optGenre ,pc);
DBWriteString(result,PluginName,optLastName,pc);
SetStatus(result,ID_STATUS_OFFLINE);
if group=nil then
group:=GetParamSectionStr(section,optGroup);
AnsiToWide(group,p,MirandaCP);
CreateGroupW(p,result);
mFreeMem(p);
CallService(MS_IGNORE_IGNORE,result,IGNOREEVENT_ALL);
end;
end;
end;
function ImportAll(wParam:WPARAM;lParam:LPARAM):int; cdecl;
var
dst:array [0..MAX_PATH-1] of AnsiChar;
pc:pAnsiChar;
lstorage,section,list:pointer;
begin
result:=0;
if lParam<>0 then
StrCopy(dst,PAnsiChar(lParam));
if (lParam<>0) or ShowDlg(dst,'radio.ini',nil,true) then
begin
lstorage:=OpenStorage(dst);
if lstorage<>nil then
begin
list:=GetSectionList(lstorage);
pc:=list;
while pc^<>#0 do
begin
section:=SearchSection(lstorage,pc);
if ImportOneStation(pAnsiChar(wParam),section)<>0 then inc(result);
while pc^<>#0 do inc(pc);
inc(pc);
end;
FreeSectionList(list);
CloseStorage(lstorage);
end;
end;
end;
procedure ExportRadioContact(num:integer;fname:PAnsiChar;hContact:THANDLE);
var
pc:pAnsiChar;
section:array [0..15] of AnsiChar;
begin
IntToStr(section,num);
pc:=DBReadString(hContact,strCList,optMyHandle);
WritePrivateProfileStringA(section,'Name',pc,fname);
mFreeMem(pc);
pc:=DBReadString(hContact,PluginName,optStationURL);
WritePrivateProfileStringA(section,'URL',pc,fname);
mFreeMem(pc);
pc:=DBReadString(hContact,PluginName,optGenre);
if pc<>nil then
begin
WritePrivateProfileStringA(section,optGenre,pc,fname);
mFreeMem(pc);
end;
pc:=DBReadString(hContact,PluginName,optBitrate);
if pc<>nil then
begin
WritePrivateProfileStringA(section,optBitrate,pc,fname);
mFreeMem(pc);
end;
pc:=DBReadString(hContact,strCList,optGroup);
if pc<>nil then
begin
WritePrivateProfileStringA(section,optGroup,pc,fname);
mFreeMem(pc);
end;
end;
function ExportAll(wParam:WPARAM;lParam:LPARAM):int; cdecl;
var
dst:array [0..MAX_PATH-1] of AnsiChar;
hContact:THANDLE;
begin
result:=0;
if lParam<>0 then
StrCopy(dst,PAnsiChar(lParam));
if (lParam<>0) or ShowDlg(dst,'radio.ini',nil,false) then
begin
if (wParam<>0) and (CallService(MS_DB_CONTACT_IS,wParam,0)<>0) then
begin
result:=1;
ExportRadioContact(result,dst,wParam)
end
else
begin
hContact:=db_find_first(PluginName);
while hContact<>0 do
begin
inc(result);
ExportRadioContact(result,dst,hContact);
hContact:=db_find_next(hContact,PluginName);
end;
end;
end;
end;
function MakeFilter(dst,descr,full,filter:PWideChar;show:bool=true):pWideChar;
var
p:PWideChar;
begin
if full<>nil then
begin
p:=StrEndW(full);
p^:=';';
StrCopyW(p+1,filter);
end;
dst:=StrCopyEW(dst,TranslateW(descr));
if show then
begin
dst^ :=' ';
(dst+1)^:='(';
dst:=StrCopyEW(dst+2,filter);
dst^:=')';
inc(dst);
dst^:=#0;
end;
inc(dst);
result:=StrCopyEW(dst,filter)+1;
end;
function ConstructFilter:pointer;
var
pc:pWideChar;
ph:PDWord;
Info:PBASS_PLUGININFO;
i:integer;
full:array [0..511] of WideChar;
tmpbuf1,tmpbuf2:array [0..127] of WideChar;
begin
mGetMem(pc,4096);
// FillChar(pc^,4096,0);
result:=pc;
full[0]:=#0;
pc:=MakeFilter(pc,'All files' ,nil ,'*.*',false);
pc:=MakeFilter(pc,'Playlist files',full,'*.pls;*.m3u;*.m3u8;*.asx');
pc:=MakeFilter(pc,'BASS built-in' ,full,'*.mp3;*.mp2;*.mp1;*.ogg;*.wav;*.aif');
ph:=pointer(BASS_PluginGetInfo(0));
if ph<>nil then
begin
while ph^<>0 do
begin
Info:=BASS_PluginGetInfo(ph^);
for i:=0 to Info^.formatc-1 do
//!! need to translate Ansi -> wide
with Info^.Formats[i] do
begin
pc:=MakeFilter(pc,FastAnsiToWideBuf(name,tmpbuf1),full,FastAnsiToWideBuf(exts,tmpbuf2));
end;
inc(ph);
end;
end;
pc:=MakeFilter(pc,'All supported formats',nil,full,false);
pc^:=#0;
end;
procedure SetButtonIcons(Dialog:HWND);
var
ti:TTOOLINFOW;
hwndTooltip:HWND;
begin
hwndTooltip:=CreateWindowW(TOOLTIPS_CLASS,nil,TTS_ALWAYSTIP,
integer(CW_USEDEFAULT),integer(CW_USEDEFAULT),
integer(CW_USEDEFAULT),integer(CW_USEDEFAULT),
Dialog,0,hInstance,nil);
FillChar(ti,SizeOf(ti),0);
ti.cbSize :=sizeof(TOOLINFO);
ti.uFlags :=TTF_IDISHWND or TTF_SUBCLASS;
ti.hwnd :=Dialog;
ti.hinst :=hInstance;
ti.uId :=GetDlgItem(Dialog,IDC_EQ_ADD);
ti.lpszText:=TranslateW('Add');
SetButtonIcon(ti.uId,IcoBtnAdd);
SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti));
ti.uId :=GetDlgItem(Dialog,IDC_EQ_DEL);
ti.lpszText:=TranslateW('Delete');
SetButtonIcon(ti.uId,IcoBtnDel);
SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti));
end;
function DlgProcOpt(Dialog:HWnd;hMessage:UINT;wParam:WPARAM;lParam:LPARAM):lresult; stdcall;
const
DlgInit:integer=1;
var
buf:array [0..MAX_PATH-1] of WideChar;
psr:TPROTOSEARCHRESULT;
dst:pWideChar;
i:dword;
vhi:TVARHELPINFO;
wnd:HWND;
p:pWideChar;
begin
result:=0;
case hMessage of
WM_DESTROY: 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);
end;
WM_INITDIALOG: begin
DlgInit:=1;
TranslateDialogDefault(Dialog);
wnd:=GetDlgItem(Dialog,IDC_HLP_VARS);
if isVarsInstalled then
begin
SendMessage(wnd,BM_SETIMAGE,IMAGE_ICON,
CallService(MS_VARS_GETSKINITEM,0,VSI_HELPICON));
end
else
ShowWindow(wnd,SW_HIDE);
if recpath<>nil then
p:=recpath
else
begin
buf[0]:=#0;
p:=@buf;
end;
SetDlgItemTextW(Dialog,IDC_ED_RECPATH,p);
CheckDlgButton(Dialog,IDC_LOOP ,doLoop);
CheckDlgButton(Dialog,IDC_SHUFFLE ,doShuffle);
CheckDlgButton(Dialog,IDC_CONTREC ,doContRec);
CheckDlgButton(Dialog,IDC_PLAYFIRST,PlayFirst);
CheckDlgButton(Dialog,IDC_CONNECT ,AuConnect);
CheckDlgButton(Dialog,IDC_AUTOMUTE ,AuMute);
CheckDlgButton(Dialog,IDC_OFFLINE ,AsOffline);
SetDlgItemTextW(Dialog,IDC_STATUS,StatusTmpl);
DlgInit:=0;
end;
WM_COMMAND: begin
case wParam shr 16 of
EN_CHANGE: begin
if DlgInit=0 then
case loword(wParam) of
IDC_STATION,IDC_STATIONURL,IDC_GENRE,IDC_BITRATE: ;
else
SendMessage(GetParent(Dialog),PSM_CHANGED,0,0);
end;
end;
BN_CLICKED: begin
case loword(wParam) of
IDC_IMPORT: begin
ImportAll(0,0);
end;
IDC_EXPORT: begin
ExportAll(0,0);
end;
IDC_HLP_VARS: begin
FillChar(vhi,SizeOf(vhi),0);
with vhi do
begin
cbSize :=SizeOf(vhi);
flags :=VHF_FULLDLG or VHF_SETLASTSUBJECT;
hwndCtrl :=GetDlgItem(Dialog,IDC_STATUS);
szSubjectDesc:='test your variables';
end;
CallService(MS_VARS_SHOWHELPEX,Dialog,tlparam(@vhi));
end;
IDC_BN_URLPATH: begin
dst:=ConstructFilter;
if ShowDlgW(@buf,nil,dst) then
SetDlgItemTextW(Dialog,IDC_STATIONURL,@buf);
mFreeMem(dst);
end;
IDC_BN_RECPATH: begin
dst:=nil;
if SelectDirectory(pWideChar(nil),dst,Dialog) then
begin
PathToRelativeW(dst,buf);
SetDlgItemTextW(Dialog,IDC_ED_RECPATH,pWideChar(@buf));
mFreeMem(dst);
end;
end;
IDC_LOOP,IDC_SHUFFLE,IDC_CONTREC,IDC_CONNECT,IDC_OFFLINE,IDC_AUTOMUTE:
SendMessage(GetParent(Dialog),PSM_CHANGED,0,0);
IDC_ADD_LIST,IDC_ADD_INI: begin
if GetWindowTextLength(GetDlgItem(Dialog,IDC_STATIONURL))>0 then
begin
FillChar(psr,SizeOf(psr),0);
with psr do
begin
if loword(wParam)=IDC_ADD_LIST then
begin
GetDlgItemTextW(Dialog,IDC_STATIONURL,@buf,MAX_PATH);
StrDupW(firstname.w,@buf);
buf[0]:=#0;
GetDlgItemTextW(Dialog,IDC_STATION,@buf,MAX_PATH);
if buf[0]<>#0 then
StrDupW(nick.w,@buf)
else
StrDupW(nick.w,firstname.w);
buf[0]:=#0;
GetDlgItemTextW(Dialog,IDC_GENRE,@buf,MAX_PATH);
StrDupW(lastname.w,@buf);
buf[0]:=#0;
GetDlgItemTextW(Dialog,IDC_BITRATE,@buf,MAX_PATH);
StrDupW(email.w,@buf);
i:=Service_AddToList(0,tlparam(@psr));
{
GetDlgItemTextW(Dialog,IDC_STATION,@buf,SizeOf(buf));
DBWriteUnicode(i,strCList,optMyHandle,@buf);
GetDlgItemTextW(Dialog,IDC_STATIONURL,@buf,SizeOf(buf));
DBWriteUnicode(i,PluginName,optStationURL,@buf);
}
// "changing" station group
dst:=GetNewGroupName(Dialog);
if dst<>nil then
DBWriteUnicode(i,strCList,optGroup,dst)
else
DBDeleteSetting(i,strCList,optGroup);
end
else if loword(wParam)=IDC_ADD_INI then
begin
GetDlgItemTextA(Dialog,IDC_STATIONURL,PAnsiChar(@buf),SizeOf(buf));
StrDup(firstname.a,PAnsiChar(@buf));
PAnsiChar(@buf)^:=#0;
GetDlgItemTextA(Dialog,IDC_STATION,PAnsiChar(@buf),SizeOf(buf));
if PAnsiChar(@buf)^<>#0 then
StrDup(nick.a,@buf)
else
StrDup(nick.a,firstname.a);
PAnsiChar(@buf)^:=#0;
GetDlgItemTextA(Dialog,IDC_GENRE,PAnsiChar(@buf),SizeOf(buf));
StrDup(lastname.a,@buf);
PAnsiChar(@buf)^:=#0;
GetDlgItemTextA(Dialog,IDC_BITRATE,PAnsiChar(@buf),SizeOf(buf));
StrDup(email.a,@buf);
if WritePrivateProfileStringA(firstname.a,'URL',firstname.a,storage) then
begin
WritePrivateProfileStringA(firstname.a,'Name' ,nick.a ,storage);
WritePrivateProfileStringA(firstname.a,optGenre ,lastname.a ,storage);
WritePrivateProfileStringA(firstname.a,optBitrate,email.a ,storage);
end
else
begin
WritePrivateProfileStringA(firstname.a,'URL' ,firstname.a,storagep);
WritePrivateProfileStringA(firstname.a,'Name' ,nick.a ,storagep);
WritePrivateProfileStringA(firstname.a,optGenre ,lastname.a ,storagep);
WritePrivateProfileStringA(firstname.a,optBitrate,email.a ,storagep);
end;
end;
mFreeMem(nick);
mFreeMem(firstname);
mFreeMem(lastname);
mFreeMem(email);
end;
end;
end;
end;
end;
end;
end;
WM_NOTIFY: begin
if integer(PNMHdr(lParam)^.code)=PSN_APPLY then
begin
doShuffle:=IsDlgButtonChecked(Dialog,IDC_SHUFFLE);
doContRec:=IsDlgButtonChecked(Dialog,IDC_CONTREC);
PlayFirst:=IsDlgButtonChecked(Dialog,IDC_PLAYFIRST);
AuConnect:=IsDlgButtonChecked(Dialog,IDC_CONNECT);
AuMute :=IsDlgButtonChecked(Dialog,IDC_AUTOMUTE);
AsOffline:=IsDlgButtonChecked(Dialog,IDC_OFFLINE);
mFreeMem(StatusTmpl);
StatusTmpl:=GetDlgText(Dialog,IDC_STATUS);
doLoop:=IsDlgButtonChecked(Dialog,IDC_LOOP);
if chan<>0 then
begin
{
BASS_ChannelGetInfo(chan,info);
if doLoop<>BST_UNCHECKED then
info.flags:=info.flags or BASS_SAMPLE_LOOP
else
info.flags:=info.flags and not BASS_SAMPLE_LOOP;
}
BASS_ChannelFlags(chan,ord(doLoop<>BST_UNCHECKED),BASS_SAMPLE_LOOP);
end;
mFreeMem(recpath);
buf[0]:=#0;
GetDlgItemTextW(Dialog,IDC_ED_RECPATH,@buf,SizeOf(buf) div SizeOf(WideChar));
if buf[0]<>#0 then
begin
mGetMem(recpath,MAX_PATH*SizeOf(WideChar));
recpath^:=#0;
PathToRelativeW(buf,recpath);
end
else
recpath:=GetDefaultRecPath;
DBWriteUnicode(0,PluginName,optRecPath,recpath);
end;
end;
// else
// result:=DefWindowProc(Dialog,hMessage,wParam,lParam);
end;
end;
//----- Tech tab -----
const
OldEQPreset:integer=-1;
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;
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;
procedure FillDeviceCombo(wnd:HWND;choose:pAnsiChar);
var
i,select,def:integer;
info:BASS_DEVICEINFO;
buf: array [0..255] of AnsiChar;
begin
SendMessage(wnd,CB_RESETCONTENT,0,0);
i:=0;
select:=-1;
def:=0;
repeat
if not BASS_GetDeviceInfo(i+1,info) then
break;
if (info.flags and BASS_DEVICE_ENABLED)<>0 then
begin
if (info.flags and BASS_DEVICE_INIT)<>0 then
begin
select:=i;
buf[0]:='>';
end
else if (info.flags and BASS_DEVICE_DEFAULT)<>0 then
begin
def:=i;
buf[0]:='*';
end
else buf[0]:=' ';
if select<0 then
begin
if StrCmp(info.name,choose)=0 then
select:=i;
end;
StrCopy(@buf[1],info.name);
SendMessageA(wnd,CB_ADDSTRING,0,lparam(@buf));
end;
inc(i);
until false;
if select>=0 then
def:=select;
SendMessage(wnd,CB_SETCURSEL,def,0);
// not acceptable coz we added 1st char
// SendMessageW(wnd,CB_SELECTSTRING,twparam(-1),tlparam(choose))
end;
function DlgProcOptTech(Dialog:HWnd;hMessage:uint;wParam:WPARAM;lParam:LPARAM):lresult; stdcall;
const
DlgInit:integer=1;
var
i:integer;
hEAXCombo:THANDLE;
ltmp:longbool;
// info:BASS_CHANNELINFO;
buf1:array [0..4] of AnsiChar;
wnd:HWND;
buf:array [0..MAX_PATH-1] of WideChar;
dst:pWideChar;
begin
result:=0;
case hMessage of
WM_DESTROY: begin
hVolCtrl:=0;
buf1[0]:='E';
buf1[1]:='Q';
buf1[2]:='_';
buf1[4]:=#0;
for i:=0 to 9 do
begin
buf1[3]:=AnsiChar(ORD('0')+i);
DBWriteByte(0,PluginName,buf1,trunc(eq[i].param.fGain)+15);
eq[i].wnd:=0;
end;
DBWriteByte(0,PluginName,optEQ_OFF ,isEQ_OFF);
end;
WM_INITDIALOG: begin
DlgInit:=1;
TranslateDialogDefault(Dialog);
SetButtonIcons(Dialog);
hVolCtrl:=GetDlgItem(Dialog,IDC_VOLUME);
SendMessage(hVolCtrl,TBM_SETRANGE,0,(100 shl 16)+0);
SendMessage(hVolCtrl,TBM_SETPOS,1,ABS(gVolume));
SetDlgItemInt(Dialog,IDC_BUFFER ,sBuffer ,false);
SetDlgItemInt(Dialog,IDC_PREBUF ,sPreBuf ,false);
SetDlgItemInt(Dialog,IDC_TIMEOUT,sTimeout,false);
SetDlgItemInt(Dialog,IDC_TRIES ,NumTries,false);
CheckDlgButton(Dialog,IDC_MONO,ForcedMono);
// Fill EAX combo
hEAXCombo:=GetDlgItem(Dialog,IDC_EAXTYPE);
for i:=0 to EAX_ENVIRONMENT_COUNT do
SendMessageW(hEAXCombo,CB_ADDSTRING,0,tlparam(TranslateW(EAXItems[i].name)));
SendMessage(hEAXCombo,CB_SETCURSEL,DBReadByte(0,PluginName,optEAXType,0),0);
// Fill combo with devices
FillDeviceCombo(GetDlgItem(Dialog,IDC_DEVICE),usedevice);
// Add preset to combo
wnd:=GetDlgItem(Dialog,IDC_PRESET);
for i:=0 to HIGH(Presets) do
SendMessageW(wnd,CB_ADDSTRING,0,tlparam(Presets[i].name));
SendMessage(wnd,CB_SETCURSEL,OldEQPreset,0);
// Equalizer
for i:=0 to 9 do
begin
eq[i].wnd:=GetDlgItem(Dialog,IDC_EQ00+i);
SendMessage(eq[i].wnd,TBM_SETRANGE,1,(16 shl 16)-15);
SendMessage(eq[i].wnd,TBM_SETTIC,0,0);
SendMessage(eq[i].wnd,TBM_SETPOS,1,-trunc(eq[i].param.fGain));
SendDlgItemMessageA(Dialog,IDC_0+i,WM_SETTEXT,0,tlparam(eq[i].text));
EnableWindow(eq[i].wnd,isEQ_OFF=BST_UNCHECKED);
end;
CheckDlgButton(Dialog,IDC_EQOFF,isEQ_OFF);
dst:=DBReadUnicode(0,PluginName,optBASSPath,nil);
SetDlgItemTextW(Dialog,IDC_BASSPATH,dst);
mFreeMem(dst);
DlgInit:=0;
end;
WM_COMMAND: begin
case wParam shr 16 of
EN_CHANGE: begin
if DlgInit=0 then
SendMessage(GetParent(Dialog),PSM_CHANGED,0,0);
end;
BN_CLICKED: begin
case loword(wParam) of
IDC_BASSPTHBTN: begin
dst:=nil;
if SelectDirectory(pWideChar(nil),dst,Dialog) then
begin
PathToRelativeW(dst,buf);
SetDlgItemTextW(Dialog,IDC_BASSPATH,pWideChar(@buf));
mFreeMem(dst);
end;
end;
IDC_EQOFF: begin
isEQ_OFF:=IsDlgButtonChecked(Dialog,IDC_EQOFF);
if isEQ_OFF=BST_UNCHECKED then
EQ_ON
else
EQ_OFF;
for i:=0 to 9 do
EnableWindow(eq[i].wnd,isEQ_OFF=BST_UNCHECKED);
end;
IDC_ZERO: begin
OldEQPreset:=-1;
for i:=0 to 9 do
begin
eq[i].param.fGain:=0;
SendMessage(eq[i].wnd,TBM_SETPOS,1,0);
if (chan<>0) and (isEQ_OFF=BST_UNCHECKED) then
BASS_FXSetParameters(eq[i].fx,@eq[i].param);
end;
end;
IDC_EQ_ADD: begin
SetLength(Presets,Length(Presets)+1);
for i:=0 to 9 do
Presets[HIGH(Presets)].preset[i]:=-SendMessage(eq[i].wnd,TBM_GETPOS,0,0);
wnd:=GetDlgItem(Dialog,IDC_PRESET);
Presets[HIGH(Presets)].name:=GetDlgText(wnd,false);
if Presets[HIGH(Presets)].name=nil then
StrDupW(Presets[HIGH(Presets)].name,'New');
OldEQPreset:=SendMessage(wnd,CB_SETCURSEL,
SendMessageW(wnd,CB_ADDSTRING,0,tlparam(Presets[HIGH(Presets)].name)),0);
end;
IDC_EQ_DEL: begin
wnd:=GetDlgItem(Dialog,IDC_PRESET);
i:=SendMessage(wnd,CB_GETCURSEL,0,0);
if (i>=0) and (i<=HIGH(Presets)) then
begin
SendMessage(wnd,CB_DELETESTRING,i,0);
mFreeMem(Presets[i].name);
move(Presets[i+1],Presets[i],(HIGH(Presets)-i)*SizeOf(tPreset));
SetLength(Presets,Length(Presets)-1);
OldEQPreset:=-1;
SendMessage(wnd,CB_SETCURSEL,-1,0);
end;
end;
end;
end;
CBN_SELCHANGE: begin
SendMessage(GetParent(Dialog),PSM_CHANGED,0,0);
case loword(wParam) of
IDC_PRESET: begin
OldEQPreset:=SendDlgItemMessage(Dialog,IDC_PRESET,CB_GETCURSEL,0,0);
for i:=0 to 9 do
begin
SendMessage(eq[i].wnd,TBM_SETPOS,1,-Presets[OldEQPreset].preset[i]);
eq[i].param.fGain:=Presets[OldEQPreset].preset[i];
if (chan<>0) and (isEQ_OFF=BST_UNCHECKED) then
BASS_FXSetParameters(eq[i].fx,@eq[i].param);
end;
end;
IDC_EAXTYPE: begin
{
i:=SendDlgItemMessage(Dialog,IDC_EAXTYPE,CB_GETCURSEL,0,0);
DBWriteByte(0,PluginName,optEAXType,i);
if i=0 then
BASS_SetEAXParameters(-1,0,-1,-1)
else
BASS_SetEAXPreset(EAXItems[i].code);
}
end;
end;
end;
end;
end;
WM_VSCROLL: begin
for i:=0 to 9 do
begin
if HWND(lParam)=eq[i].wnd then
begin
eq[i].param.fGain:=-SendMessage(lParam,TBM_GETPOS,0,0);
if (chan<>0) and (isEQ_OFF=BST_UNCHECKED) then
BASS_FXSetParameters(eq[i].fx,@eq[i].param);
OldEQPreset:=-1;
break;
end;
end;
end;
WM_HSCROLL: begin
Service_RadioSetVolume(SendMessage(lParam,TBM_GETPOS,0,0),1)
end;
WM_NOTIFY: begin
if integer(PNMHdr(lParam)^.code)=PSN_APPLY then
begin
SavePresets;
mFreeMem(usedevice);
usedevice:=GetDlgText(Dialog,IDC_DEVICE,true);
StrCopy(usedevice,usedevice+1);
DBWriteString(0,PluginName,optDevice,usedevice);
//!! bass path saving here
dst:=GetDlgText(Dialog,IDC_BASSPATH);
DBWriteUnicode(0,PluginName,optBASSPath,dst);
mFreeMem(dst);
ForcedMono:=IsDlgButtonChecked(Dialog,IDC_MONO);
DBWriteByte(0,PluginName,optForcedMono,ForcedMono);
i:=SendDlgItemMessage(Dialog,IDC_EAXTYPE,CB_GETCURSEL,0,0);
DBWriteByte(0,PluginName,optEAXType,i);
if i=0 then
BASS_SetEAXParameters(-1,0,-1,-1)
else
BASS_SetEAXPreset(EAXItems[i].code);
NumTries:=GetDlgItemInt(Dialog,IDC_TRIES,ltmp,false);
if NumTries<1 then NumTries:=1;
DBWriteByte(0,PluginName,optNumTries,NumTries);
i:=GetDlgItemInt(Dialog,IDC_PREBUF,ltmp,false);
if i>100 then i:=100;
if cardinal(i)<>sPreBuf then
begin
sPreBuf:=i;
BASS_SetConfig(BASS_CONFIG_NET_PREBUF,i);
DBWriteWord(0,PluginName,optPreBuf,sPreBuf);
end;
i:=GetDlgItemInt(Dialog,IDC_BUFFER,ltmp,false);
if i>20000 then i:=20000;
if cardinal(i)<>sBuffer then
begin
sBuffer:=i;
BASS_SetConfig(BASS_CONFIG_NET_BUFFER,i);
DBWriteWord(0,PluginName,optBuffer,sBuffer);
end;
i:=GetDlgItemInt(Dialog,IDC_TIMEOUT,ltmp,false);
if i>30000 then i:=30000;
if cardinal(i)<>sTimeout then
begin
sTimeout:=i;
BASS_SetConfig(BASS_CONFIG_NET_TIMEOUT,i);
DBWriteWord(0,PluginName,optTimeout,sTimeout);
end;
end;
end;
// else
// result:=DefWindowProc(Dialog,hMessage,wParam,lParam);
end;
end;
function OnOptInitialise(wParam:WPARAM;lParam:LPARAM):int;cdecl;
var
odp:TOPTIONSDIALOGPAGE;
begin
FillChar(odp,SizeOf(odp),0);
odp.cbSize :=SizeOf(odp);
odp.flags :=ODPF_BOLDGROUPS;
odp.Position :=900003000;
odp.hInstance :=hInstance;
odp.szGroup.a :='Network';
odp.szTitle.a :=PluginName;
odp.pszTemplate:=MAKEINTRESOURCEA(IDD_SETTING);
odp.pfnDlgProc :=@DlgProcOpt;
odp.szTab.a :='Common';
CallService(MS_OPT_ADDPAGE,wParam,tlparam(@odp));
odp.pszTemplate:=MAKEINTRESOURCEA(IDD_SETTING_TECH);
odp.pfnDlgProc :=@DlgProcOptTech;//!!
odp.szTab.a :=Translate('Advanced');
CallService(MS_OPT_ADDPAGE,wParam,tlparam(@odp));
result:=0;
end;
// checking proto in several places for speed, not size economy
function OnSettingsChanged(wParam:WPARAM;lParam:LPARAM):int;cdecl;
var
buf:array [0..MAX_PATH-1] of AnsiChar;
i:integer;
pc:PAnsiChar;
begin
result:=0;
with PDBCONTACTWRITESETTING(lParam)^ do
begin
if AuMute<>BST_UNCHECKED then
begin
if StrCmp(szModule,'Skin')=0 then
begin
if StrCmp(szSetting,'UseSound')=0 then
begin
// Mute
if value.bVal=0 then
begin
if gVolume>=0 then
Service_RadioMute(0,0);
end
// Unmute
else
begin
if gVolume<0 then
Service_RadioMute(0,0);
end;
end;
exit;
end
end;
// works only if called AFTER changes
if StrCmp(szModule,strCList)=0 then
begin
if StrCmp(szSetting,optMyHandle)=0 then
begin
if value._type=DBVT_DELETED then
begin
if StrCmp(PAnsiChar(CallService(MS_PROTO_GETCONTACTBASEPROTO,wParam,0)),
PluginName)<>0 then exit;
pc:=DBReadString(wParam,PluginName,optNick);
DBWriteString(wParam,strCList,optMyHandle,pc);
mFreeMem(pc);
end;
end;
exit;
end;
if StrCmp(szModule,'UserInfo')<>0 then exit;
if StrCmp(szSetting,optAge)=0 then
begin
if StrCmp(PAnsiChar(CallService(MS_PROTO_GETCONTACTBASEPROTO,wParam,0)),
PluginName)<>0 then exit;
if value._type=DBVT_DELETED then
i:=DBReadWord(wParam,PluginName,optAge)
else
i:=value.wVal;
DBWriteString(wParam,PluginName,optBitrate,IntToStr(buf,i));
exit;
end;
case value._type of
DBVT_DELETED,
DBVT_ASCIIZ ,
DBVT_WCHAR ,
DBVT_UTF8 :
if StrCmp(PAnsiChar(CallService(MS_PROTO_GETCONTACTBASEPROTO,wParam,0)),
PluginName)<>0 then exit;
else
exit;
end;
case value._type of
DBVT_DELETED: pc:=DBReadString(wParam,PluginName,szSetting);
DBVT_ASCIIZ : pc:=value.szVal.a;
DBVT_WCHAR : WideToAnsi(value.szVal.w,pc,MirandaCP);
DBVT_UTF8 : UTF8ToAnsi(value.szVal.a,pc,MirandaCP);
end;
if StrCmp(szSetting,optFirstName)=0 then DBWriteString(wParam,PluginName,optStationURL,pc)
else if StrCmp(szSetting,optNick )=0 then DBWriteString(wParam,strCList,optMyHandle,pc)
else if StrCmp(szSetting,optLastName )=0 then DBWriteString(wParam,PluginName,optGenre,pc);
if value._type<>DBVT_ASCIIZ then
mFreeMem(pc);
end;
end;
function OnContactDeleted(wParam:WPARAM;lParam:LPARAM):int;cdecl;
begin
result:=0;
if ActiveContact<>THANDLE(wParam) then exit;
ControlCenter(MRC_STOP,wParam);
{ if StrCmp(PAnsiChar(CallService(MS_PROTO_GETCONTACTBASEPROTO,wParam,0)),
PluginName)<>0 then exit;
}
end;
|