ViewChannel.pas
32.6 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
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
{ UNIT ViewChannel.pas
--------------------------------- ViewChannel -----------------------------
This unit takes charge of displaying channel window for kMIDIPlayer
Copyright 2011 Silhwan Hyun, All Rights Reserved
Author : Silhwan Hyun (e-mail addr : hyunsh@hanafos.com)
Contibutors
Emil Weiss : Test & Advice for update/debug
Revision History
------------------------------
Ver 0.9.0 9 Feb 2013
- Initial Release
----------------------------------------------------------------------------}
unit ViewChannel;
{$DEFINE MULTI_LANGUAGE}
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, MIDIFile2, MidiPlayer2, Instrument, Buttons,
{$IFDEF MULTI_LANGUAGE}gnugettext,{$ENDIF} AMLed, ExtCtrls, AdvImage, pngimage;
const
WM_ViewChannelConfig = WM_USER + 147;
ViewChannel_Shown = 1;
ViewChannel_Closed = 2;
type
TViewChannelForm = class(TForm)
btnClose: TButton;
AdvImage1: TAdvImage;
chImageBtn1: TAdvImage;
chImageBtn2: TAdvImage;
chImageBtn4: TAdvImage;
chImageBtn3: TAdvImage;
chImageBtn5: TAdvImage;
chImageBtn6: TAdvImage;
chImageBtn8: TAdvImage;
chImageBtn7: TAdvImage;
chImageBtn9: TAdvImage;
chImageBtn10: TAdvImage;
chImageBtn13: TAdvImage;
chImageBtn11: TAdvImage;
chImageBtn12: TAdvImage;
chImageBtn14: TAdvImage;
chImageBtn16: TAdvImage;
chImageBtn15: TAdvImage;
Led_CH1: TLed;
Led_CH2: TLed;
Led_CH4: TLed;
Led_CH3: TLed;
Led_CH8: TLed;
Led_CH7: TLed;
Led_CH6: TLed;
Led_CH5: TLed;
Led_CH16: TLed;
Led_CH15: TLed;
Led_CH14: TLed;
Led_CH13: TLed;
Led_CH12: TLed;
Led_CH11: TLed;
Led_CH10: TLed;
Led_CH9: TLed;
FaderThumb1: TAdvImage;
lblInst1: TLabel;
lblInst2: TLabel;
lblInst3: TLabel;
lblInst4: TLabel;
lblInst7: TLabel;
lblInst8: TLabel;
lblInst6: TLabel;
lblInst5: TLabel;
lblInst15: TLabel;
lblInst16: TLabel;
lblInst14: TLabel;
lblInst13: TLabel;
lblInst12: TLabel;
lblInst11: TLabel;
lblInst10: TLabel;
lblInst9: TLabel;
lblFader1: TLabel;
lblFader2: TLabel;
lblFader3: TLabel;
lblFader4: TLabel;
lblFader7: TLabel;
lblFader8: TLabel;
lblFader6: TLabel;
lblFader5: TLabel;
lblFader15: TLabel;
lblFader16: TLabel;
lblFader14: TLabel;
lblFader13: TLabel;
lblFader12: TLabel;
lblFader11: TLabel;
lblFader10: TLabel;
lblFader9: TLabel;
FaderThumb2: TAdvImage;
FaderThumb3: TAdvImage;
FaderThumb4: TAdvImage;
FaderThumb5: TAdvImage;
FaderThumb6: TAdvImage;
FaderThumb7: TAdvImage;
FaderThumb8: TAdvImage;
FaderThumb9: TAdvImage;
FaderThumb10: TAdvImage;
FaderThumb11: TAdvImage;
FaderThumb12: TAdvImage;
FaderThumb13: TAdvImage;
FaderThumb14: TAdvImage;
FaderThumb15: TAdvImage;
FaderThumb16: TAdvImage;
btn_Solo1: TAdvImage;
btn_Solo2: TAdvImage;
btn_Solo3: TAdvImage;
btn_Solo4: TAdvImage;
btn_Solo5: TAdvImage;
btn_Solo6: TAdvImage;
btn_Solo7: TAdvImage;
btn_Solo8: TAdvImage;
btn_Solo9: TAdvImage;
btn_Solo10: TAdvImage;
btn_Solo11: TAdvImage;
btn_Solo12: TAdvImage;
btn_Solo13: TAdvImage;
btn_Solo14: TAdvImage;
btn_Solo15: TAdvImage;
btn_Solo16: TAdvImage;
FaderGroup: TRadioGroup;
rbDelay: TRadioButton;
rbChorus: TRadioButton;
rbReverb: TRadioButton;
rbExpression: TRadioButton;
rbPan: TRadioButton;
rbVolume: TRadioButton;
DeviceGroup: TRadioGroup;
cbMIDIMode: TComboBox;
btnReset: TButton;
lbl_Mode: TLabel;
lbl_ChNo: TLabel;
lbl_ChState: TLabel;
lbl_Solo: TLabel;
lbl_Act: TLabel;
lbl_Inst: TLabel;
lbl_Fader: TLabel;
lbl_Value: TLabel;
btnAllOn: TButton;
procedure btnCloseClick(Sender: TObject);
procedure btnSolo_NClick(Sender: TObject);
procedure btnAllOnClick(Sender: TObject);
procedure cb_CHNClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure cbMIDIModeChange(Sender: TObject);
procedure rbFaderSelClick(Sender: TObject);
procedure btnResetClick(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure chImageBtnMouseEnter(Sender: TObject);
procedure chImageBtnMouseLeave(Sender: TObject);
procedure chImageBtnMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure chImageBtnMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure FaderThumbMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
private
{ Private declarations }
procedure SetInstrumentName(MIDIMode: TMIDIMode; ChannelNo, Bank, ProgramNo: byte);
procedure SetSlidePos(ChannelNo, FaderVal: byte);
procedure SetFaderVal(ChannelNo, FaderVal: byte; BySlider: boolean);
procedure SetImageBtn(img: TAdvImage);
procedure SetImage(Destination: TAdvImage;
x, y, W, H: integer;
Source: TBitmap;
startX, StartY: integer);
procedure BtnImageLoad(Btn_No : integer; b_Pressed, b_Highlighted : boolean);
public
{ Public declarations }
procedure ResetInstrumentFields;
procedure ResetExpressions;
procedure ResetFields(Reset_Device: boolean);
procedure GetChannelEvent(MidiEvent: TMidiEvent);
procedure SetPlayerChannelState;
end;
var
ViewChannelForm: TViewChannelForm;
implementation
{$R *.dfm}
uses MIDITest;
const
OnInterval = 40;
ThumbLeftPos = 407;
ThumbTravel = 68;
var
BankData: array[1..16] of byte = (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
MapData: array[1..16] of byte = (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
VolumeData: array[1..16] of byte;
PanData: array[1..16] of byte;
ExpressionData: array[1..16] of byte;
ReverbData: array[1..16] of byte;
ChorusData: array[1..16] of byte;
DelayData: array[1..16] of byte;
ChannelState: TChannelState;
MIDI_Mode: TMIDIMode = GS;
MovingSliderNo: integer = 0;
FaderType: TFaderType = fVolume;
Image_Controls: TBitmap;
i_CursorOn: integer = 0;
b_BtnPressed: boolean = false;
CURSOR_HAND: HCURSOR;
NowTracking: boolean = false;
ThumbStartX: integer;
ThumbMouseDownX : integer;
procedure TViewChannelForm.ResetInstrumentFields;
var
I: integer;
begin
for I := 1 to 16 do
begin
BankData[I] := 0;
MapData[I] := 0;
end;
lblInst1.Caption := 'Piano 1';
lblInst2.Caption := 'Piano 1';
lblInst3.Caption := 'Piano 1';
lblInst4.Caption := 'Piano 1';
lblInst5.Caption := 'Piano 1';
lblInst6.Caption := 'Piano 1';
lblInst7.Caption := 'Piano 1';
lblInst8.Caption := 'Piano 1';
lblInst9.Caption := 'Piano 1';
lblInst10.Caption := 'STANDARD 1';
lblInst11.Caption := 'Piano 1';
lblInst12.Caption := 'Piano 1';
lblInst13.Caption := 'Piano 1';
lblInst14.Caption := 'Piano 1';
lblInst15.Caption := 'Piano 1';
lblInst16.Caption := 'Piano 1';
end;
procedure TViewChannelForm.ResetExpressions;
var
I: integer;
begin
for I := 1 to 16 do
begin
ExpressionData[I] := 127;
MainForm.MidiPlayer.SetChannelFader(I - 1, 127, fExpression);
end;
if FaderType = fExpression then
begin
for I := 1 to 16 do
SetSlidePos(I, 127);
lblFader1.Caption := '127';
lblFader2.Caption := '127';
lblFader3.Caption := '127';
lblFader4.Caption := '127';
lblFader5.Caption := '127';
lblFader6.Caption := '127';
lblFader7.Caption := '127';
lblFader8.Caption := '127';
lblFader9.Caption := '127';
lblFader10.Caption := '127';
lblFader11.Caption := '127';
lblFader12.Caption := '127';
lblFader13.Caption := '127';
lblFader14.Caption := '127';
lblFader15.Caption := '127';
lblFader16.Caption := '127';
end;
end;
procedure TViewChannelForm.ResetFields(Reset_Device: boolean);
var
I: integer;
begin
for I := 1 to 16 do
begin
// BankData[I] := 0;
// MapData[I] := 0;
VolumeData[I] := 127;
ExpressionData[I] := 127;
PanData[I] := 64;
ReverbData[I] := 40;
ChorusData[I] := 0;
DelayData[I] := 0;
end;
ResetInstrumentFields;
for I := 0 to Self.ComponentCount - 1 do
if Self.Components[I] is TLabel then
begin
if (Self.Components[I].Tag >= 1) and (Self.Components[I].Tag <= 16) then
begin
if copy(Self.Components[I].Name, 1, 8) = 'lblFader' then
begin
if rbVolume.Checked or rbExpression.Checked then
(Self.Components[I] as TLabel).Caption := '127'
else if rbPan.Checked then
(Self.Components[I] as TLabel).Caption := '64'
else if rbReverb.Checked then
(Self.Components[I] as TLabel).Caption := '40'
else if rbDelay.Checked or rbChorus.Checked then
(Self.Components[I] as TLabel).Caption := '0';
end;
end;
end else
if Self.Components[I] is TAdvImage then
begin
if (Self.Components[I].Tag >= 21) and (Self.Components[I].Tag <= 36) then
begin
if rbVolume.Checked or rbExpression.Checked then
(Self.Components[I] as TAdvImage).Left := ThumbLeftPos + ThumbTravel
else if rbPan.Checked then
(Self.Components[I] as TAdvImage).Left := ThumbLeftPos + round(ThumbTravel * 64 / 127)
else if rbReverb.Checked then
(Self.Components[I] as TAdvImage).Left := ThumbLeftPos + round(ThumbTravel * 40 / 127)
else if rbDelay.Checked or rbChorus.Checked then
(Self.Components[I] as TAdvImage).Left := ThumbLeftPos;
end;
end;
// ListBox1.Clear;
if Reset_Device then
MainForm.MidiPlayer.ResetDevice(MIDI_Mode);
end;
function GetDrumKitName(KitNo: byte): string;
begin
case KitNo of
1 : Result := 'STANDARD 1';
2 : Result := 'STANDARD 2';
3 : Result := 'STANDARD 3';
9 : Result := 'Room';
10 : Result := 'Hip-Hop';
11 : Result := 'Jungle';
12 : Result := 'Techno';
17 : Result := 'Power';
25 : Result := 'Electronic';
26 : Result := 'TR-808';
27 : Result := 'Dance';
28 : Result := 'CR-78';
29 : Result := 'TR-606';
30 : Result := 'TR-707';
31 : Result := 'TR-909';
33 : Result := 'Jazz';
41 : Result := 'Brush';
49 : Result := 'Orchestra';
51 : Result := 'Ethnic';
52 : Result := 'Kick & Snare';
53 : Result := 'Asia';
54 : Result := 'Cymbal & Claps';
57 : Result := 'Sound FX';
58 : Result := 'Rhythm FX 1';
59 : Result := 'Rhythm FX 2';
128 : Result := 'CM-64/CM-32L';
else
Result := 'Unknown Drum Kit (Kit # : ' + intToStr(KitNo) + ')';
end;
end;
procedure TViewChannelForm.SetInstrumentName(MIDIMode: TMIDIMode; ChannelNo, Bank, ProgramNo: byte);
begin
case ChannelNo of
1 : lblInst1.Caption := GetProgramName(MIDIMode, Bank, ProgramNo);
2 : lblInst2.Caption := GetProgramName(MIDIMode, Bank, ProgramNo);
3 : lblInst3.Caption := GetProgramName(MIDIMode, Bank, ProgramNo);
4 : lblInst4.Caption := GetProgramName(MIDIMode, Bank, ProgramNo);
5 : lblInst5.Caption := GetProgramName(MIDIMode, Bank, ProgramNo);
6 : lblInst6.Caption := GetProgramName(MIDIMode, Bank, ProgramNo);
7 : lblInst7.Caption := GetProgramName(MIDIMode, Bank, ProgramNo);
8 : lblInst8.Caption := GetProgramName(MIDIMode, Bank, ProgramNo);
9 : lblInst9.Caption := GetProgramName(MIDIMode, Bank, ProgramNo);
10 : lblInst10.Caption := GetDrumKitName(ProgramNo + 1);
11 : lblInst11.Caption := GetProgramName(MIDIMode, Bank, ProgramNo);
12 : lblInst12.Caption := GetProgramName(MIDIMode, Bank, ProgramNo);
13 : lblInst13.Caption := GetProgramName(MIDIMode, Bank, ProgramNo);
14 : lblInst14.Caption := GetProgramName(MIDIMode, Bank, ProgramNo);
15 : lblInst15.Caption := GetProgramName(MIDIMode, Bank, ProgramNo);
16 : lblInst16.Caption := GetProgramName(MIDIMode, Bank, ProgramNo);
end;
end;
procedure TViewChannelForm.SetSlidePos(ChannelNo, FaderVal: byte);
begin
case ChannelNo of
1 : FaderThumb1.Left := ThumbLeftPos + round(ThumbTravel * FaderVal / 127);
2 : FaderThumb2.Left := ThumbLeftPos + round(ThumbTravel * FaderVal / 127);
3 : FaderThumb3.Left := ThumbLeftPos + round(ThumbTravel * FaderVal / 127);
4 : FaderThumb4.Left := ThumbLeftPos + round(ThumbTravel * FaderVal / 127);
5 : FaderThumb5.Left := ThumbLeftPos + round(ThumbTravel * FaderVal / 127);
6 : FaderThumb6.Left := ThumbLeftPos + round(ThumbTravel * FaderVal / 127);
7 : FaderThumb7.Left := ThumbLeftPos + round(ThumbTravel * FaderVal / 127);
8 : FaderThumb8.Left := ThumbLeftPos + round(ThumbTravel * FaderVal / 127);
9 : FaderThumb9.Left := ThumbLeftPos + round(ThumbTravel * FaderVal / 127);
10 : FaderThumb10.Left := ThumbLeftPos + round(ThumbTravel * FaderVal / 127);
11 : FaderThumb11.Left := ThumbLeftPos + round(ThumbTravel * FaderVal / 127);
12 : FaderThumb12.Left := ThumbLeftPos + round(ThumbTravel * FaderVal / 127);
13 : FaderThumb13.Left := ThumbLeftPos + round(ThumbTravel * FaderVal / 127);
14 : FaderThumb14.Left := ThumbLeftPos + round(ThumbTravel * FaderVal / 127);
15 : FaderThumb15.Left := ThumbLeftPos + round(ThumbTravel * FaderVal / 127);
16 : FaderThumb16.Left := ThumbLeftPos + round(ThumbTravel * FaderVal / 127);
end;
end;
procedure TViewChannelForm.SetFaderVal(ChannelNo, FaderVal: byte; BySlider: boolean);
begin
case ChannelNo of
1 : lblFader1.Caption := intToStr(FaderVal);
2 : lblFader2.Caption := intToStr(FaderVal);
3 : lblFader3.Caption := intToStr(FaderVal);
4 : lblFader4.Caption := intToStr(FaderVal);
5 : lblFader5.Caption:= intToStr(FaderVal);
6 : lblFader6.Caption:= intToStr(FaderVal);
7 : lblFader7.Caption := intToStr(FaderVal);
8 : lblFader8.Caption := intToStr(FaderVal);
9 : lblFader9.Caption := intToStr(FaderVal);
10 : lblFader10.Caption := intToStr(FaderVal);
11 : lblFader11.Caption := intToStr(FaderVal);
12 : lblFader12.Caption := intToStr(FaderVal);
13 : lblFader13.Caption := intToStr(FaderVal);
14 : lblFader14.Caption := intToStr(FaderVal);
15 : lblFader15.Caption := intToStr(FaderVal);
16 : lblFader16.Caption := intToStr(FaderVal);
end;
case FaderType of
fVolume : VolumeData[ChannelNo] := FaderVal;
fPan : PanData[ChannelNo] := FaderVal;
fExpression : ExpressionData[ChannelNo] := FaderVal;
fReverb : ReverbData[ChannelNo] := FaderVal;
fChorus : ChorusData[ChannelNo] := FaderVal;
fDelay : DelayData[ChannelNo] := FaderVal;
end;
if not BySlider then
SetSlidePos(ChannelNo, FaderVal);
end;
procedure TViewChannelForm.SetPlayerChannelState;
begin
MainForm.MidiPlayer.ChannelState := ChannelState;
end;
procedure TViewChannelForm.btnAllOnClick(Sender: TObject);
var
I: integer;
begin
for I := 0 to 15 do
begin
ChannelState[I] := true;
BtnImageLoad(I+1, false, false);
end;
SetPlayerChannelState;
end;
procedure TViewChannelForm.btnCloseClick(Sender: TObject);
begin
Close;
end;
procedure TViewChannelForm.btnResetClick(Sender: TObject);
begin
ResetFields(true);
end;
procedure TViewChannelForm.btnSolo_NClick(Sender: TObject);
var
BtnNo: integer;
I: integer;
begin
BtnNo := (Sender as TAdvImage).Tag;
if BtnNo = 41 then ChannelState[0] := true else ChannelState[0] := false;
if BtnNo = 42 then ChannelState[1] := true else ChannelState[1] := false;
if BtnNo = 43 then ChannelState[2] := true else ChannelState[2] := false;
if BtnNo = 44 then ChannelState[3] := true else ChannelState[3] := false;
if BtnNo = 45 then ChannelState[4] := true else ChannelState[4] := false;
if BtnNo = 46 then ChannelState[5] := true else ChannelState[5] := false;
if BtnNo = 47 then ChannelState[6] := true else ChannelState[6] := false;
if BtnNo = 48 then ChannelState[7] := true else ChannelState[7] := false;
if BtnNo = 49 then ChannelState[8] := true else ChannelState[8] := false;
if BtnNo = 50 then ChannelState[9] := true else ChannelState[9] := false;
if BtnNo = 51 then ChannelState[10] := true else ChannelState[10] := false;
if BtnNo = 52 then ChannelState[11] := true else ChannelState[11] := false;
if BtnNo = 53 then ChannelState[12] := true else ChannelState[12] := false;
if BtnNo = 54 then ChannelState[13] := true else ChannelState[13] := false;
if BtnNo = 55 then ChannelState[14] := true else ChannelState[14] := false;
if BtnNo = 56 then ChannelState[15] := true else ChannelState[15] := false;
for I := 1 to 16 do
BtnImageLoad(I, false, false);
SetPlayerChannelState;
end;
procedure TViewChannelForm.cb_CHNClick(Sender: TObject);
begin
BtnImageLoad((Sender as TSpeedButton).Tag, false, false);
SetPlayerChannelState;
end;
procedure TViewChannelForm.SetImageBtn(img: TAdvImage);
begin
{ img.OnMouseEnter := ImageMouseEnter;
img.OnMouseLeave := ImageMouseLeave; }
img.Picture.Bitmap.Width := img.Width;
img.Picture.Bitmap.Height := img.Height;
end;
procedure TViewChannelForm.SetImage(Destination: TAdvImage;
x, y, W, H: integer;
Source: TBitmap;
startX, StartY: integer);
var
DestDC: HDC;
SrcDC: HDC;
begin
DestDC := Destination.Picture.Bitmap.Canvas.Handle;
SrcDC := Source.Canvas.Handle;
BitBlt(DestDC, x, y, W, H, SrcDC, startX, StartY, SRCCOPY);
Destination.Refresh;
end;
procedure TViewChannelForm.BtnImageLoad(Btn_No : integer; b_Pressed, b_Highlighted : boolean);
procedure SetImage2(Dest_No: integer;
x, y, W, H: integer;
Source: TBitmap;
StartX, StartY: integer);
begin
case Dest_No of
1: SetImage(chImageBtn1, x, y, w, h, Source, startX, StartY);
2: SetImage(chImageBtn2, x, y, w, h, Source, startX, StartY);
3: SetImage(chImageBtn3, x, y, w, h, Source, startX, StartY);
4: SetImage(chImageBtn4, x, y, w, h, Source, startX, StartY);
5: SetImage(chImageBtn5, x, y, w, h, Source, startX, StartY);
6: SetImage(chImageBtn6, x, y, w, h, Source, startX, StartY);
7: SetImage(chImageBtn7, x, y, w, h, Source, startX, StartY);
8: SetImage(chImageBtn8, x, y, w, h, Source, startX, StartY);
9: SetImage(chImageBtn9, x, y, w, h, Source, startX, StartY);
10: SetImage(chImageBtn10, x, y, w, h, Source, startX, StartY);
11: SetImage(chImageBtn11, x, y, w, h, Source, startX, StartY);
12: SetImage(chImageBtn12, x, y, w, h, Source, startX, StartY);
13: SetImage(chImageBtn13, x, y, w, h, Source, startX, StartY);
14: SetImage(chImageBtn14, x, y, w, h, Source, startX, StartY);
15: SetImage(chImageBtn15, x, y, w, h, Source, startX, StartY);
16: SetImage(chImageBtn16, x, y, w, h, Source, startX, StartY);
41: SetImage(btn_Solo1, x, y, w, h, Source, startX, StartY);
42: SetImage(btn_Solo2, x, y, w, h, Source, startX, StartY);
43: SetImage(btn_Solo3, x, y, w, h, Source, startX, StartY);
44: SetImage(btn_Solo4, x, y, w, h, Source, startX, StartY);
45: SetImage(btn_Solo5, x, y, w, h, Source, startX, StartY);
46: SetImage(btn_Solo6, x, y, w, h, Source, startX, StartY);
47: SetImage(btn_Solo7, x, y, w, h, Source, startX, StartY);
48: SetImage(btn_Solo8, x, y, w, h, Source, startX, StartY);
49: SetImage(btn_Solo9, x, y, w, h, Source, startX, StartY);
50: SetImage(btn_Solo10, x, y, w, h, Source, startX, StartY);
51: SetImage(btn_Solo11, x, y, w, h, Source, startX, StartY);
52: SetImage(btn_Solo12, x, y, w, h, Source, startX, StartY);
53: SetImage(btn_Solo13, x, y, w, h, Source, startX, StartY);
54: SetImage(btn_Solo14, x, y, w, h, Source, startX, StartY);
55: SetImage(btn_Solo15, x, y, w, h, Source, startX, StartY);
56: SetImage(btn_Solo16, x, y, w, h, Source, startX, StartY);
end;
end;
begin
case Btn_No of
1..16 : if b_Pressed then
begin
if ChannelState[Btn_No-1] then
SetImage2(Btn_No, 0, 0, 43, 16, Image_Controls, 0, 51)
else
SetImage2(Btn_No, 0, 0, 43, 16, Image_Controls, 0, 17)
end else
if b_Highlighted then
begin
if ChannelState[Btn_No-1] then
SetImage2(Btn_No, 0, 0, 43, 16, Image_Controls, 0, 85)
else
SetImage2(Btn_No, 0, 0, 43, 16, Image_Controls, 0, 68);
end else
begin
if ChannelState[Btn_No-1] then
SetImage2(Btn_No, 0, 0, 43, 16, Image_Controls, 0, 34)
else
SetImage2(Btn_No, 0, 0, 43, 16, Image_Controls, 0, 0);
end;
41..56 : if b_Pressed then
SetImage2(Btn_No, 0, 0, 27, 16, Image_Controls, 100, 70)
else if b_Highlighted then
SetImage2(Btn_No, 0, 0, 27, 16, Image_Controls, 72, 70)
else
SetImage2(Btn_No, 0, 0, 27, 16, Image_Controls, 44, 70);
end;
end;
procedure TViewChannelForm.chImageBtnMouseLeave(Sender: TObject);
begin
if (Sender as TComponent).Tag = i_CursorOn then
i_CursorOn := 0;
{ if b_BtnPressed then
b_BtnPressed := false; }
BtnImageLoad((Sender as TComponent).Tag, false, false);
if b_BtnPressed then
b_BtnPressed := false;
end;
procedure TViewChannelForm.chImageBtnMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
b_BtnPressed := false;
ReleaseCapture;
if (Sender as TComponent).Tag = i_CursorOn then
begin
if ((Sender as TAdvImage).Tag >= 1) and ((Sender as TAdvImage).Tag <= 16) then
begin
ChannelState[(Sender as TComponent).Tag - 1] := not ChannelState[(Sender as TComponent).Tag - 1];
SetPlayerChannelState;
end;
BtnImageLoad((Sender as TComponent).Tag, false, true);
end else
BtnImageLoad((Sender as TComponent).Tag, false, false);
case (Sender as TComponent).Tag of
21..36 : NowTracking := false;
41..56 : btnSolo_NClick(Sender);
end;
end;
procedure TViewChannelForm.chImageBtnMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
CurCursor: HCURSOR;
m_point: TPoint;
begin
if not (ssLeft in Shift) then
exit;
b_BtnPressed := true;
SetCapture(Self.Handle);
BtnImageLoad((Sender as TComponent).Tag, true, false);
case (Sender as TComponent).Tag of
21..36 : begin
NowTracking := true;
CurCursor := GetCursor;
if CurCursor <> CURSOR_HAND then
SetCursor(CURSOR_HAND);
GetCursorPos(m_point);
ThumbStartX := (Sender as TControl).Left;
ThumbMouseDownX := m_point.X;
end;
end;
if i_CursorOn <>(Sender as TComponent).Tag then // for the case of no response
i_CursorOn :=(Sender as TComponent).Tag;
end;
procedure TViewChannelForm.chImageBtnMouseEnter(Sender: TObject);
begin
i_CursorOn := (Sender as TComponent).Tag;
if b_BtnPressed then
exit;
BtnImageLoad((Sender as TComponent).Tag, false, true);
end;
procedure TViewChannelForm.cbMIDIModeChange(Sender: TObject);
begin
if cbMIDIMode.Text = 'GS' then
begin
MIDI_Mode := GS;
MainForm.MidiPlayer.GM2_OnOff(false);
end else if cbMIDIMode.Text = 'GM2' then
begin
MIDI_Mode := GM2;
MainForm.MidiPlayer.GM2_OnOff(true);
end;
ResetFields(false);
end;
procedure TViewChannelForm.FaderThumbMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
var
CurCursor : HCURSOR;
diffX, NewPosX : integer;
m_point : TPoint;
ThumbNum : integer;
SlideValue: integer;
begin
CurCursor := GetCursor;
if CurCursor <> CURSOR_HAND then
begin
SetCursor(CURSOR_HAND);
// OrgCursor := CurCursor;
end;
if not NowTracking then
exit;
GetCursorPos(m_point);
diffX := (m_point.X) - ThumbMouseDownX;
if diffX <= 0 then
begin
if (Sender as TControl).Left > ThumbLeftPos then //
begin
NewPosX := ThumbStartX + diffX;
if NewPosX < ThumbLeftPos then
NewPosX := ThumbLeftPos;
(Sender as TControl).Left := NewPosX;
end;
end else
if (Sender as TControl).Left < (ThumbLeftPos + ThumbTravel) then
begin
NewPosX := ThumbStartX + diffX;
if NewPosX > (ThumbLeftPos + ThumbTravel) then
NewPosX := (ThumbLeftPos + ThumbTravel);
(Sender as TControl).Left := NewPosX;
end;
ThumbNum := (Sender as TComponent).Tag - 20;
SlideValue := round(((Sender as TControl).Left - ThumbLeftPos) / ThumbTravel * 127);
MainForm.MidiPlayer.SetChannelFader(ThumbNum - 1, SlideValue, FaderType);
SetFaderVal(ThumbNum, SlideValue, true{BySlider});
end;
procedure TViewChannelForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
PostMessage(MainForm.Handle, WM_ViewChannelConfig, ViewChannel_Closed, 0);
end;
procedure TViewChannelForm.FormCreate(Sender: TObject);
var
I: integer;
begin
{$IFDEF MULTI_LANGUAGE}
TranslateComponent(self);
if GetOEMCP = 949 then // Korean Language ?
begin
lbl_ChNo.Font.Name := '';
lbl_ChState.Font.Name := '';
lbl_ChState.Left := 53;
lbl_Solo.Font.Name := '';
lbl_Act.Font.Name := '';
lbl_Inst.Font.Name := '';
lbl_Value.Font.Name := '';
lbl_Value.Left := 362;
lbl_Fader.Top := 11;
FaderGroup.Font.Name := '';
DeviceGroup.Font.Name := '';
lbl_Mode.Font.Name := '';
end;
{$ENDIF}
Image_Controls := TBitmap.Create;
Image_Controls.LoadFromResourceName(HInstance, 'BUTTONS');
ChannelState := MainForm.MidiPlayer.ChannelState;
SetImageBtn(chImageBtn1);
SetImageBtn(chImageBtn2);
SetImageBtn(chImageBtn3);
SetImageBtn(chImageBtn4);
SetImageBtn(chImageBtn5);
SetImageBtn(chImageBtn6);
SetImageBtn(chImageBtn7);
SetImageBtn(chImageBtn8);
SetImageBtn(chImageBtn9);
SetImageBtn(chImageBtn10);
SetImageBtn(chImageBtn11);
SetImageBtn(chImageBtn12);
SetImageBtn(chImageBtn13);
SetImageBtn(chImageBtn14);
SetImageBtn(chImageBtn15);
SetImageBtn(chImageBtn16);
SetImageBtn(btn_Solo1);
SetImageBtn(btn_Solo2);
SetImageBtn(btn_Solo3);
SetImageBtn(btn_Solo4);
SetImageBtn(btn_Solo5);
SetImageBtn(btn_Solo6);
SetImageBtn(btn_Solo7);
SetImageBtn(btn_Solo8);
SetImageBtn(btn_Solo9);
SetImageBtn(btn_Solo10);
SetImageBtn(btn_Solo11);
SetImageBtn(btn_Solo12);
SetImageBtn(btn_Solo13);
SetImageBtn(btn_Solo14);
SetImageBtn(btn_Solo15);
SetImageBtn(btn_Solo16);
for I := 1 to 16 do
BtnImageLoad(I, false, false);
for I := 41 to 56 do
BtnImageLoad(I, false, false);
CURSOR_HAND := LoadCursor(hInstance, 'HAND_CURSOR');
end;
procedure TViewChannelForm.FormDestroy(Sender: TObject);
begin
Image_Controls.Free;
end;
procedure TViewChannelForm.FormShow(Sender: TObject);
begin
PostMessage(MainForm.Handle, WM_ViewChannelConfig, ViewChannel_Shown, 0);
if MIDI_Mode = GS then
cbMIDIMode.ItemIndex := 1
else if MIDI_Mode = GM2 then
cbMIDIMode.ItemIndex := 0;
end;
procedure TViewChannelForm.GetChannelEvent(MidiEvent: TMidiEvent);
var
EventNo: byte;
ChannelNo: byte;
begin
EventNo := (MidiEvent.Event and $F0);
ChannelNo := (MidiEvent.Event and $0F) + 1;
case EventNo of
$B0 : if MidiEvent.Data1 = 0 then // Bank Select coarse
BankData[ChannelNo] := MidiEvent.Data2
else if MidiEvent.Data1 = 32 then // Bank Select fine
MapData[ChannelNo] := MidiEvent.Data2
// 7 : Volume, 10 : Pan, 11 : Expression, 91 : Reverb, 93 : Chorus, 94 : Delay
else if (MidiEvent.Data1 = 7) or (MidiEvent.Data1 = 10) or (MidiEvent.Data1 = 11) or
(MidiEvent.Data1 = 91) or (MidiEvent.Data1 = 93) or (MidiEvent.Data1 = 94) then
begin
if (rbVolume.Checked and (MidiEvent.Data1 = 7)) or
(rbPan.Checked and (MidiEvent.Data1 = 10)) or
(rbExpression.Checked and (MidiEvent.Data1 = 11)) or
(rbReverb.Checked and (MidiEvent.Data1 = 91)) or
(rbChorus.Checked and (MidiEvent.Data1 = 93)) or
(rbDelay.Checked and (MidiEvent.Data1 = 94)) then
SetFaderVal(ChannelNo, MidiEvent.Data2, false)
else
case MidiEvent.Data1 of
7 : VolumeData[ChannelNo] := MidiEvent.Data2;
10 : PanData[ChannelNo] := MidiEvent.Data2;
11 : ExpressionData[ChannelNo] := MidiEvent.Data2;
91 : ReverbData[ChannelNo] := MidiEvent.Data2;
93 : ChorusData[ChannelNo] := MidiEvent.Data2;
94 : DelayData[ChannelNo] := MidiEvent.Data2;
end;
end;
$C0 : if MIDI_Mode = GS then
SetInstrumentName(MIDI_Mode, ChannelNo, BankData[ChannelNo], MidiEvent.Data1)
else if MIDI_Mode = GM2 then
if (BankData[ChannelNo] = 120) and (MapData[ChannelNo] = 0) then // It's a drum kit ?
begin
case ChannelNo of
1 : lblInst1.Caption := GetDrumKitName(MidiEvent.Data1 + 1);
2 : lblInst2.Caption := GetDrumKitName(MidiEvent.Data1 + 1);
3 : lblInst3.Caption := GetDrumKitName(MidiEvent.Data1 + 1);
4 : lblInst4.Caption := GetDrumKitName(MidiEvent.Data1 + 1);
5 : lblInst5.Caption := GetDrumKitName(MidiEvent.Data1 + 1);
6 : lblInst6.Caption := GetDrumKitName(MidiEvent.Data1 + 1);
7 : lblInst7.Caption := GetDrumKitName(MidiEvent.Data1 + 1);
8 : lblInst8.Caption := GetDrumKitName(MidiEvent.Data1 + 1);
9 : lblInst9.Caption := GetDrumKitName(MidiEvent.Data1 + 1);
10 : lblInst10.Caption := GetDrumKitName(MidiEvent.Data1 + 1);
11 : lblInst11.Caption := GetDrumKitName(MidiEvent.Data1 + 1);
12 : lblInst12.Caption := GetDrumKitName(MidiEvent.Data1 + 1);
13 : lblInst13.Caption := GetDrumKitName(MidiEvent.Data1 + 1);
14 : lblInst14.Caption := GetDrumKitName(MidiEvent.Data1 + 1);
15 : lblInst15.Caption := GetDrumKitName(MidiEvent.Data1 + 1);
16 : lblInst16.Caption := GetDrumKitName(MidiEvent.Data1 + 1);
end;
end else {if (BankData[ChannelNo] = 121) then }
SetInstrumentName(MIDI_Mode, ChannelNo, MapData[ChannelNo], MidiEvent.Data1)
{ else
SetInstrumentName(MIDI_Mode, ChannelNo, BankData[ChannelNo], MidiEvent.Data1)};
end;
if (EventNo >= $80) and (EventNo <= $E0) then
case ChannelNo of
1 : Led_CH1.Blink(OnInterval);
2 : Led_CH2.Blink(OnInterval);
3 : Led_CH3.Blink(OnInterval);
4 : Led_CH4.Blink(OnInterval);
5 : Led_CH5.Blink(OnInterval);
6 : Led_CH6.Blink(OnInterval);
7 : Led_CH7.Blink(OnInterval);
8 : Led_CH8.Blink(OnInterval);
9 : Led_CH9.Blink(OnInterval);
10 : Led_CH10.Blink(OnInterval);
11 : Led_CH11.Blink(OnInterval);
12 : Led_CH12.Blink(OnInterval);
13 : Led_CH13.Blink(OnInterval);
14 : Led_CH14.Blink(OnInterval);
15 : Led_CH15.Blink(OnInterval);
16 : Led_CH16.Blink(OnInterval);
end;
end;
procedure TViewChannelForm.rbFaderSelClick(Sender: TObject);
var
I: integer;
FaderData: array[1..16] of byte;
begin
if rbVolume.Checked then begin
FaderType := fVolume;
for I := 1 to 16 do
FaderData[I] := VolumeData[I];
end else if rbPan.Checked then begin
FaderType := fPan;
for I := 1 to 16 do
FaderData[I] := PanData[I];
end else if rbExpression.Checked then begin
FaderType := fExpression;
for I := 1 to 16 do
FaderData[I] := ExpressionData[I];
end else if rbReverb.Checked then begin
FaderType := fReverb;
for I := 1 to 16 do
FaderData[I] := ReverbData[I];
end else if rbChorus.Checked then begin
FaderType := fChorus;
for I := 1 to 16 do
FaderData[I] := ChorusData[I];
end else if rbDelay.Checked then begin
FaderType := fDelay;
for I := 1 to 16 do
FaderData[I] := DelayData[I];
end;
for I := 1 to 16 do
SetSlidePos(I, FaderData[I]);
lblFader1.Caption := intToStr(FaderData[1]);
lblFader2.Caption := intToStr(FaderData[2]);
lblFader3.Caption := intToStr(FaderData[3]);
lblFader4.Caption := intToStr(FaderData[4]);
lblFader5.Caption := intToStr(FaderData[5]);
lblFader6.Caption := intToStr(FaderData[6]);
lblFader7.Caption := intToStr(FaderData[7]);
lblFader8.Caption := intToStr(FaderData[8]);
lblFader9.Caption := intToStr(FaderData[9]);
lblFader10.Caption := intToStr(FaderData[10]);
lblFader11.Caption := intToStr(FaderData[11]);
lblFader12.Caption := intToStr(FaderData[12]);
lblFader13.Caption := intToStr(FaderData[13]);
lblFader14.Caption := intToStr(FaderData[14]);
lblFader15.Caption := intToStr(FaderData[15]);
lblFader16.Caption := intToStr(FaderData[16]);
end;
end.