/
qtractorMidiEditor.cpp
5461 lines (4662 loc) · 155 KB
/
qtractorMidiEditor.cpp
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
// qtractorMidiEditor.cpp
//
/****************************************************************************
Copyright (C) 2005-2019, rncbc aka Rui Nuno Capela. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*****************************************************************************/
#include "qtractorAbout.h"
#include "qtractorMidiEditor.h"
#include "qtractorMidiEditList.h"
#include "qtractorMidiEditTime.h"
#include "qtractorMidiEditView.h"
#include "qtractorMidiEditEvent.h"
#include "qtractorMidiThumbView.h"
#include "qtractorMidiEditCommand.h"
#include "qtractorMidiEngine.h"
#include "qtractorMidiClip.h"
#include "qtractorMidiToolsForm.h"
#include "qtractorInstrument.h"
#include "qtractorRubberBand.h"
#include "qtractorTimeScale.h"
#include "qtractorSession.h"
#include "qtractorOptions.h"
#include <QApplication>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QCloseEvent>
#include <QPixmap>
#include <QFrame>
#include <QIcon>
#include <QPainter>
#include <QFileInfo>
#include <QDir>
#include <QComboBox>
#include <QToolTip>
// Translatable macro contextualizer.
#undef _TR
#define _TR(x) QT_TR_NOOP(x)
// Follow-playhead: maximum iterations on hold.
#define QTRACTOR_SYNC_VIEW_HOLD 46
// An double-dash string reference (formerly empty blank).
static QString g_sDashes = "--";
//----------------------------------------------------------------------------
// MIDI Note Names - Default note names hash map.
static struct
{
unsigned char note;
const char *name;
} g_aNoteNames[] = {
// Diatonic note map...
{ 0, _TR("C") },
{ 1, _TR("C#/Db") },
{ 2, _TR("D") },
{ 3, _TR("D#/Eb") },
{ 4, _TR("E") },
{ 5, _TR("F") },
{ 6, _TR("F#/Gb") },
{ 7, _TR("G") },
{ 8, _TR("G#/Ab") },
{ 9, _TR("A") },
{ 10, _TR("A#/Bb") },
{ 11, _TR("B") },
// GM Drum note map...
{ 35, _TR("Acoustic Bass Drum") },
{ 36, _TR("Bass Drum 1") },
{ 37, _TR("Side Stick") },
{ 38, _TR("Acoustic Snare") },
{ 39, _TR("Hand Clap") },
{ 40, _TR("Electric Snare") },
{ 41, _TR("Low Floor Tom") },
{ 42, _TR("Closed Hi-Hat") },
{ 43, _TR("High Floor Tom") },
{ 44, _TR("Pedal Hi-Hat") },
{ 45, _TR("Low Tom") },
{ 46, _TR("Open Hi-Hat") },
{ 47, _TR("Low-Mid Tom") },
{ 48, _TR("Hi-Mid Tom") },
{ 49, _TR("Crash Cymbal 1") },
{ 50, _TR("High Tom") },
{ 51, _TR("Ride Cymbal 1") },
{ 52, _TR("Chinese Cymbal") },
{ 53, _TR("Ride Bell") },
{ 54, _TR("Tambourine") },
{ 55, _TR("Splash Cymbal") },
{ 56, _TR("Cowbell") },
{ 57, _TR("Crash Cymbal 2") },
{ 58, _TR("Vibraslap") },
{ 59, _TR("Ride Cymbal 2") },
{ 60, _TR("Hi Bongo") },
{ 61, _TR("Low Bongo") },
{ 62, _TR("Mute Hi Conga") },
{ 63, _TR("Open Hi Conga") },
{ 64, _TR("Low Conga") },
{ 65, _TR("High Timbale") },
{ 66, _TR("Low Timbale") },
{ 67, _TR("High Agogo") },
{ 68, _TR("Low Agogo") },
{ 69, _TR("Cabasa") },
{ 70, _TR("Maracas") },
{ 71, _TR("Short Whistle") },
{ 72, _TR("Long Whistle") },
{ 73, _TR("Short Guiro") },
{ 74, _TR("Long Guiro") },
{ 75, _TR("Claves") },
{ 76, _TR("Hi Wood Block") },
{ 77, _TR("Low Wood Block") },
{ 78, _TR("Mute Cuica") },
{ 79, _TR("Open Cuica") },
{ 80, _TR("Mute Triangle") },
{ 81, _TR("Open Triangle") },
{ 0, nullptr }
};
static QHash<unsigned char, QString> g_noteNames;
// Default note name map accessor.
const QString qtractorMidiEditor::defaultNoteName (
unsigned char note, bool fDrums )
{
if (fDrums) {
// Pre-load drum-names hash table...
if (g_noteNames.isEmpty()) {
for (int i = 12; g_aNoteNames[i].name; ++i) {
g_noteNames.insert(g_aNoteNames[i].note,
QObject::tr(g_aNoteNames[i].name, "noteName"));
}
}
// Check whether the drum note exists...
QHash<unsigned char, QString>::ConstIterator iter
= g_noteNames.constFind(note);
if (iter != g_noteNames.constEnd())
return iter.value();
}
return QObject::tr(g_aNoteNames[note % 12].name, "noteName")
+ QString::number((note / 12) - 1);
}
//----------------------------------------------------------------------------
// MIDI Controller Names - Default controller names hash map.
static struct
{
unsigned char controller;
const char *name;
} g_aControllerNames[] = {
{ 0, _TR("Bank Select (coarse)") },
{ 1, _TR("Modulation Wheel (coarse)") },
{ 2, _TR("Breath Controller (coarse)") },
{ 4, _TR("Foot Pedal (coarse)") },
{ 5, _TR("Portamento Time (coarse)") },
{ 6, _TR("Data Entry (coarse)") },
{ 7, _TR("Volume (coarse)") },
{ 8, _TR("Balance (coarse)") },
{ 10, _TR("Pan Position (coarse)") },
{ 11, _TR("Expression (coarse)") },
{ 12, _TR("Effect Control 1 (coarse)") },
{ 13, _TR("Effect Control 2 (coarse)") },
{ 16, _TR("General Purpose Slider 1") },
{ 17, _TR("General Purpose Slider 2") },
{ 18, _TR("General Purpose Slider 3") },
{ 19, _TR("General Purpose Slider 4") },
{ 32, _TR("Bank Select (fine)") },
{ 33, _TR("Modulation Wheel (fine)") },
{ 34, _TR("Breath Controller (fine)") },
{ 36, _TR("Foot Pedal (fine)") },
{ 37, _TR("Portamento Time (fine)") },
{ 38, _TR("Data Entry (fine)") },
{ 39, _TR("Volume (fine)") },
{ 40, _TR("Balance (fine)") },
{ 42, _TR("Pan Position (fine)") },
{ 43, _TR("Expression (fine)") },
{ 44, _TR("Effect Control 1 (fine)") },
{ 45, _TR("Effect Control 2 (fine)") },
{ 64, _TR("Hold Pedal (on/off)") },
{ 65, _TR("Portamento (on/off)") },
{ 66, _TR("Sustenuto Pedal (on/off)") },
{ 67, _TR("Soft Pedal (on/off)") },
{ 68, _TR("Legato Pedal (on/off)") },
{ 69, _TR("Hold 2 Pedal (on/off)") },
{ 70, _TR("Sound Variation") },
{ 71, _TR("Sound Timbre") },
{ 72, _TR("Sound Release Time") },
{ 73, _TR("Sound Attack Time") },
{ 74, _TR("Sound Brightness") },
{ 75, _TR("Sound Control 6") },
{ 76, _TR("Sound Control 7") },
{ 77, _TR("Sound Control 8") },
{ 78, _TR("Sound Control 9") },
{ 79, _TR("Sound Control 10") },
{ 80, _TR("General Purpose Button 1 (on/off)") },
{ 81, _TR("General Purpose Button 2 (on/off)") },
{ 82, _TR("General Purpose Button 3 (on/off)") },
{ 83, _TR("General Purpose Button 4 (on/off)") },
{ 91, _TR("Effects Level") },
{ 92, _TR("Tremulo Level") },
{ 93, _TR("Chorus Level") },
{ 94, _TR("Celeste Level") },
{ 95, _TR("Phaser Level") },
{ 96, _TR("Data Button Increment") },
{ 97, _TR("Data Button Decrement") },
{ 98, _TR("Non-Registered Parameter (fine)") },
{ 99, _TR("Non-Registered Parameter (coarse)") },
{100, _TR("Registered Parameter (fine)") },
{101, _TR("Registered Parameter (coarse)") },
{120, _TR("All Sound Off") },
{121, _TR("All Controllers Off") },
{122, _TR("Local Keyboard (on/off)") },
{123, _TR("All Notes Off") },
{124, _TR("Omni Mode Off") },
{125, _TR("Omni Mode On") },
{126, _TR("Mono Operation") },
{127, _TR("Poly Operation") },
{ 0, nullptr }
};
static QHash<unsigned char, QString> g_controllerNames;
// Default controller name accessor.
const QString& qtractorMidiEditor::defaultControllerName ( unsigned char controller )
{
if (g_controllerNames.isEmpty()) {
// Pre-load controller-names hash table...
for (int i = 0; g_aControllerNames[i].name; ++i) {
g_controllerNames.insert(g_aControllerNames[i].controller,
QObject::tr(g_aControllerNames[i].name, "controllerName"));
}
}
QHash<unsigned char, QString>::ConstIterator iter
= g_controllerNames.constFind(controller);
if (iter == g_controllerNames.constEnd())
return g_sDashes;
else
return iter.value();
}
//----------------------------------------------------------------------------
// MIDI RPN Names - Default RPN names hash map.
static struct
{
unsigned short param;
const char *name;
} g_aRpnNames[] = {
{ 0, _TR("Pitch Bend Sensitivity") },
{ 1, _TR("Fine Tune") },
{ 2, _TR("Coarse Tune") },
{ 3, _TR("Tuning Program") },
{ 4, _TR("Tuning Bank") },
{ 0, nullptr }
};
static QMap<unsigned short, QString> g_rpnNames;
// Default RPN map accessor.
const QMap<unsigned short, QString>& qtractorMidiEditor::defaultRpnNames (void)
{
if (g_rpnNames.isEmpty()) {
// Pre-load RPN-names hash table...
for (int i = 0; g_aRpnNames[i].name; ++i) {
g_rpnNames.insert(g_aRpnNames[i].param,
QObject::tr(g_aRpnNames[i].name, "rpnName"));
}
}
return g_rpnNames;
}
//----------------------------------------------------------------------------
// MIDI NRPN Names - Default NRPN names hash map.
static struct
{
unsigned short param;
const char *name;
} g_aNrpnNames[] = {
{ 136, _TR("Vibrato Rate") },
{ 137, _TR("Vibrato Depth") },
{ 138, _TR("Vibrato Delay") },
{ 160, _TR("Filter Cutoff") },
{ 161, _TR("Filter Resonance") },
{ 227, _TR("EG Attack") },
{ 228, _TR("EG Decay") },
{ 230, _TR("EG Release") },
// GS Drum NRPN map...
{ 2560, _TR("Drum Filter Cutoff") },
{ 2688, _TR("Drum Filter Resonance") },
{ 2816, _TR("Drum EG Attack") },
{ 2944, _TR("Drum EG Decay") },
{ 3072, _TR("Drum Pitch Coarse") },
{ 3200, _TR("Drum Pitch Fine") },
{ 3328, _TR("Drum Level") },
{ 3584, _TR("Drum Pan") },
{ 3712, _TR("Drum Reverb Send") },
{ 3840, _TR("Drum Chorus Send") },
{ 3968, _TR("Drum Variation Send") },
{ 0, nullptr }
};
static QMap<unsigned short, QString> g_nrpnNames;
// Default NRPN map accessor.
const QMap<unsigned short, QString>& qtractorMidiEditor::defaultNrpnNames (void)
{
if (g_nrpnNames.isEmpty()) {
// Pre-load NRPN-names hash table...
const QString sDrumNrpnName("%1 (%2)");
for (int i = 0; g_aNrpnNames[i].name; ++i) {
const unsigned short param
= g_aNrpnNames[i].param;
const QString& sName
= QObject::tr(g_aNrpnNames[i].name, "nrpnName");
if (param < 2560) {
g_nrpnNames.insert(param, sName);
} else {
for (int j = 12; g_aNoteNames[j].name; ++j) {
const unsigned char note = g_aNoteNames[j].note;
g_nrpnNames.insert(param + note,
sDrumNrpnName.arg(sName).arg(note));
// .arg(defaultNoteName(note, true)));
}
}
}
}
return g_nrpnNames;
}
//----------------------------------------------------------------------------
// MIDI Control-14 Names - Default controller names hash map.
static struct
{
unsigned char controller;
const char *name;
} g_aControl14Names[] = {
{ 1, _TR("Modulation Wheel (14bit)") },
{ 2, _TR("Breath Controller (14bit)") },
{ 4, _TR("Foot Pedal (14bit)") },
{ 5, _TR("Portamento Time (14bit)") },
{ 7, _TR("Volume (14bit)") },
{ 8, _TR("Balance (14bit)") },
{ 10, _TR("Pan Position (14bit)") },
{ 11, _TR("Expression (14bit)") },
{ 12, _TR("Effect Control 1 (14bit)") },
{ 13, _TR("Effect Control 2 (14bit)") },
{ 16, _TR("General Purpose Slider 1 (14bit)") },
{ 17, _TR("General Purpose Slider 2 (14bit)") },
{ 18, _TR("General Purpose Slider 3 (14bit)") },
{ 19, _TR("General Purpose Slider 4 (14bit)") },
{ 0, nullptr }
};
static QHash<unsigned char, QString> g_control14Names;
// Default control-14 name accessor.
const QString& qtractorMidiEditor::defaultControl14Name ( unsigned char controller )
{
if (g_control14Names.isEmpty()) {
// Pre-load controller-names hash table...
for (int i = 0; g_aControl14Names[i].name; ++i) {
g_control14Names.insert(g_aControl14Names[i].controller,
QObject::tr(g_aControl14Names[i].name, "control14Name"));
}
}
QHash<unsigned char, QString>::ConstIterator iter
= g_control14Names.constFind(controller);
if (iter == g_control14Names.constEnd())
return g_sDashes;
else
return iter.value();
}
//----------------------------------------------------------------------------
// MIDI Scale Names - Default scale names table.
static struct
{
const char *name;
unsigned char note[12];
} g_aScaleTab[] = {
{ _TR("Chromatic"), { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 } },
{ _TR("Major"), { 0, 0, 2, 2, 4, 5, 5, 7, 7, 9, 9,11 } },
{ _TR("Minor"), { 0, 0, 2, 3, 3, 5, 5, 7, 8, 8, 8,11 } },
{ _TR("Melodic Minor (Asc)"), { 0, 0, 2, 3, 3, 5, 5, 7, 7, 9, 9,11 } },
{ _TR("Melodic Minor (Desc)"), { 0, 0, 2, 3, 3, 5, 5, 7, 8, 8,10,10 } },
{ _TR("Whole Tone"), { 0, 0, 2, 2, 4, 4, 6, 6, 8, 8,10,10 } },
{ _TR("Pentatonic Major"), { 0, 0, 2, 2, 4, 4, 4, 7, 7, 9, 9, 9 } },
{ _TR("Pentatonic Minor"), { 0, 0, 0, 3, 3, 5, 5, 7, 7, 7,10,10 } },
{ _TR("Pentatonic Blues"), { 0, 0, 0, 3, 3, 5, 6, 7, 7, 7,10,10 } },
{ _TR("Pentatonic Neutral"), { 0, 0, 2, 2, 2, 5, 5, 7, 7, 7,10,10 } },
{ _TR("Octatonic (H-W)"), { 0, 1, 1, 3, 4, 4, 6, 7, 7, 9,10,10 } },
{ _TR("Octatonic (W-H)"), { 0, 0, 2, 3, 3, 5, 6, 6, 8, 9, 9,11 } },
{ _TR("Ionian"), { 0, 0, 2, 2, 4, 5, 5, 7, 7, 9, 9,11 } }, // identical to "Major"
{ _TR("Dorian"), { 0, 0, 2, 3, 3, 5, 5, 7, 7, 9,10,10 } },
{ _TR("Phrygian"), { 0, 1, 1, 3, 3, 5, 5, 7, 8, 8,10,10 } },
{ _TR("Lydian"), { 0, 0, 2, 2, 4, 4, 6, 7, 7, 9, 9,11 } },
{ _TR("Mixolydian"), { 0, 0, 2, 2, 4, 5, 5, 7, 7, 9,10,10 } },
{ _TR("Aeolian"), { 0, 0, 2, 3, 3, 5, 5, 7, 8, 8,10,10 } }, // identical to "Melodic Minor (Descending)"
{ _TR("Locrian"), { 0, 1, 1, 3, 3, 5, 6, 6, 8, 8,10,10 } },
{ _TR("Egyptian"), { 0, 0, 2, 2, 2, 5, 5, 7, 7, 7,10,10 } }, // identical to "Pentatonic Neutral"
{ _TR("Eight Tone Spanish"), { 0, 1, 1, 3, 4, 5, 6, 6, 6, 6,10,10 } },
{ _TR("Hawaiian"), { 0, 0, 2, 3, 3, 5, 5, 7, 7, 9, 9,11 } }, // identical to "Melodic Minor (Ascending)"
{ _TR("Hindu"), { 0, 0, 2, 2, 4, 5, 5, 7, 8, 8,10,10 } },
{ _TR("Hirajoshi"), { 0, 0, 2, 3, 3, 3, 3, 7, 8, 8, 8, 8 } },
{ _TR("Hungarian Major"), { 0, 0, 0, 3, 4, 4, 6, 7, 7, 9,10,10 } },
{ _TR("Hungarian Minor"), { 0, 0, 2, 3, 3, 3, 6, 7, 8, 8, 8,11 } },
{ _TR("Hungarian Gypsy"), { 0, 1, 1, 1, 4, 5, 5, 7, 8, 8, 8,11 } },
{ _TR("Japanese (A)"), { 0, 1, 1, 1, 1, 5, 5, 7, 8, 8, 8, 8 } },
{ _TR("Japanese (B)"), { 0, 0, 2, 2, 2, 5, 5, 7, 8, 8, 8, 8 } },
{ _TR("Jewish (Adonai Malakh)"), { 0, 1, 2, 3, 3, 5, 5, 7, 7, 9,10,10 } },
{ _TR("Jewish (Ahaba Rabba)"), { 0, 1, 1, 1, 4, 5, 5, 7, 8, 8,10,10 } },
{ _TR("Jewish (Magen Abot)"), { 0, 1, 1, 3, 4, 4, 6, 6, 8, 8,10,11 } },
{ _TR("Oriental (A)"), { 0, 1, 1, 1, 4, 5, 6, 6, 8, 8,10,10 } },
{ _TR("Oriental (B)"), { 0, 1, 1, 1, 1, 1, 6, 6, 6, 9,10,10 } },
{ _TR("Oriental (C)"), { 0, 1, 1, 1, 4, 5, 6, 6, 6, 9,10,10 } },
{ _TR("Roumanian Minor"), { 0, 0, 2, 3, 3, 3, 6, 7, 7, 9,10,10 } },
{ _TR("Neapolitan"), { 0, 1, 1, 3, 3, 5, 5, 7, 8, 8, 8,11 } },
{ _TR("Neapolitan Major"), { 0, 1, 1, 3, 3, 5, 5, 7, 7, 9, 9,11 } },
{ _TR("Neapolitan Minor"), { 0, 1, 1, 1, 1, 5, 5, 7, 8, 8,10,10 } },
// { _TR("Mohammedan"), { 0, 0, 2, 3, 3, 5, 5, 7, 8, 8, 8,11 } }, // identical to "Harmonic Minor"
{ _TR("Overtone"), { 0, 0, 2, 2, 4, 4, 6, 7, 7, 9,10,10 } },
// { _TR("Diatonic"), { 0, 0, 2, 2, 4, 4, 4, 7, 7, 9, 9, 9 } }, // identical to "Pentatonic Major"
// { _TR("Double Harmonic"), { 0, 1, 1, 1, 4, 5, 5, 7, 8, 8, 8,11 } }, // identical to "Hungarian Gypsy Persian"
{ _TR("Eight Tone Spanish"), { 0, 1, 1, 3, 4, 5, 6, 6, 8, 8,10,10 } },
{ _TR("Leading Whole Tone"), { 0, 0, 2, 2, 4, 4, 6, 6, 8, 8,10,11 } },
{ _TR("Nine Tone Scale"), { 0, 0, 2, 3, 4, 4, 6, 7, 8, 9, 9,11 } },
{ _TR("Dominant Seventh"), { 0, 0, 2, 2, 2, 5, 5, 7, 7, 9,10,10 } },
{ _TR("Augmented"), { 0, 0, 0, 3, 4, 4, 4, 7, 8, 8, 8,11 } },
{ _TR("Algerian"), { 0, 0, 2, 3, 3, 5, 6, 7, 8, 8, 8,11 } },
{ _TR("Arabian (A)"), { 0, 0, 2, 3, 3, 5, 6, 6, 8, 9, 9,11 } }, // identical to "Octatonic (W-H)"
{ _TR("Arabian (B)"), { 0, 0, 2, 2, 4, 5, 6, 6, 8, 8,10,10 } },
// { _TR("Asavari Theta"), { 0, 0, 2, 3, 3, 5, 5, 7, 8, 8,10,10 } }, // identical to "Melodic Minor (Descending)"
{ _TR("Balinese"), { 0, 1, 1, 3, 3, 3, 3, 7, 8, 8, 8, 8 } },
// { _TR("Bilaval Theta"), { 0, 0, 2, 2, 4, 5, 5, 7, 7, 9, 9,11 } }, // identical to "Major"
// { _TR("Bhairav Theta"), { 0, 1, 1, 1, 4, 5, 5, 7, 8, 8, 8,11 } }, // identical to "Hungarian Gypsy Persian"
// { _TR("Bhairavi Theta"), { 0, 1, 1, 3, 3, 5, 5, 7, 8, 8,10,10 } }, // identical to "Phrygian"
// { _TR("Byzantine"), { 0, 1, 1, 1, 4, 5, 5, 7, 8, 8, 8,11 } }, // identical to "Hungarian Gypsy Persian"
{ _TR("Chinese"), { 0, 0, 0, 0, 4, 4, 6, 7, 7, 7, 7,11 } },
// { _TR("Chinese Mongolian"), { 0, 0, 2, 2, 4, 4, 4, 7, 7, 9, 9, 9 } }, // identical to "Pentatonic Major"
{ _TR("Diminished"), { 0, 0, 2, 3, 3, 5, 6, 6, 8, 9, 9,11 } }, // identical to "Octatonic (W-H)"
// { _TR("Egyptian"), { 0, 0, 2, 2, 2, 5, 5, 7, 7, 7,10,10 } }, // identical to "Pentatonic Neutral"
// { _TR("Ethiopian (A Raray)"), { 0, 0, 2, 2, 4, 5, 5, 7, 7, 9, 9,11 } }, // identical to "Major"
// { _TR("Ethiopian (Geez & Ezel)"),{ 0, 0, 2, 3, 3, 5, 5, 7, 8, 8,10,10 } }, // identical to "Melodic Minor (Descending)"
// { _TR("Hawaiian"), { 0, 0, 2, 3, 3, 5, 5, 7, 7, 9, 9,11 } }, // identical to "Melodic Minor (Ascending)"
// { _TR("Hindustan"), { 0, 0, 2, 2, 4, 5, 5, 7, 8, 8,10,10 } }, // identical to "Hindu"
{ _TR("Japanese (Ichikosucho)"), { 0, 0, 2, 2, 4, 5, 6, 7, 7, 9, 9,11 } },
{ _TR("Japanese (Taishikicho)"), { 0, 0, 2, 2, 4, 5, 6, 7, 7, 9,10,11 } },
{ _TR("Javaneese"), { 0, 1, 1, 3, 3, 5, 5, 7, 7, 9,10,10 } },
// { _TR("Kafi Theta"), { 0, 0, 2, 3, 3, 5, 5, 7, 7, 9,10,10 } }, // identical to "Dorian"
// { _TR("Kalyan Theta"), { 0, 0, 2, 2, 4, 4, 6, 7, 7, 9, 9,11 } }, // identical to "Lydian"
// { _TR("Khamaj Theta"), { 0, 0, 2, 2, 4, 5, 5, 7, 7, 9,10,10 } }, // identical to "Mixolydian"
// { _TR("Madelynian"), { 0, 1, 1, 3, 3, 5, 6, 6, 8, 8,10,10 } }, // identical to "Locrian"
{ _TR("Marva Theta"), { 0, 1, 1, 1, 4, 4, 6, 7, 7, 9, 9,11 } },
#ifdef QTRACTOR_MELA_SCALES
{ _TR("Mela Bhavapriya"), { 0, 1, 2, 2, 2, 5, 5, 7, 8, 9, 9, 9 } },
{ _TR("Mela Chakravakam"), { 0, 1, 1, 1, 4, 5, 5, 7, 7, 9,10,10 } },
{ _TR("Mela Chalanata"), { 0, 0, 0, 3, 4, 5, 5, 7, 7, 7,10,11 } },
// { _TR("Mela Charukesi"), { 0, 0, 2, 2, 4, 5, 5, 7, 8, 8,10,10 } }, // identical to "Hindu"
{ _TR("Mela Chitrambari"), { 0, 0, 2, 2, 4, 4, 6, 7, 7, 7,10,11 } },
{ _TR("Mela Dharmavati"), { 0, 0, 2, 3, 3, 3, 6, 7, 7, 9, 9,11 } },
{ _TR("Mela Dhatuvardhani"), { 0, 0, 0, 3, 4, 4, 6, 7, 8, 8, 8,11 } },
{ _TR("Mela Dhavalambari"), { 0, 1, 1, 1, 4, 4, 6, 7, 8, 9, 9, 9 } },
// { _TR("Mela Dhenuka"), { 0, 1, 1, 3, 3, 5, 5, 7, 8, 8, 8,11 } }, // identical to "Neapolitan"
// { _TR("Mela Dhirasankarabharana"),{0, 0, 2, 2, 4, 5, 5, 7, 7, 9, 9,11 } }, // identical to "Major"
{ _TR("Mela Divyamani"), { 0, 1, 1, 1, 4, 4, 6, 7, 7, 7,10,11 } },
// { _TR("Mela Gamanasrama"), { 0, 1, 1, 1, 4, 4, 6, 7, 7, 9, 9,11 } }, // identical to "Marva Theta"
{ _TR("Mela Ganamurti"), { 0, 1, 2, 2, 2, 5, 5, 7, 8, 8, 8,11 } },
{ _TR("Mela Gangeyabhusani"), { 0, 0, 0, 3, 4, 5, 5, 7, 8, 8, 8,11 } },
// { _TR("Mela Gaurimanohari"), { 0, 0, 2, 3, 3, 5, 5, 7, 7, 9, 9,11 } }, // identical to "Melodic Minor (Ascending)"
{ _TR("Mela Gavambodhi"), { 0, 1, 1, 3, 3, 3, 6, 7, 8, 9, 9, 9 } },
{ _TR("Mela Gayakapriya"), { 0, 1, 1, 1, 4, 5, 5, 7, 8, 9, 9, 9 } },
// { _TR("Mela Hanumattodi"), { 0, 1, 1, 3, 3, 5, 5, 7, 8, 8,10,10 } }, // identical to "Phrygian"
// { _TR("Mela Harikambhoji"), { 0, 0, 2, 2, 4, 5, 5, 7, 7, 9,10,10 } }, // identical to "Mixolydian"
{ _TR("Mela Hatakambari"), { 0, 1, 1, 1, 4, 5, 5, 7, 7, 7,10,11 } },
// { _TR("Mela Hemavati"), { 0, 0, 2, 3, 3, 3, 6, 7, 7, 9,10,10 } }, // identical to "Roumanian Minor"
{ _TR("Mela Jalarnavam"), { 0, 1, 2, 2, 2, 2, 6, 7, 8, 8,10,10 } },
{ _TR("Mela Jhalavarali"), { 0, 1, 2, 2, 2, 2, 6, 7, 8, 8, 8,11 } },
{ _TR("Mela Jhankaradhvani"), { 0, 0, 2, 3, 3, 5, 5, 7, 8, 9, 9, 9 } },
{ _TR("Mela Jyotisvarupini"), { 0, 0, 0, 3, 4, 4, 6, 7, 8, 8,10,10 } },
{ _TR("Mela Kamavarardhani"), { 0, 1, 1, 1, 4, 4, 6, 7, 8, 8, 8,11 } },
// { _TR("Mela Kanakangi"), { 0, 1, 2, 2, 2, 5, 5, 7, 8, 9, 9, 9 } }, // identical to "Mela Bhavapriya"
{ _TR("Mela Kantamani"), { 0, 0, 2, 2, 4, 4, 6, 7, 8, 9, 9, 9 } },
// { _TR("Mela Kharaharapriya"), { 0, 0, 2, 3, 3, 5, 5, 7, 7, 9,10,10 } }, // identical to "Dorian"
// { _TR("Mela Kiravani"), { 0, 0, 2, 3, 3, 5, 5, 7, 8, 8, 8,11 } }, // identical to "Harmonic Minor"
// { _TR("Mela Kokilapriya"), { 0, 1, 1, 3, 3, 5, 5, 7, 7, 9, 9,11 } }, // identical to "Neapolitan Major"
{ _TR("Mela Kosalam"), { 0, 0, 0, 3, 4, 4, 6, 7, 7, 9, 9,11 } },
{ _TR("Mela Latangi"), { 0, 0, 2, 2, 4, 4, 6, 7, 8, 8, 8,11 } },
{ _TR("Mela Manavati"), { 0, 1, 2, 2, 2, 5, 5, 7, 7, 9, 9,11 } },
{ _TR("Mela Mararanjani"), { 0, 0, 2, 2, 4, 5, 5, 7, 8, 9, 9, 9 } },
// { _TR("Mela Mayamalavagaula"), { 0, 1, 1, 1, 4, 5, 5, 7, 8, 8, 8,11 } }, // identical to "Hungarian Gypsy Persian"
// { _TR("Mela Mechakalyani"), { 0, 0, 2, 2, 4, 4, 6, 7, 7, 9, 9,11 } }, // identical to "Lydian"
{ _TR("Mela Naganandini"), { 0, 0, 2, 2, 4, 5, 5, 7, 7, 7,10,11 } },
{ _TR("Mela Namanarayani"), { 0, 1, 1, 1, 4, 4, 6, 7, 8, 8,10,10 } },
// { _TR("Mela Nasikabhusani"), { 0, 0, 0, 3, 4, 4, 6, 7, 7, 9,10,10 } }, // identical to "Hungarian Major"
// { _TR("Mela Natabhairavi"), { 0, 0, 2, 3, 3, 5, 5, 7, 8, 8,10,10 } }, // identical to "Melodic Minor (Descending)"
// { _TR("Mela Natakapriya"), { 0, 1, 1, 3, 3, 5, 5, 7, 7, 9,10,10 } }, // identical to "Javaneese"
{ _TR("Mela Navanitam"), { 0, 1, 2, 2, 2, 2, 6, 7, 7, 9,10,10 } },
{ _TR("Mela Nitimati"), { 0, 0, 2, 3, 3, 3, 6, 7, 7, 7,10,11 } },
{ _TR("Mela Pavani"), { 0, 1, 2, 2, 2, 2, 6, 7, 7, 9, 9,11 } },
{ _TR("Mela Ragavardhani"), { 0, 0, 0, 3, 4, 5, 5, 7, 8, 8,10,10 } },
{ _TR("Mela Raghupriya"), { 0, 1, 2, 2, 2, 2, 6, 7, 7, 7,10,11 } },
{ _TR("Mela Ramapriya"), { 0, 1, 1, 1, 4, 4, 6, 7, 7, 9,10,10 } },
{ _TR("Mela Rasikapriya"), { 0, 0, 0, 3, 4, 4, 6, 7, 7, 7,10,11 } },
{ _TR("Mela Ratnangi"), { 0, 1, 2, 2, 2, 5, 5, 7, 8, 8,10,10 } },
{ _TR("Mela Risabhapriya"), { 0, 0, 2, 2, 4, 4, 6, 7, 8, 8,10,10 } },
{ _TR("Mela Rupavati"), { 0, 1, 1, 3, 3, 5, 5, 7, 7, 7,10,11 } },
{ _TR("Mela Sadvidhamargini"), { 0, 1, 1, 3, 3, 3, 6, 7, 7, 9,10,10 } },
{ _TR("Mela Salagam"), { 0, 1, 2, 2, 2, 2, 6, 7, 8, 9, 9, 9 } },
{ _TR("Mela Sanmukhapriya"), { 0, 0, 2, 3, 3, 3, 6, 7, 8, 8,10,10 } },
{ _TR("Mela Sarasangi"), { 0, 0, 2, 2, 4, 5, 5, 7, 8, 8, 8,11 } },
{ _TR("Mela Senavati"), { 0, 1, 1, 3, 3, 5, 5, 7, 8, 9, 9, 9 } },
// { _TR("Mela Simhendramadhyama"), { 0, 0, 2, 3, 3, 3, 6, 7, 8, 8, 8,11 } }, // identical to "Hungarian Minor"
{ _TR("Mela Subhapantuvarali"), { 0, 1, 1, 3, 3, 3, 6, 7, 8, 8, 8,11 } },
{ _TR("Mela Sucharitra"), { 0, 0, 0, 3, 4, 4, 6, 7, 8, 9, 9, 9 } },
{ _TR("Mela Sulini"), { 0, 0, 0, 3, 4, 5, 5, 7, 7, 9, 9,11 } },
{ _TR("Mela Suryakantam"), { 0, 1, 1, 1, 4, 5, 5, 7, 7, 9, 9,11 } },
// { _TR("Mela Suvarnangi"), { 0, 1, 2, 2, 2, 2, 6, 7, 7, 9, 9,11 } }, // identical to "Mela Pavani"
{ _TR("Mela Syamalangi"), { 0, 0, 2, 3, 3, 3, 6, 7, 8, 9, 9, 9 } },
{ _TR("Mela Tanarupi"), { 0, 1, 2, 2, 2, 5, 5, 7, 7, 7,10,11 } },
// { _TR("Mela Vaschaspati"), { 0, 0, 2, 2, 4, 4, 6, 7, 7, 9,10,10 } }, // identical to "Overtone"
{ _TR("Mela Vagadhisvari"), { 0, 0, 0, 3, 4, 5, 5, 7, 7, 9,10,10 } },
// { _TR("Mela Vakulabharanam"), { 0, 1, 1, 1, 4, 5, 5, 7, 8, 8,10,10 } }, // identical to "Jewish (Ahaba Rabba)"
{ _TR("Mela Vanaspati"), { 0, 1, 2, 2, 2, 5, 5, 7, 7, 9,10,10 } },
{ _TR("Mela Varunapriya"), { 0, 0, 2, 3, 3, 5, 5, 7, 7, 7,10,11 } },
// { _TR("Mela Visvambari"), { 0, 1, 1, 1, 4, 4, 6, 7, 7, 7,10,11 } }, // identical to "Mela Divyamani"
{ _TR("Mela Yagapriya"), { 0, 0, 0, 3, 4, 5, 5, 7, 8, 9, 9, 9 } },
#endif // QTRACTOR_MELA_SCALES
// { _TR("Mohammedan"), { 0, 0, 2, 3, 3, 5, 5, 7, 8, 8, 8,11 } }, // identical to "Harmonic Minor"
{ _TR("Persian"), { 0, 1, 1, 1, 4, 5, 6, 6, 8, 8, 8,11 } },
{ _TR("Purvi Theta"), { 0, 1, 1, 1, 4, 4, 6, 7, 8, 8, 8,11 } }, // identical to "Mela Kamavarardhani"
{ _TR("Spanish Gypsy"), { 0, 1, 1, 1, 4, 5, 5, 7, 8, 8,10,10 } }, // identical to "Jewish (Ahaba Rabba)"
{ _TR("Todi Theta"), { 0, 1, 1, 3, 3, 3, 6, 7, 8, 8, 8,11 } }, // identical to "Mela Subhapantuvarali"
// { _TR("Aux Diminished"), { 0, 0, 2, 3, 3, 5, 6, 6, 8, 9, 9,11 } }, // identical to "Octatonic (W-H)"
// { _TR("Aux Augmented"), { 0, 0, 2, 2, 4, 4, 6, 6, 8, 8,10,10 } }, // identical to "Whole Tone"
// { _TR("Aux Diminished Blues"), { 0, 1, 1, 3, 4, 4, 6, 7, 7, 9,10,10 } }, // identical to "Octatonic (H-W)"
{ _TR("Enigmatic"), { 0, 1, 1, 1, 4, 4, 6, 6, 8, 8,10,11 } },
{ _TR("Kumoi"), { 0, 0, 2, 3, 3, 3, 3, 7, 7, 9, 9, 9 } },
{ _TR("Lydian Augmented"), { 0, 0, 2, 2, 4, 4, 6, 6, 8, 9, 9,11 } },
{ _TR("Pelog"), { 0, 1, 1, 3, 3, 3, 3, 7, 8, 8, 8, 8 } }, // identical to "Balinese"
{ _TR("Prometheus"), { 0, 0, 2, 2, 4, 4, 6, 6, 6, 9,10,10 } },
{ _TR("Prometheus Neapolitan"), { 0, 1, 1, 1, 4, 4, 6, 6, 6, 9,10,10 } },
{ _TR("Six Tone Symmetrical"), { 0, 1, 1, 1, 4, 5, 5, 5, 8, 9, 9, 9 } },
{ _TR("Super Locrian"), { 0, 1, 1, 3, 4, 4, 6, 6, 8, 8,10,10 } },
{ _TR("Lydian Minor"), { 0, 0, 2, 2, 4, 4, 6, 7, 8, 8,10,10 } }, // identical to "Mela Risabhapriya"
{ _TR("Lydian Diminished"), { 0, 0, 2, 3, 3, 3, 6, 7, 7, 9, 9,11 } }, // identical to "Mela Dharmavati"
// { _TR("Major Locrian"), { 0, 0, 2, 2, 4, 5, 6, 6, 8, 8,10,10 } }, // identical to "Arabian (B)"
// { _TR("Hindu"), { 0, 0, 2, 2, 4, 5, 5, 7, 8, 8,10,10 } }, // identical to "Hindu"
// { _TR("Diminished Whole Tone"), { 0, 1, 1, 3, 4, 4, 6, 6, 8, 8,10,10 } }, // identical to "Super Locrian"
{ _TR("Half Diminished"), { 0, 0, 2, 3, 3, 5, 6, 6, 8, 8,10,10 } },
{ _TR("Bhairav"), { 0, 1, 1, 1, 4, 5, 5, 7, 8, 8, 8,11 } }, // identical to "Hungarian Gypsy Persian"
{ _TR("Yaman"), { 0, 0, 2, 2, 4, 4, 6, 7, 7, 9, 9,11 } }, // identical to "Lydian"
{ _TR("Todi"), { 0, 1, 1, 3, 3, 5, 5, 7, 8, 8,10,10 } }, // identical to "Phrygian"
{ _TR("Jog"), { 0, 0, 0, 3, 4, 5, 5, 7, 7, 7,10,10 } },
{ _TR("Multani"), { 0, 1, 1, 3, 3, 3, 6, 7, 8, 8, 8,11 } }, // identical to "Mela Subhapantuvarali"
{ _TR("Darbari"), { 0, 0, 2, 3, 3, 5, 5, 7, 8, 8,10,10 } }, // identical to "Melodic Minor (Descending)"
{ _TR("Malkauns"), { 0, 0, 0, 3, 3, 5, 5, 5, 8, 8,10,10 } },
{ _TR("Bhoopali"), { 0, 0, 2, 2, 4, 4, 4, 7, 7, 9, 9, 9 } }, // identical to "Pentatonic Major"
{ _TR("Shivaranjani"), { 0, 0, 2, 3, 3, 3, 3, 7, 7, 9, 9, 9 } }, // identical to "Kumoi"
{ _TR("Marwa"), { 0, 1, 1, 1, 4, 4, 6, 6, 6, 9, 9,11 } },
// { _TR("Blues"), { 0, 0, 0, 3, 3, 5, 6, 7, 7, 7,10,10 } }, // identical to "Pentatonic Blues"
{ _TR("Minor 5"), { 0, 0, 0, 3, 3, 5, 5, 7, 7, 7,10,10 } }, // identical to "Pentatonic Minor"
{ _TR("Major 5"), { 0, 0, 0, 0, 4, 5, 5, 7, 7, 7, 7,11 } },
{ _TR("5"), { 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7 } },
{ _TR("45"), { 0, 0, 0, 0, 0, 5, 5, 7, 7, 7, 7, 7 } },
{ _TR("457"), { 0, 0, 0, 0, 0, 5, 5, 7, 7, 7,10,10 } },
{ _TR("M 6"), { 0, 0, 2, 3, 3, 5, 5, 7, 7, 7,10,11 } }, // identical to "Mela Varunapriya"
{ nullptr, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }
};
// Default scale key note names accessor.
const QStringList& qtractorMidiEditor::scaleKeyNames (void)
{
static QStringList s_scaleKeys;
if (s_scaleKeys.isEmpty()) {
for (int i = 0; i < 12; ++i)
s_scaleKeys.append(QObject::tr(g_aNoteNames[i].name, "scaleKeyName"));
}
return s_scaleKeys;
}
// Default scale type names table accessor.
const QStringList& qtractorMidiEditor::scaleTypeNames (void)
{
static QStringList s_scaleTypes;
if (s_scaleTypes.isEmpty()) {
for (int i = 0; g_aScaleTab[i].name; ++i)
s_scaleTypes.append(QObject::tr(g_aScaleTab[i].name, "scaleTypeName"));
}
return s_scaleTypes;
}
// Scale quantizer method.
unsigned char qtractorMidiEditor::snapToScale (
unsigned char note, int iKey, int iScale )
{
const int n = int(note) + (12 - iKey);
return 12 * ((n / 12) - 1) + iKey + int(g_aScaleTab[iScale].note[n % 12]);
}
//----------------------------------------------------------------------------
// qtractorMidiEdit::ClipBoard - MIDI editor clipaboard singleton.
// Singleton declaration.
qtractorMidiEditor::ClipBoard qtractorMidiEditor::g_clipboard;
//----------------------------------------------------------------------------
// qtractorMidiEdit::DragTimeScale - Specialized drag/time-scale (draft)...
struct qtractorMidiEditor::DragTimeScale
{
DragTimeScale(qtractorTimeScale *ts, unsigned long offset)
: cursor(ts)
{
node = cursor.seekFrame(offset);
t0 = node->tickFromFrame(offset);
x0 = ts->pixelFromFrame(offset);
}
qtractorTimeScale::Cursor cursor;
qtractorTimeScale::Node *node;
unsigned long t0;
int x0;
};
//----------------------------------------------------------------------------
// qtractorMidiEditor -- The main MIDI sequence editor widget.
// Constructor.
qtractorMidiEditor::qtractorMidiEditor ( QWidget *pParent )
: QSplitter(Qt::Vertical, pParent)
{
// Initialize instance variables...
m_pMidiClip = nullptr;
// Event fore/background colors.
m_foreground = Qt::darkBlue;
m_background = Qt::blue;
// Common drag state.
m_dragState = DragNone;
m_dragCursor = DragNone;
m_resizeMode = ResizeNone;
m_pEventDrag = nullptr;
m_bEventDragEdit = false;
m_pRubberBand = nullptr;
// Zoom mode flag.
m_iZoomMode = ZoomAll;
// Drum mode (UI).
m_bDrumMode = false;
// Edit mode flags.
m_bEditMode = false;
m_bEditModeDraw = false;
// Snap-to-beat/bar grid/zebra mode.
m_bSnapZebra = false;
m_bSnapGrid = false;
// Floating tool-tips mode.
m_bToolTips = true;
// Last default editing values.
m_last.note = 0x3c; // middle-C
m_last.value = 0x40;
m_last.pitchBend = 0;
m_last.duration = 0;
// The local mighty command pattern instance.
m_pCommands = new qtractorCommandList();
// Local time-scale.
m_pTimeScale = new qtractorTimeScale();
// The local time-scale offset/length.
m_iOffset = 0;
m_iLength = 0;
// Local edit-head/tail positioning.
m_iEditHeadX = 0;
m_iEditTailX = 0;
// Local play-head positioning.
m_iPlayHeadX = 0;
m_bSyncView = false;
// Note autition while editing.
m_bSendNotes = false;
// Event (note) duration rectangle vs. stick.
m_bNoteDuration = false;
// Event (note, velocity) coloring.
m_bNoteColor = false;
m_bValueColor = false;
// Which widget holds focus on drag-paste?
m_pEditPaste = nullptr;
// Snap-to-scale (aka.in-place scale-quantize) stuff.
m_iSnapToScaleKey = 0;
m_iSnapToScaleType = 0;
// Temporary sync-view/follow-playhead hold state.
m_bSyncViewHold = false;
m_iSyncViewHold = 0;
// Current ghost-track option.
m_pGhostTrack = nullptr;
// The main widget splitters.
m_pHSplitter = new QSplitter(Qt::Horizontal, this);
m_pHSplitter->setObjectName("qtractorMidiEditor::HSplitter");
m_pVSplitter = this;
m_pVSplitter->setObjectName("qtractorMidiEditor::VSplitter");
// Create child frame widgets...
QWidget *pVBoxLeft = new QWidget(m_pHSplitter);
QWidget *pVBoxRight = new QWidget(m_pHSplitter);
QWidget *pHBoxBottom = new QWidget(m_pVSplitter);
// Create child view widgets...
m_pEditListHeader = new QFrame(pVBoxLeft);
m_pEditListHeader->setFixedHeight(20);
m_pEditList = new qtractorMidiEditList(this, pVBoxLeft);
m_pEditList->setMinimumWidth(32);
m_pEditTime = new qtractorMidiEditTime(this, pVBoxRight);
m_pEditTime->setFixedHeight(20);
m_pEditView = new qtractorMidiEditView(this, pVBoxRight);
m_pEditEventScale = new qtractorMidiEditEventScale(this, pHBoxBottom);
m_pEditEvent = new qtractorMidiEditEvent(this, pHBoxBottom);
m_pEditEventFrame = new QFrame(pHBoxBottom);
m_pEditList->updateContentsHeight();
m_pThumbView = new qtractorMidiThumbView(this);
// Create child box layouts...
QVBoxLayout *pVBoxLeftLayout = new QVBoxLayout(pVBoxLeft);
pVBoxLeftLayout->setMargin(0);
pVBoxLeftLayout->setSpacing(0);
pVBoxLeftLayout->addWidget(m_pEditListHeader);
pVBoxLeftLayout->addWidget(m_pEditList);
pVBoxLeft->setLayout(pVBoxLeftLayout);
QVBoxLayout *pVBoxRightLayout = new QVBoxLayout(pVBoxRight);
pVBoxRightLayout->setMargin(0);
pVBoxRightLayout->setSpacing(0);
pVBoxRightLayout->addWidget(m_pEditTime);
pVBoxRightLayout->addWidget(m_pEditView);
pVBoxRight->setLayout(pVBoxRightLayout);
QHBoxLayout *pHBoxBottomLayout = new QHBoxLayout(pHBoxBottom);
pHBoxBottomLayout->setMargin(0);
pHBoxBottomLayout->setSpacing(0);
pHBoxBottomLayout->addWidget(m_pEditEventScale);
pHBoxBottomLayout->addWidget(m_pEditEvent);
pHBoxBottomLayout->addWidget(m_pEditEventFrame);
pHBoxBottom->setLayout(pHBoxBottomLayout);
// m_pHSplitter->setOpaqueResize(false);
m_pHSplitter->setStretchFactor(m_pHSplitter->indexOf(pVBoxLeft), 0);
m_pHSplitter->setHandleWidth(2);
// m_pVSplitter->setOpaqueResize(false);
m_pVSplitter->setStretchFactor(m_pVSplitter->indexOf(pHBoxBottom), 0);
m_pVSplitter->setHandleWidth(2);
m_pVSplitter->setWindowIcon(QIcon(":/images/qtractorMidiEditor.png"));
m_pVSplitter->setWindowTitle(tr("MIDI Editor"));
// To have all views in positional sync.
QObject::connect(m_pEditList, SIGNAL(contentsMoving(int,int)),
m_pEditView, SLOT(contentsYMovingSlot(int,int)));
QObject::connect(m_pEditView, SIGNAL(contentsMoving(int,int)),
m_pEditTime, SLOT(contentsXMovingSlot(int,int)));
QObject::connect(m_pEditView, SIGNAL(contentsMoving(int,int)),
m_pEditList, SLOT(contentsYMovingSlot(int,int)));
QObject::connect(m_pEditView, SIGNAL(contentsMoving(int,int)),
m_pEditEvent, SLOT(contentsXMovingSlot(int,int)));
QObject::connect(m_pEditEvent, SIGNAL(contentsMoving(int,int)),
m_pEditTime, SLOT(contentsXMovingSlot(int,int)));
QObject::connect(m_pEditEvent, SIGNAL(contentsMoving(int,int)),
m_pEditView, SLOT(contentsXMovingSlot(int,int)));
QObject::connect(m_pEditView,
SIGNAL(contentsMoving(int,int)),
m_pThumbView, SLOT(updateThumb()));
QObject::connect(m_pCommands,
SIGNAL(updateNotifySignal(unsigned int)),
SLOT(updateNotifySlot(unsigned int)));
// Initial splitter sizes.
qtractorOptions *pOptions = qtractorOptions::getInstance();
if (pOptions) {
QList<int> sizes;
// Initial horizontal splitter sizes...
sizes.append(48);
sizes.append(752);
pOptions->loadSplitterSizes(m_pHSplitter, sizes);
sizes.clear();
// Initial vertical splitter sizes...
sizes.append(420);
sizes.append(180);
pOptions->loadSplitterSizes(m_pVSplitter, sizes);
}
// Track splitter moves...
QObject::connect(m_pHSplitter,
SIGNAL(splitterMoved(int, int)),
SLOT(horizontalSplitterSlot()));
QObject::connect(m_pVSplitter,
SIGNAL(splitterMoved(int, int)),
SLOT(verticalSplitterSlot()));
}
// Destructor.
qtractorMidiEditor::~qtractorMidiEditor (void)
{
resetDragState(nullptr);
// Save splitter sizes...
qtractorOptions *pOptions = qtractorOptions::getInstance();
if (pOptions) {
pOptions->saveSplitterSizes(m_pHSplitter);
pOptions->saveSplitterSizes(m_pVSplitter);
}
// Release local instances.
delete m_pTimeScale;
delete m_pCommands;
}
// Editing sequence accessor.
void qtractorMidiEditor::setMidiClip ( qtractorMidiClip *pMidiClip )
{
// So, this is the brand new object to edit...
m_pMidiClip = pMidiClip;
// Reset ghost-track anyway...
m_pGhostTrack = nullptr;
if (m_pMidiClip) {
// Now set the editing MIDI sequence alright...
setOffset(m_pMidiClip->clipStart());
setLength(m_pMidiClip->clipLength());
// Set its most outstanding properties...
qtractorTrack *pTrack = m_pMidiClip->track();
if (pTrack) {
setDrumMode(pTrack->isMidiDrums());
setForeground(pTrack->foreground());
setBackground(pTrack->background());
}
// And the last but not least...
qtractorMidiSequence *pSeq = m_pMidiClip->sequence();
if (pSeq) {
// Reset some internal state...
m_cursor.reset(pSeq);
m_cursorAt.reset(pSeq);
// Reset as last on middle note and snap duration...
m_last.note = (pSeq->noteMin() + pSeq->noteMax()) >> 1;
if (m_last.note == 0)
m_last.note = 0x3c; // Default to middle-C.
}
// Set ghost-track by name...
const QString& sGhostTrackName
= m_pMidiClip->ghostTrackName();
qtractorSession *pSession = pTrack->session();
if (pSession && !sGhostTrackName.isEmpty()) {
for (pTrack = pSession->tracks().first();
pTrack; pTrack = pTrack->next()) {
if (pTrack->trackType() == qtractorTrack::Midi
&& pTrack->trackName() == sGhostTrackName) {
m_pGhostTrack = pTrack;
break;
}
}
}
// Set zoom ratios...
const unsigned short iHorizontalZoom
= pMidiClip->editorHorizontalZoom();
if (iHorizontalZoom != 100)
setHorizontalZoom(iHorizontalZoom);
const unsigned short iVerticalZoom
= pMidiClip->editorVerticalZoom();
if (iVerticalZoom != 100)
setVerticalZoom(iVerticalZoom);
// Set splitter sizes...
const QList<int>& hsizes
= pMidiClip->editorHorizontalSizes();
if (!hsizes.isEmpty())
setHorizontalSizes(hsizes);
const QList<int>& vsizes
= pMidiClip->editorVerticalSizes();
if (!vsizes.isEmpty())
setVerticalSizes(vsizes);
// Got clip!
} else {
// Reset those little things too..
setDrumMode(false);
setOffset(0);
setLength(0);
}
// All commands reset.
m_pCommands->clear();
}
qtractorMidiClip *qtractorMidiEditor::midiClip (void) const
{
return m_pMidiClip;
}
// MIDI clip property accessors.
const QString& qtractorMidiEditor::filename (void) const
{
return m_pMidiClip->filename();
}
unsigned short qtractorMidiEditor::trackChannel (void) const
{
return (m_pMidiClip ? m_pMidiClip->trackChannel() : 0);
}