-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathGPBase.cs
executable file
·1394 lines (1239 loc) · 36.3 KB
/
GPBase.cs
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
using System;
using System.Collections.Generic;
using UnityEngine;
abstract public class GPFile
{
//Parent class for common type
abstract public void readSong();
public GP4File.Clipboard clipboard = null;
public RSEMasterEffect masterEffect = null;
public PageSetup pageSetup = null;
public int tempo;
public string tempoName;
public bool hideTempo;
public List<DirectionSign> directions = new List<DirectionSign>();
public string words;
public string music;
public List<Track> tracks = new List<Track>();
public GPFile self;
public string title;
public string subtitle;
public string interpret;
public string album;
public string author ;
public string copyright ;
public string tab_author ;
public string instructional ;
public int[] versionTuple = new int[] { };
public string version = "";
public List<Lyrics> lyrics = new List<Lyrics>();
public List<MeasureHeader> measureHeaders = new List<MeasureHeader>();
public TripletFeel _tripletFeel;
}
public class GPBase
{
public const int bendPosition = 60;
public const int bendSemitone = 25;
public static int pointer = 0;
public static byte[] data;
public static void skip(int count)
{
pointer += count;
}
public static byte[] readByte(int count = 1)
{
return extract(pointer, count, true);
}
public static sbyte[] readSignedByte(int count = 1)
{
byte[] unsigned = extract(pointer, count, true);
sbyte[] ret_val = new sbyte[unsigned.Length];
for (int x = 0; x < unsigned.Length; x++)
{
ret_val[x] = (sbyte)unsigned[x];
}
return ret_val;
}
public static bool[] readBool(int count = 1)
{
byte[] vals = extract(pointer, count, true);
bool[] ret_val = new bool[vals.Length];
for (int x = 0; x < vals.Length; x++)
{
ret_val[x] = (vals[x] != 0x0);
}
return ret_val;
}
public static short[] readShort(int count = 1)
{
byte[] vals = extract(pointer, count * 2, true);
short[] ret_val = new short[count];
for (int x = 0; x < vals.Length; x += 2)
{
ret_val[x / 2] = (short)(vals[x] + (vals[x + 1] << 8));
}
return ret_val;
}
public static int[] readInt(int count = 1)
{
byte[] vals = extract(pointer, count * 4, true);
int[] ret_val = new int[count];
for (int x = 0; x < vals.Length; x += 4)
{
ret_val[x / 4] = (int)(vals[x] + (vals[x + 1] << 8) + (vals[x + 2] << 16) + (vals[x + 3] << 24));
}
return ret_val;
}
public static float[] readFloat(int count = 1)
{
byte[] vals = extract(pointer, count * 4, true);
float[] ret_val = new float[count];
for (int x = 0; x < vals.Length; x += 4)
{
ret_val[x / 4] = System.BitConverter.ToSingle(vals, x);
}
return ret_val;
}
public static double[] readDouble(int count = 1)
{
byte[] vals = extract(pointer, count * 8, true);
double[] ret_val = new double[count];
for (int x = 0; x < vals.Length; x += 8)
{
ret_val[x / 8] = System.BitConverter.ToDouble(vals, x);
}
return ret_val;
}
public static string readString(int size, int length = 0)
{
if (length == 0)
{
length = size;
}
int count = (size > 0) ? size : length;
byte[] ss = (length >= 0) ? extract(pointer, length, true) : extract(pointer, size, true);
skip(count - ss.Length);
return System.Text.Encoding.Default.GetString(ss);
}
public static string readByteSizeString(int size)
{
return readString(size, (int)readByte()[0]);
}
public static string readIntSizeString()
{
return readString(readInt()[0]);
}
public static string readIntByteSizeString()
{
//Read length of the string increased by 1 and stored in 1 integer
//followed by length of the string in 1 byte and finally followed by
//character bytes.
int d = readInt()[0] - 1;
return readByteSizeString(d);
}
public static byte[] extract(int start, int length, bool advance_pointer)
{
if (length <= 0)
{
return new byte[Math.Max(0, length)];
}
if (length + start > data.Length)
{
return new byte[Math.Max(0, length)];
return null;
}
byte[] ret = new byte[length];
for (int x = start; x < start + length; x++)
{
ret[x - start] = data[x];
}
if (advance_pointer) pointer += length;
return ret;
}
}
public class Barre
{
public int start = 0;
public int end = 0;
public int fret;
public Barre(int fret = 0, int start = 0, int end = 0)
{
this.start = start; this.fret = fret; this.end = end;
}
public int[] range()
{
return new int[] { start, end };
}
}
public class Beat
{
public Voice voice;
public List<Voice> voices = new List<Voice>();
public Measure measure;
public Duration duration = new Duration();
public int start = Duration.quarterTime;
public BeatEffect effect = new BeatEffect();
public Octave octave = Octave.none;
public BeatDisplay display = new BeatDisplay();
public List<Note> notes = new List<Note>();
public BeatStatus status;
public BeatText text = new BeatText();
public Beat(Voice voice = null)
{
this.voice = voice;
}
public int realStart()
{
int offset = start + measure.start();
return measure.header.realStart + offset;
}
public bool hasVibrato()
{
foreach (Note note in notes)
{
if (note.effect.vibrato) return true;
}
return false;
}
public bool hasHarmonic()
{
foreach (Note note in notes)
{
if (note.effect.isHarmonic()) return true;
}
return false;
}
public void addNote(Note note)
{
note.beat = this;
notes.Add(note);
}
}
public class BeatDisplay
{
public bool breakBeam = false;
public bool forceBeam = false;
public VoiceDirection beamDirection = VoiceDirection.none;
public TupletBracket tupletBracket = TupletBracket.none;
public int breakSecondary = 0;
public bool breakSecondaryTuplet = false;
public bool forceBracket = false;
}
public class BeatEffect
{
public bool fadeIn = false;
public bool fadeOut = false;
public bool volumeSwell = false;
public BeatStrokeDirection pickStroke = BeatStrokeDirection.none;
public bool hasRasgueado = false;
public BeatStroke stroke = null;
public SlapEffect slapEffect = SlapEffect.none;
public bool vibrato = false;
public Chord chord = null;
public BendEffect tremoloBar = null;
public MixTableChange mixTableChange;
public bool isChord() { return chord != null; }
public bool isTremoloBar() { return tremoloBar != null; }
public bool isSlapEffect() { return slapEffect != SlapEffect.none; }
public bool hasPickStroke() { return pickStroke != BeatStrokeDirection.none; }
public bool isDefault()
{
BeatEffect def = new BeatEffect();
return (stroke == def.stroke && hasRasgueado == def.hasRasgueado &&
pickStroke == def.pickStroke && fadeIn == def.fadeIn &&
vibrato == def.vibrato && tremoloBar == def.tremoloBar &&
slapEffect == def.slapEffect);
}
}
public class BeatStroke
{
public BeatStrokeDirection direction = BeatStrokeDirection.none;
public int value = 0; //4 = quarter etc.
public float startTime = 0.0f; //0 = falls on time, 1 = starts on time
public BeatStroke() { }
public BeatStroke(BeatStrokeDirection d, int v, float s)
{
direction = d;
value = v;
startTime = s;
}
public void setByGP6Standard(int GP6Duration)
{
//GP6 will use value as 30 to 480 (64th to quarter note)
int[] possibleVals = { 1, 2, 4, 8, 16, 32, 64 };
int translated = 64/(GP6Duration / 30);
int lastVal = 0;
foreach (int val in possibleVals)
{
if (val == translated) { value = val; break; }
if (val > translated && lastVal < translated)
{
value = (translated - lastVal > val - translated) ? val : lastVal;
break;
}
lastVal = val;
}
}
public int getIncrementTime(Beat beat)
{
int duration = 0;
if (value > 0)
{
foreach (Voice voice in beat.voices)
{
if (voice.isEmpty()) continue;
int currentDuration = voice.duration.time();
if (duration == 0 || currentDuration < duration)
{
duration = ((currentDuration <= Duration.quarterTime) ? currentDuration : Duration.quarterTime);
}
if (duration > 0)
{
return (int)Math.Round((duration / 8.0f) * (4.0f / value));
}
}
}
return 0;
}
public BeatStroke swapDirection()
{
if (direction == BeatStrokeDirection.up)
{
direction = BeatStrokeDirection.down;
}
else if (direction == BeatStrokeDirection.down)
{
direction = BeatStrokeDirection.up;
}
return new BeatStroke(direction, value,0.0f);
}
}
public class BeatText
{
public string value;
public BeatText(string value = "")
{
this.value = value;
}
}
public class BendEffect
{
public const int semitoneLength = 1;
public const int maxPosition = 12;
public int maxValue = semitoneLength * 12;
public BendType type = BendType.none;
public int value = 0;
public List<BendPoint> points = new List<BendPoint>();
}
public class BendPoint
{
public int position = 0;
public int value;
public float GP6position = 0;
public float GP6value = 0;
bool vibrato = false;
public BendPoint(int position = 0, int value = 0, bool vibrato = false)
{
this.position = position;
this.value = value;
this.vibrato = vibrato;
GP6position = position * 100.0f / BendEffect.maxPosition;
GP6value = value * 25.0f / BendEffect.semitoneLength;
}
public BendPoint(float position, float value, bool isGP6Format = true)
{
if (isGP6Format) {
//GP6 Format: position: 0-100, value: 100 = 1 whole tone up
this.position = (int)(position * BendEffect.maxPosition / 100);
this.value = (int)(value*2*BendEffect.semitoneLength / 100);
GP6position = position;
GP6value = value;
} else
{
this.position = (int)position;
this.value = (int)value;
GP6position = position * 100.0f / BendEffect.maxPosition;
GP6value = value * 50.0f / BendEffect.semitoneLength;
}
}
public int getTime(int duration)
{
return (int)(duration * (float)position / (float)BendEffect.maxPosition);
}
}
public class Chord
{
public int[] strings;
public string name = "";
public List<Barre> barres = new List<Barre>();
public bool[] omissions = new bool[7];
public List<Fingering> fingerings = new List<Fingering>();
public bool newFormat;
public int firstFret;
public bool sharp;
public PitchClass root;
public ChordType type;
public ChordExtension extension;
public PitchClass bass;
public ChordAlteration tonality;
public bool add;
public ChordAlteration fifth;
public ChordAlteration ninth;
public ChordAlteration eleventh;
public bool show = true;
public Chord(int length)
{
strings = new int[length];
for (int x = 0; x < length; x++)
{
strings[x] = -1;
}
}
public int[] notes()
{
List<int> valids = new List<int>();
foreach (int s in strings)
{
if (s >= 0) valids.Add(s);
}
return valids.ToArray();
}
}
public class DirectionSign
{
public string name = "";
public short measure = 0;
public DirectionSign(string name = "", short measure = 0)
{
this.name = name;
this.measure = measure;
}
}
public class Duration
{
public const int quarterTime = 960;
public const int whole = 1;
public const int half = 2;
public const int quarter = 4;
public const int eigth = 8;
public const int sixteenth = 16;
public const int thirtySecond = 32;
public const int sixtyFourth = 64;
public const int hundredTwentyEigth = 128;
public int value = quarter;
public bool isDotted = false;
public bool isDoubleDotted = false;
public Tuplet tuplet = new Tuplet();
const int minTime = (int)((int)(quarterTime * (4.0f / sixtyFourth)) * 2.0f / 3.0f);
public Duration() { }
public Duration(int time) //Does not recognize tuplets
{ //From GP6 Format -> 30 = 64th, 480 = quarter, 1920 = whole
int substract = 0;
if (time >= 15) { value = hundredTwentyEigth; substract = 15; }
if (time >= 30) {value = sixtyFourth; substract = 30; }
if (time >= 60) {value = thirtySecond; substract = 60; }
if (time >= 120) {value = sixteenth; substract = 120; }
if (time >= 240) {value = eigth; substract = 240; }
if (time >= 480) {value = quarter; substract = 480; }
if (time >= 960) {value = half; substract = 960; }
if (time >= 1920) {value = whole; substract = 1920; }
time -= substract;
if (time >= (float)(value * 0.5f)) isDotted = true;
if (time >= (float)(value * 0.75f)) { isDotted = false; isDoubleDotted = true; }
}
public int time()
{
int result = (int)(quarterTime * (4.0f / value));
if (isDotted) result += (int)(result / 2.0f);
if (isDoubleDotted) result += (int)((result / 4.0f) * 3);
return tuplet.convertTime(result);
}
}
public class GraceEffect
{
public int fret = 0;
public int duration = -1;
public int velocity = Velocities.def;
public GraceEffectTransition transition = GraceEffectTransition.none;
public bool isOnBeat = false;
public bool isDead = false;
public int durationTime()
{
return (int)(Duration.quarterTime / 16.0f * duration);
}
}
public class GuitarString
{
public int number, value;
public GuitarString(int number, int value)
{
this.number = number; this.value = value;
}
}
public abstract class HarmonicEffect
{
public float fret = 0;
public int type = 0;
}
public class NaturalHarmonic : HarmonicEffect { public NaturalHarmonic() { type = 1; } }
public class ArtificialHarmonic : HarmonicEffect {
public PitchClass pitch;
public Octave octave;
public ArtificialHarmonic(PitchClass pitch = null, Octave octave = 0) {
this.pitch = pitch;
this.octave = octave;
this.type = 2;
}
}
public class TappedHarmonic : HarmonicEffect {
public TappedHarmonic(int fret = 0)
{
this.fret = fret;
this.type = 3;
}
}
public class PinchHarmonic : HarmonicEffect { public PinchHarmonic() { type = 4; } }
public class SemiHarmonic : HarmonicEffect { public SemiHarmonic() { type = 5; } }
public class FeedbackHarmonic : HarmonicEffect { public FeedbackHarmonic() { type = 6; } }
public class LyricLine
{
public int startingMeasure = 1;
public string lyrics = "";
}
public class Lyrics
{
static int maxLineCount = 5;
public int trackChoice;
public LyricLine[] lines;
public Lyrics()
{
trackChoice = -1;
lines = new LyricLine[maxLineCount];
for (int x = 0; x < maxLineCount; x++)
{
lines[x] = new LyricLine();
}
}
}
public class Marker
{
public string title = "Section";
public myColor color = new myColor(255, 0, 0);
public MeasureHeader measureHeader = null;
}
public enum SimileMark
{
none = 0, simple = 1, firstOfDouble = 2, secondOfDouble = 3
}
public class Measure
{
public const int maxVoices = 2;
public Track track;
public MeasureHeader header;
public MeasureClef clef = MeasureClef.treble;
public List<Voice> voices = new List<Voice>();
public LineBreak lineBreak = LineBreak.none;
public List<Beat> beats = new List<Beat>();
public SimileMark simileMark = SimileMark.none;
public Measure(Track track = null, MeasureHeader header = null)
{
if (voices.Count == 0)
{
for (int x = 0; x < maxVoices; x++)
{
voices.Add(new Voice(this));
}
}
this.header = header;
this.track = track;
}
public bool isEmpty()
{
foreach (Voice v in voices)
{
if (!v.isEmpty()) return false;
}
if (beats.Count != 0) return false;
return true;
}
public int end()
{
return start() + length();
}
public int number()
{
return header.number;
}
public KeySignature keySignature()
{
return header.keySignature;
}
public int repeatClose()
{
return header.repeatClose;
}
public int start()
{
return header.start;
}
public int length()
{
return header.length();
}
public Tempo tempo()
{
return header.tempo;
}
public TimeSignature timeSignature()
{
return header.timeSignature;
}
public bool isRepeatOpen()
{
return header.isRepeatOpen;
}
public TripletFeel tripletFeel()
{
return header.tripletFeel;
}
public bool hasMarker()
{
return header.hasMarker();
}
public Marker marker()
{
return header.marker;
}
public void addVoice(Voice voice)
{
voice.measure = this;
voices.Add(voice);
}
}
public class MeasureHeader
{
public GPFile song;
public RepeatGroup repeatGroup = null;
public int number = 0;
public int start = Duration.quarterTime;
public TimeSignature timeSignature = new TimeSignature();
public KeySignature keySignature = KeySignature.CMajor;
public Tempo tempo = new Tempo();
public TripletFeel tripletFeel = TripletFeel.none;
public bool isRepeatOpen = false;
public int repeatClose = -1;
public List<int> repeatAlternatives = new List<int>();
public int realStart = -1;
public bool hasDoubleBar = false;
public Marker marker = null;
public List<string> direction = new List<string>();
public List<string> fromDirection = new List<string>();
public bool hasMarker()
{
return (marker != null);
}
public int length()
{
return timeSignature.numerator * timeSignature.denominator.time();
}
}
public class MidiChannel
{
public int channel, effectChannel, instrument, volume, balance, chorus,
reverb, phaser, tremolo, bank;
static int DEFAULT_PERCUSSION_CHANNEL = 9;
public MidiChannel()
{
this.channel = 0; this.effectChannel = 1; this.instrument = 25; this.volume = 104;
this.balance = 64; this.chorus = 0; this.reverb = 0; this.phaser = 0;
this.tremolo = 0; this.bank = 0;
}
public bool isPercussionChannel()
{
return channel % 16 == DEFAULT_PERCUSSION_CHANNEL;
}
}
public enum WahState
{
off =-2, none=-1, opened = 0, closed = 100
}
public class WahEffect
{
public WahState state = WahState.none;
public bool display = false;
}
public class MixTableChange
{
public string tempoName;
public bool hideTempo;
public bool useRSE;
public MixTableItem instrument = null;
public MixTableItem volume = null;
public MixTableItem balance = null;
public MixTableItem chorus = null;
public MixTableItem reverb = null;
public MixTableItem phaser = null;
public MixTableItem tremolo = null;
public MixTableItem tempo = null;
public WahEffect wah = null;
public RSEInstrument rse = null;
public MixTableChange(string tempoName = "", bool hideTempo = true, bool useRSE = true)
{
this.tempoName = tempoName;
this.hideTempo = hideTempo;
this.useRSE = useRSE;
}
public bool isJustWah()
{
return (instrument == null && volume == null && balance == null && chorus == null && reverb == null &&
phaser == null && tremolo == null && wah != null);
}
}
public class MixTableItem
{
public int value;
public int duration;
public bool allTracks;
public MixTableItem(int value = 0, int duration = 0, bool allTracks = false)
{
this.value = value;
this.duration = duration;
this.allTracks = allTracks;
}
}
public class myColor
{
float r, g, b, a = 1.0f;
public myColor(int r, int g, int b, int a = 255)
{
this.r = (float)r / 255.0f;
this.g = (float)g / 255.0f;
this.b = (float)b / 255.0f;
this.a = (float)a / 255.0f;
}
}
public class Note
{
public Beat beat;
public int value = 0;
public int velocity = Velocities.def;
public int str = 0;
public bool swapAccidentals = false;
public NoteEffect effect = new NoteEffect();
public double durationPercent = 1.0;
public NoteType type = NoteType.rest;
public int duration;
public int tuplet;
public Note(Beat beat = null)
{
this.beat = beat;
}
public int realValue()
{
return (value + beat.voice.measure.track.strings[str - 1].value);
}
}
public class NoteEffect
{
public bool vibrato = false;
public List<SlideType> slides = new List<SlideType>();
public bool hammer = false;
public bool ghostNote = false;
public bool accentuatedNote = false;
public bool heavyAccentuatedNote = false;
public bool palmMute = false;
public bool staccato = false;
public bool letRing = false;
public Fingering leftHandFinger = Fingering.open;
public Fingering rightHandFinger = Fingering.open;
public Note note = null;
public BendEffect bend = null;
public HarmonicEffect harmonic = null;
public GraceEffect grace = null;
public TrillEffect trill = null;
public TremoloPickingEffect tremoloPicking = null;
public bool isBend()
{
return (bend != null && bend.points.Count > 0);
}
public bool isHarmonic() { return harmonic != null; }
public bool isGrace() { return grace != null; }
public bool isTrill() { return trill != null; }
public bool isTremoloPicking() { return tremoloPicking != null; }
public bool isFingering() { return ((int)leftHandFinger > -1 || (int)rightHandFinger > -1); }
}
public class Padding
{
public int right, top, left, bottom;
public Padding(int right = 0, int top=0, int left=0, int bottom = 0)
{
this.right = right; this.top = top; this.left = left; this.bottom = bottom;
}
}
public class Point
{
public int x, y;
public Point(int x=0, int y=0)
{
this.x = x; this.y = y;
}
}
public enum HeaderFooterElements
{
none = 0x000,
title = 0x001,
subtitle = 0x002,
artist = 0x004,
album = 0x008,
words = 0x010,
music = 0x020,
wordsAndMusic = 0x040,
copyright = 0x080,
pageNumber = 0x100,
all = title | subtitle | artist | album | words | music | wordsAndMusic | copyright | pageNumber
}
public class PageSetup
{
/*The page setup describes how the document is rendered.
Page setup contains page size, margins, paddings, and how the title
elements are rendered.
Following template vars are available for defining the page texts:
- ``%title%``: will be replaced with Song.title
- ``%subtitle%``: will be replaced with Song.subtitle
- ``%artist%``: will be replaced with Song.artist
- ``%album%``: will be replaced with Song.album
- ``%words%``: will be replaced with Song.words
- ``%music%``: will be replaced with Song.music
- ``%WORDSANDMUSIC%``: will be replaced with the according word
and music values
- ``%copyright%``: will be replaced with Song.copyright
- ``%N%``: will be replaced with the current page number (if
supported by layout)
- ``%P%``: will be replaced with the number of pages (if supported
by layout)*/
public Point pageSize = new Point(210,297);
public Padding pageMargin = new Padding(10, 15, 10, 10);
public float scoreSizeProportion = 1.0f;
public HeaderFooterElements headerAndFooter = HeaderFooterElements.all;
public string title = "%title%";
public string subtitle = "%subtitle%";
public string artist = "%artist%";
public string album = "%album%";
public string words = "Words by %words%";
public string music = "Music by %music%";
public string wordsAndMusic = "Words & Music by %WORDSMUSIC%";
public string copyright = "Copyright %copyright%\nAll Rights Reserved - International Copyright Secured";
public string pageNumber = "Page %N%/%P%";
}
public class PitchClass
{
/*Constructor provides several overloads. Each overload provides keyword
argument *intonation* that may be either "sharp" or "flat".
First of overloads is (tone, accidental):
:param tone: integer of whole-tone.
:param accidental: flat (-1), none (0) or sharp (1).
>>> p = PitchClass(4, -1)
>>> vars(p)
{'accidental': -1, 'intonation': 'flat', 'just': 4, 'value': 3}
>>> print p
Eb
>>> p = PitchClass(4, -1, intonation='sharp')
>>> vars(p)
{'accidental': -1, 'intonation': 'flat', 'just': 4, 'value': 3}
>>> print p
D#
Second, semitone number can be directly passed to constructor:
:param semitone: integer of semitone.
>>> p = PitchClass(3)
>>> print p
Eb
>>> p = PitchClass(3, intonation='sharp')
>>> print p
D#
And last, but not least, note name:
:param name: string representing note.
>>> p = PitchClass('D#')
>>> print p
D#*/
public int just = 0;
public int accidental = 0;
public int value = 0;
public string intonation = null;
public float actualOvertone = 0.0f;
public PitchClass(int arg0i = 0, int arg1i = -1, string arg0s = "", string intonation = "", float actualOvertone = 0.0f)
{
string[] _notes_sharp = { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" };
string[] _notes_flat = { "C", "Db", "D", "Eb", "E", "F", "Gb", "G", "Ab", "A", "Bb", "B" };
int value = 0;
string str = "";
int accidental = 0;
int pitch = 0;
this.actualOvertone = actualOvertone; //Make it simpler to use later in internal format
if (arg1i == -1)
{
if (!arg0s.Equals(""))
{
str = arg0s;
for (int x = 0; x < _notes_sharp.Length; x++)
{
if (str.Equals(_notes_sharp[x])) { value = x; break; }
if (str.Equals(_notes_flat[x])) { value = x; break; }
}
}
else
{
value = arg0i % 12;
str = _notes_sharp[Math.Max(value,0)];
if (intonation.Equals("flat")) str = _notes_flat[value];