LibMusicXML 3.18
msrBasicTypes.h
1/*
2 MusicXML Library
3 Copyright (C) Grame 2006-2013
4
5 This Source Code Form is subject to the terms of the Mozilla Public
6 License, v. 2.0. If a copy of the MPL was not distributed with this
7 file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
9 Grame Research Laboratory, 11, cours de Verdun Gensoul 69002 Lyon - France
10 research@grame.fr
11*/
12
13#ifndef ___msrBasicTypes___
14#define ___msrBasicTypes___
15
16#include <vector>
17#include <map>
18
19#include "smartpointer.h"
20
21#include "rational.h"
22
23
24namespace MusicXML2
25{
26
27// input line numbers
28//______________________________________________________________________________
29
30#define K_NO_INPUT_LINE_NUMBER 0
31
32// names lists max length
33// ------------------------------------------------------
34
35#define K_NAMES_LIST_MAX_LENGTH 50
36
37// XMLLang
38//______________________________________________________________________________
39enum msrXMLLangKind {
40 kXMLLangIt, kXMLLangEn, kXMLLangDe, kXMLLangFr, kXMLLangJa, kXMLLangLa };
41
42msrXMLLangKind msrXMLLangKindFromString (
43 int inputLineNumber,
44 string XMLLangString);
45
46string msrXMLLangKindAsString (
47 msrXMLLangKind XMLLangKind);
48
49// diatonic pitches
50//______________________________________________________________________________
51enum msrDiatonicPitchKind {
52 // starting at C for LilyPond relative octave calculations
53 kC, kD, kE, kF, kG, kA, kB,
54 k_NoDiatonicPitch };
55
56msrDiatonicPitchKind msrDiatonicPitchKindFromString (
57 char diatonicNoteName);
58
59string msrDiatonicPitchKindAsString (
60 msrDiatonicPitchKind diatonicPitchKind);
61
62// alterations
63//______________________________________________________________________________
64enum msrAlterationKind {
65 k_NoAlteration,
66
67 kTripleFlat, kDoubleFlat, kSesquiFlat, kFlat, kSemiFlat,
68 kNatural,
69 kSemiSharp, kSharp, kSesquiSharp, kDoubleSharp, kTripleSharp };
70
71msrAlterationKind msrAlterationKindFromMusicXMLAlter (
72 float alter);
73
74string msrAlterationKindAsString (
75 msrAlterationKind alterationKind);
76
77// semi tones pitches
78//______________________________________________________________________________
79enum msrSemiTonesPitchKind {
80 k_NoSemiTonesPitch_STP,
81
82 kC_TripleFlat_STP,
83 kC_DoubleFlat_STP, kC_Flat_STP,
84 kC_Natural_STP,
85 kC_Sharp_STP, kC_DoubleSharp_STP,
86 kC_TripleSharp_STP,
87
88 kD_TripleFlat_STP,
89 kD_DoubleFlat_STP, kD_Flat_STP,
90 kD_Natural_STP,
91 kD_Sharp_STP, kD_DoubleSharp_STP,
92 kD_TripleSharp_STP,
93
94 kE_TripleFlat_STP,
95 kE_DoubleFlat_STP, kE_Flat_STP,
96 kE_Natural_STP,
97 kE_Sharp_STP, kE_DoubleSharp_STP,
98 kE_TripleSharp_STP,
99
100 kF_TripleFlat_STP,
101 kF_DoubleFlat_STP, kF_Flat_STP,
102 kF_Natural_STP,
103 kF_Sharp_STP, kF_DoubleSharp_STP,
104 kF_TripleSharp_STP,
105
106 kG_TripleFlat_STP,
107 kG_DoubleFlat_STP, kG_Flat_STP,
108 kG_Natural_STP,
109 kG_Sharp_STP, kG_DoubleSharp_STP,
110 kG_TripleSharp_STP,
111
112 kA_TripleFlat_STP,
113 kA_DoubleFlat_STP, kA_Flat_STP,
114 kA_Natural_STP,
115 kA_Sharp_STP, kA_DoubleSharp_STP,
116 kA_TripleSharp_STP,
117
118 kB_TripleFlat_STP,
119 kB_DoubleFlat_STP, kB_Flat_STP,
120 kB_Natural_STP,
121 kB_Sharp_STP, kB_DoubleSharp_STP,
122 kB_TripleSharp_STP };
123
124string msrSemiTonesPitchKindAsString (
125 msrSemiTonesPitchKind semiTonesPitchKind);
126
127// quarter tones pitches
128//______________________________________________________________________________
129enum msrQuarterTonesPitchKind {
130 k_NoQuarterTonesPitch_QTP,
131
132 k_Rest_QTP,
133
134 kA_TripleFlat_QTP,
135 kA_DoubleFlat_QTP, kA_SesquiFlat_QTP, kA_Flat_QTP, kA_SemiFlat_QTP,
136 kA_Natural_QTP,
137 kA_SemiSharp_QTP, kA_Sharp_QTP, kA_SesquiSharp_QTP, kA_DoubleSharp_QTP,
138 kA_TripleSharp_QTP,
139
140 kB_TripleFlat_QTP,
141 kB_DoubleFlat_QTP, kB_SesquiFlat_QTP, kB_Flat_QTP, kB_SemiFlat_QTP,
142 kB_Natural_QTP,
143 kB_SemiSharp_QTP, kB_Sharp_QTP, kB_SesquiSharp_QTP, kB_DoubleSharp_QTP,
144 kB_TripleSharp_QTP,
145
146 kC_TripleFlat_QTP,
147 kC_DoubleFlat_QTP, kC_SesquiFlat_QTP, kC_Flat_QTP, kC_SemiFlat_QTP,
148 kC_Natural_QTP,
149 kC_SemiSharp_QTP, kC_Sharp_QTP, kC_SesquiSharp_QTP, kC_DoubleSharp_QTP,
150 kC_TripleSharp_QTP,
151
152 kD_TripleFlat_QTP,
153 kD_DoubleFlat_QTP, kD_SesquiFlat_QTP, kD_Flat_QTP, kD_SemiFlat_QTP,
154 kD_Natural_QTP,
155 kD_SemiSharp_QTP, kD_Sharp_QTP, kD_SesquiSharp_QTP, kD_DoubleSharp_QTP,
156 kD_TripleSharp_QTP,
157
158 kE_TripleFlat_QTP,
159 kE_DoubleFlat_QTP, kE_SesquiFlat_QTP, kE_Flat_QTP, kE_SemiFlat_QTP,
160 kE_Natural_QTP,
161 kE_SemiSharp_QTP, kE_Sharp_QTP, kE_SesquiSharp_QTP, kE_DoubleSharp_QTP,
162 kE_TripleSharp_QTP,
163
164 kF_TripleFlat_QTP,
165 kF_DoubleFlat_QTP, kF_SesquiFlat_QTP, kF_Flat_QTP, kF_SemiFlat_QTP,
166 kF_Natural_QTP,
167 kF_SemiSharp_QTP, kF_Sharp_QTP, kF_SesquiSharp_QTP, kF_DoubleSharp_QTP,
168 kF_TripleSharp_QTP,
169
170 kG_TripleFlat_QTP,
171 kG_DoubleFlat_QTP, kG_SesquiFlat_QTP, kG_Flat_QTP, kG_SemiFlat_QTP,
172 kG_Natural_QTP,
173 kG_SemiSharp_QTP, kG_Sharp_QTP, kG_SesquiSharp_QTP, kG_DoubleSharp_QTP,
174 kG_TripleSharp_QTP };
175
176void setDiatonicPitchKindAndAlterationKind (
177 msrQuarterTonesPitchKind quarterTonesPitchKind,
178 msrDiatonicPitchKind& diatonicPitchKind,
179 msrAlterationKind& alterationKind);
180
181msrQuarterTonesPitchKind quarterTonesPitchKindFromDiatonicPitchAndAlteration (
182 int inputLineNumber,
183 msrDiatonicPitchKind diatonicPitchKind,
184 msrAlterationKind alterationKind);
185
186msrDiatonicPitchKind diatonicPitchKindFromQuarterTonesPitchKind (
187 int inputLineNumber,
188 msrQuarterTonesPitchKind quarterTonesPitchKind);
189
190msrQuarterTonesPitchKind quarterTonesPitchKindFromSemiTonesPitchKind (
191 msrSemiTonesPitchKind semiTonesPitchKind);
192
193msrSemiTonesPitchKind semiTonesPitchKindFromQuarterTonesPitchKind (
194 msrQuarterTonesPitchKind quarterTonesPitchKind);
195
196msrSemiTonesPitchKind semiTonesPitchKindFromString (
197 string theString);
198
199// alterations preferences
200//______________________________________________________________________________
201enum msrAlterationPreferenceKind {
202 kPreferFlat, kPreferNatural, kPreferSharp };
203
204msrQuarterTonesPitchKind msrSemiTonesPitchKindAsQuarterTonesPitchKind (
205 msrSemiTonesPitchKind semiTonesPitchKind,
206 msrAlterationPreferenceKind alterationPreferenceKind);
207
208// intervals
209//______________________________________________________________________________
210enum msrIntervalKind {
211 k_NoIntervalKind,
212
213 kDiminishedUnisson, kPerfectUnison, kAugmentedUnison,
214
215 kDiminishedSecond, kMinorSecond, kMajorSecond, kAugmentedSecond,
216
217 kDiminishedThird, kMinorThird, kMajorThird, kAugmentedThird,
218
219 kDiminishedFourth, kPerfectFourth, kAugmentedFourth,
220
221 kDiminishedFifth, kPerfectFifth, kAugmentedFifth,
222
223 kDiminishedSixth, kMinorSixth, kMajorSixth, kAugmentedSixth,
224
225 kDiminishedSeventh, kMinorSeventh, kMajorSeventh, kAugmentedSeventh,
226
227 kDiminishedOctave, kPerfectOctave, kAugmentedOctave,
228
229 kDiminishedNinth, kMinorNinth, kMajorNinth, kAugmentedNinth,
230
231 kDiminishedTenth, kMinorTenth, kMajorTenth, kAugmentedTenth,
232
233 kDiminishedEleventh, kPerfectEleventh, kAugmentedEleventh,
234
235 kDiminishedTwelfth, kPerfectTwelfth, kAugmentedTwelfth,
236
237 kDiminishedThirteenth, kMinorThirteenth, kMajorThirteenth, kAugmentedThirteenth };
238
239int msrIntervalKindAsSemiTones (
240 msrIntervalKind intervalKind);
241
242int msrIntervalKindAsQuarterTones (
243 msrIntervalKind intervalKind);
244
245string msrIntervalKindAsString (
246 msrIntervalKind intervaKindl);
247
248string msrIntervalKindAsShortString (
249 msrIntervalKind intervalKind);
250
251msrIntervalKind invertIntervalKind (
252 msrIntervalKind intervalKind);
253
254int intervalKindAsSemitones (
255 msrIntervalKind intervalKind);
256
257/* JMI
258msrSemiTonesPitchKind noteAtIntervalKindFromNote (
259 msrIntervalKind intervalKind,
260 msrSemiTonesPitchKind semiTonesPitchKind,
261 msrAlterationPreferenceKind alterationPreferenceKind);
262*/
263
264msrSemiTonesPitchKind noteAtIntervalFromSemiTonesPitch (
265 int inputLineNumber,
266 msrIntervalKind intervalKind,
267 msrSemiTonesPitchKind semiTonesPitchKind);
268
269msrQuarterTonesPitchKind noteAtIntervalFromQuarterTonesPitch (
270 int inputLineNumber,
271 msrIntervalKind intervalKind,
272 msrQuarterTonesPitchKind quarterTonesPitchKind);
273
274msrIntervalKind intervalBetweenSemiTonesPitches (
275 msrSemiTonesPitchKind semiTonesPitch1,
276 msrSemiTonesPitchKind semiTonesPitch2);
277
278// harmonies
279//______________________________________________________________________________
280enum msrHarmonyKind {
281 k_NoHarmony,
282
283 // MusicXML chords
284
285 kMajorHarmony, kMinorHarmony,
286 kAugmentedHarmony, kDiminishedHarmony,
287
288 kDominantHarmony,
289 kMajorSeventhHarmony, kMinorSeventhHarmony,
290 kDiminishedSeventhHarmony, kAugmentedSeventhHarmony,
291 kHalfDiminishedHarmony,
292 kMinorMajorSeventhHarmony,
293
294 kMajorSixthHarmony, kMinorSixthHarmony,
295
296 kDominantNinthHarmony,
297 kMajorNinthHarmony, kMinorNinthHarmony,
298
299 kDominantEleventhHarmony, kMajorEleventhHarmony, kMinorEleventhHarmony,
300
301 kDominantThirteenthHarmony, kMajorThirteenthHarmony, kMinorThirteenthHarmony,
302
303 kSuspendedSecondHarmony, kSuspendedFourthHarmony,
304
305 kNeapolitanHarmony, kItalianHarmony, kFrenchHarmony, kGermanHarmony,
306
307 kPedalHarmony, kPowerHarmony, kTristanHarmony,
308
309 // jazz-specific chords
310
311 kMinorMajorNinth, // -maj9, minmaj9
312
313 kDominantSuspendedFourthHarmony, // 7sus4, domsus4
314 kDominantAugmentedFifthHarmony, // 7#5, domaug5
315 kDominantMinorNinthHarmony, // 7b9, dommin9
316 kDominantAugmentedNinthDiminishedFifthHarmony, // 7#9b5, domaug9dim5
317 kDominantAugmentedNinthAugmentedFifthHarmony, // 7#9#5, domaug9aug5
318 kDominantAugmentedEleventhHarmony, // 7#11, domaug11
319
320 kMajorSeventhAugmentedEleventhHarmony, // maj7#11, maj7aug11
321
322 // other
323
324 kOtherHarmony,
325
326 kNoneHarmony };
327
328string msrHarmonyKindAsString (
329 msrHarmonyKind harmonyKind);
330
331string msrHarmonyKindAsShortString (
332 msrHarmonyKind harmonyKind);
333
334string msrHarmonyKindShortName (
335 msrHarmonyKind harmonyKind);
336
337msrHarmonyKind msrHarmonyKindFromString (
338 string theString);
339
340string existingHarmonyKinds (int namesListMaxLength);
341string existingHarmonyKindsNames (int namesListMaxLength);
342
343// constant
344const int K_HARMONY_NO_INVERSION = -1;
345
346extern map<string, msrHarmonyKind>
347 gHarmonyKindsMap;
348
349//extern list<string>
350// gHarmonyKindsNamesList;
351
352void initializeHarmonyKinds ();
353
354// quarter tones pitches languages
355//______________________________________________________________________________
356enum msrQuarterTonesPitchesLanguageKind {
357 kNederlands, kCatalan, kDeutsch, kEnglish, kEspanol, kFrancais,
358 kItaliano, kNorsk, kPortugues, kSuomi, kSvenska, kVlaams };
359
360string msrQuarterTonesPitchesLanguageKindAsString (
361 msrQuarterTonesPitchesLanguageKind languageKind);
362
363string msrDiatonicPitchKindAsString ( // JMI
364 msrQuarterTonesPitchesLanguageKind languageKind,
365 msrDiatonicPitchKind diatonicPitchKind);
366
367string msrQuarterTonesPitchKindAsString (
368 msrQuarterTonesPitchesLanguageKind languageKind,
369 msrQuarterTonesPitchKind quarterTonesPitchKind);
370
371msrQuarterTonesPitchKind msrQuarterTonesPitchKindFromString (
372 msrQuarterTonesPitchesLanguageKind languageKind,
373 string quarterTonesPitchName);
374
375/* JMI
376string msrSemiTonesPitchKindAsString (
377 msrQuarterTonesPitchesLanguageKind languageKind,
378 msrSemiTonesPitchKind semiTonesPitchKind);
379 */
380
381string msrSemiTonesPitchKindAsFlatsAndSharps (
382 msrQuarterTonesPitchesLanguageKind languageKind,
383 msrSemiTonesPitchKind semiTonesPitchKind);
384
385/* JMI
386string msrQuarterTonesPitchKindAsFlatsAndSharps (
387 msrQuarterTonesPitchesLanguageKind languageKind,
388 msrQuarterTonesPitchKind quarterTonesPitchKind);
389*/
390
391// enharmonies
392//______________________________________________________________________________
393msrSemiTonesPitchKind enharmonicSemiTonesPitch (
394 msrSemiTonesPitchKind semiTonesPitchKind,
395 msrAlterationPreferenceKind alterationPreferenceKind);
396
397// durations
398//______________________________________________________________________________
399enum msrDurationKind {
400 // from longest to shortest for the algorithms
401 kMaxima, kLong, kBreve, kWhole, kHalf,
402 kQuarter,
403 kEighth, k16th, k32nd, k64th, k128th, k256th, k512th, k1024th,
404 k_NoDuration };
405
406msrDurationKind msrDurationKindFromString (
407 int inputLineNumber,
408 string durationString);
409
410rational msrDurationKindAsWholeNotes (
411 msrDurationKind durationKind);
412
413msrDurationKind wholeNotesAsDurationKind (rational wholeNotes);
414
415string msrDurationKindAsString (msrDurationKind durationKind);
416
417// whole notes
418//______________________________________________________________________________
419string wholeNotesAsMsrString (
420 int inputLineNumber,
421 rational wholeNotes,
422 int& dotsNumber);
423
424string wholeNotesAsMsrString (
425 int inputLineNumber,
426 rational wholeNotes);
427
428string multipleRestMeasuresWholeNotesAsMsrString (
429 int inputLineNumber, // JMI
430 rational wholeNotes);
431
432// dotted durations
433//______________________________________________________________________________
435{
436// JMI protected:
437 public:
438
439 // constructors/destructor
440 // ------------------------------------------------------
441
443
445 msrDurationKind durationKind,
446 int dotsNumber);
447
448 virtual ~msrDottedDuration ();
449
450 public:
451
452 // set and get
453 // ------------------------------------------------------
454
455 msrDurationKind getDurationKind () const
456 { return fDurationKind; }
457
458 int getDotsNumber () const
459 { return fDotsNumber; }
460
461 // services
462 // ------------------------------------------------------
463
464 void incrDotsNumber ()
465 { fDotsNumber++; }
466
467 rational dottedDurationAsWholeNotes (
468 int inputLineNumber) const;
469
470 // visitors
471 // ------------------------------------------------------
472
473/* JMI
474 virtual void acceptIn (basevisitor* v);
475 virtual void acceptOut (basevisitor* v);
476
477 virtual void browseData (basevisitor* v);
478*/
479
480 public:
481
482 // ------------------------------------------------------
483
484 //virtual
485 void print (ostream& os) const;
486
487 private:
488
489 // fields
490 // ------------------------------------------------------
491
492 msrDurationKind fDurationKind;
493 int fDotsNumber;
494};
495EXP ostream& operator<< (ostream& os, const msrDottedDuration& elt);
496
497// semitone pitches and octave
498// can be used as absolute, relative or fixed reference
499//______________________________________________________________________________
501{
502 public:
503
504 // creation from MusicXML
505 // ------------------------------------------------------
506
508 msrSemiTonesPitchKind semiTonesPitchKind,
509 int octave);
510
511 SMARTP<msrSemiTonesPitchAndOctave> createSemiTonesPitchAndOctaveNewbornClone ();
512
513 // creation from a string
514 // ------------------------------------------------------
515
516 static SMARTP<msrSemiTonesPitchAndOctave> createFromString (
517 int inputLineNumber,
518 string theString);
519
520 protected:
521
522 // constructors/destructor
523 // ------------------------------------------------------
524
526 msrSemiTonesPitchKind semiTonesPitchKind,
527 int octave);
528
530
531 public:
532
533 // set and get
534 // ------------------------------------------------------
535
536 msrSemiTonesPitchKind getSemiTonesPitchKind () const
537 { return fSemiTonesPitchKind; }
538
539 void incrementOctave ()
540 { fOctave++; }
541
542 void decrementOctave ()
543 { fOctave--; }
544
545 int getOctave () const
546 { return fOctave; }
547
548 public:
549
550 // services
551 // ------------------------------------------------------
552
553 string semiTonesPitchKindAsString () const;
554 string semiTonesPitchKindAsShortString () const;
555
556 string asString () const;
557
558 public:
559
560 // print
561 // ------------------------------------------------------
562
563 virtual void print (ostream& os) const;
564
565 private:
566
567 // fields
568 // ------------------------------------------------------
569
570 msrSemiTonesPitchKind fSemiTonesPitchKind;
571 int fOctave;
572};
574EXP ostream& operator<< (ostream& os, const S_msrSemiTonesPitchAndOctave& elt);
575
576// length units
577//______________________________________________________________________________
578
579enum msrLengthUnitKind {
580 kInchUnit, kCentimeterUnit, kMillimeterUnit };
581
582string msrLengthUnitKindAsString (
583 msrLengthUnitKind lengthUnitKind);
584
585string existingMsrLengthUnitKinds (int namesListMaxLength);
586
587extern map<string, msrLengthUnitKind>
588 gMsrLengthUnitKindsMap;
589
590void initializeMsrLengthUnitKindsMap ();
591
592// lengths
593//______________________________________________________________________________
594
595class msrLength : public smartable
596{
597 public:
598
599 // creation
600 // ------------------------------------------------------
601
602 static SMARTP<msrLength> create (
603 msrLengthUnitKind lengthUnitKind,
604 float lengthValue);
605
606 public:
607
608 // constructors/destructor
609 // ------------------------------------------------------
610
611 msrLength (
612 msrLengthUnitKind lengthUnitKind,
613 float lengthValue);
614
615 msrLength ();
616
617 virtual ~msrLength ();
618
619 public:
620
621 // set and get
622 // ------------------------------------------------------
623
624 void setLengthUnitKind (msrLengthUnitKind value)
625 { fLengthUnitKind = value; }
626
627 msrLengthUnitKind getLengthUnitKind () const
628 { return fLengthUnitKind; }
629
630 void setLengthValue (float value)
631 { fLengthValue = value; }
632
633 float getLengthValue () const
634 { return fLengthValue; };
635
636 public:
637
638 // services
639 // ------------------------------------------------------
640
641 bool operator== (
642 const msrLength& other) const
643 {
644 return
645 fLengthUnitKind == other.fLengthUnitKind
646 &&
647 fLengthValue == other.fLengthValue;
648 }
649
650 bool operator!= (
651 const msrLength& other) const
652 { return ! ((*this) == other); }
653
654 void convertToLengthUnit (
655 msrLengthUnitKind lengthUnitKind);
656
657 public:
658
659 // print
660 // ------------------------------------------------------
661
662 string asString () const;
663
664 virtual void print (ostream& os) const;
665
666 private:
667
668 // fields
669 // ------------------------------------------------------
670
671 msrLengthUnitKind fLengthUnitKind;
672
673 float fLengthValue;
674};
676EXP ostream& operator<< (ostream& os, const S_msrLength& elt);
677
678// margins types
679//______________________________________________________________________________
680
681enum msrMarginTypeKind {
682 kOddMargin, kEvenMargin, kBothMargins };
683
684string msrMarginTypeKindAsString (
685 msrMarginTypeKind marginTypeKind);
686
687string existingMsrMarginTypeKinds (int namesListMaxLength);
688
689extern map<string, msrMarginTypeKind>
690 gMsrMarginTypeKindsMap;
691
692void initializeMsrMarginTypeKindsMap ();
693
694// margins
695//______________________________________________________________________________
696
697class msrMargin : public smartable
698{
699 public:
700
701 // creation
702 // ------------------------------------------------------
703
704 static SMARTP<msrMargin> create (
705 msrMarginTypeKind marginTypeKind,
706 msrLength marginLength);
707
708 public:
709
710 // constructors/destructor
711 // ------------------------------------------------------
712
713 msrMargin (
714 msrMarginTypeKind marginTypeKind,
715 msrLength marginLength);
716
717 msrMargin ();
718
719 virtual ~msrMargin ();
720
721 public:
722
723 // set and get
724 // ------------------------------------------------------
725
726 void setMarginTypeKind (msrMarginTypeKind& value)
727 { fMarginTypeKind = value; }
728
729 msrMarginTypeKind getMarginTypeKind () const
730 { return fMarginTypeKind; }
731
732 void setMarginLength (msrLength& value)
733 { fMarginLength = value; }
734
735 msrLength getMarginLength () const
736 { return fMarginLength; };
737
738 public:
739
740 // services
741 // ------------------------------------------------------
742
743 bool operator== (
744 const msrMargin& other) const
745 {
746 return
747 fMarginTypeKind == other.fMarginTypeKind
748 &&
749 fMarginLength == other.fMarginLength;
750 }
751
752 bool operator!= (
753 const msrMargin& other) const
754 { return ! ((*this) == other); }
755
756 public:
757
758 // print
759 // ------------------------------------------------------
760
761 string asString () const;
762
763 virtual void print (ostream& os) const;
764
765 private:
766
767 // fields
768 // ------------------------------------------------------
769
770
771 msrMarginTypeKind fMarginTypeKind;
772 msrLength fMarginLength;
773};
775EXP ostream& operator<< (ostream& os, const S_msrMargin& elt);
776
777// fonts
778//______________________________________________________________________________
779class msrFontSize : public smartable
780{
781 public:
782
783 // data types
784 // ------------------------------------------------------
785
786 enum msrFontSizeKind {
787 kFontSizeNone,
788 kFontSizeXXSmall, kFontSizeXSmall, kFontSizeSmall,
789 kFontSizeMedium,
790 kFontSizeLarge, kFontSizeXLarge, kFontSizeXXLarge,
791 kFontSizeNumeric };
792
793 static string fontSizeKindAsString (
794 msrFontSizeKind fontSizeKind);
795
796 // creation from MusicXML
797 // ------------------------------------------------------
798
799 static SMARTP<msrFontSize> create (
800 msrFontSizeKind fontSizeKind);
801
802 static SMARTP<msrFontSize> create (
803 float fontNumericSize);
804
805 protected:
806
807 // constructors/destructor
808 // ------------------------------------------------------
809
811 msrFontSizeKind fontSizeKind);
812
814 float numericFontSize);
815
816 virtual ~msrFontSize ();
817
818 public:
819
820 // set and get
821 // ------------------------------------------------------
822
823 msrFontSizeKind getFontSizeKind () const
824 { return fFontSizeKind; }
825
826 float getFontNumericSize ();
827
828 // services
829 // ------------------------------------------------------
830
831 string fontSizeKindAsString () const;
832
833 string fontSizeAsString () const;
834
835 public:
836
837 // ------------------------------------------------------
838
839 virtual void print (ostream& os) const;
840
841 private:
842
843 // fields
844 // ------------------------------------------------------
845
846 msrFontSizeKind fFontSizeKind;
847
848 float fFontNumericSize;
849 // only relevant when
850 // fFontSizeKind == kNumericFontSize
851};
853EXP ostream& operator<< (ostream& os, const S_msrFontSize& elt);
854
855enum msrFontStyleKind {
856 kFontStyleNone,
857 kFontStyleNormal, KFontStyleItalic };
858
859msrFontStyleKind msrFontStyleKindFromString (
860 int inputLineNumber,
861 string fontStyleString);
862
863string msrFontStyleKindAsString (
864 msrFontStyleKind fontStyleKind);
865
866enum msrFontWeightKind {
867 kFontWeightNone,
868 kFontWeightNormal, kFontWeightBold };
869
870msrFontWeightKind msrFontWeightKindFromString (
871 int inputLineNumber,
872 string fontWeightString);
873
874string msrFontWeightKindAsString (
875 msrFontWeightKind fontWeightKind);
876
877// alignement
878//______________________________________________________________________________
879/*
880 The justify entity is used to indicate left, center, or
881 right justification. The default value varies for different
882 elements. For elements where the justify attribute is present
883 but the halign attribute is not, the justify attribute
884 indicates horizontal alignment as well as justification.
885*/
886
887enum msrJustifyKind {
888 kJustifyNone,
889 kJustifyLeft, kJustifyCenter, kJustifyRight };
890
891msrJustifyKind msrJustifyKindFromString (
892 int inputLineNumber,
893 string justifyString);
894
895string msrJustifyKindAsString (
896 msrJustifyKind justifyKind);
897
898enum msrHorizontalAlignmentKind {
899 kHorizontalAlignmentNone,
900 kHorizontalAlignmentLeft, kHorizontalAlignmentCenter, kHorizontalAlignmentRight };
901
902msrHorizontalAlignmentKind msrHorizontalAlignmentKindFromString (
903 int inputLineNumber,
904 string horizontalAlignString);
905
906string msrHorizontalAlignmentKindAsString (
907 msrHorizontalAlignmentKind horizontalAlignmentKind);
908
909enum msrVerticalAlignmentKind {
910 kVerticalAlignmentNone,
911 kVerticalAlignmentTop, kVerticalAlignmentMiddle, kVerticalAlignmentBottom };
912
913msrVerticalAlignmentKind msrVerticalAlignmentKindFromString (
914 int inputLineNumber,
915 string verticalAlignmentString);
916
917string msrVerticalAlignmentKindAsString (
918 msrVerticalAlignmentKind verticalAlignmentKind);
919
920// direction
921//______________________________________________________________________________
922enum msrDirectionKind {
923 kDirectionNone,
924 kDirectionUp, kDirectionDown };
925
926string msrDirectionKindAsString (
927 msrDirectionKind directionKind);
928
929// print object
930//______________________________________________________________________________
931enum msrPrintObjectKind {
932 kPrintObjectNone,
933 kPrintObjectYes, kPrintObjectNo};
934
935msrPrintObjectKind msrPrintObjectKindFromString (
936 int inputLineNumber,
937 string printObjectString);
938
939string msrPrintObjectKindAsString (
940 msrPrintObjectKind printObjectKind);
941
942// placement
943//______________________________________________________________________________
944enum msrPlacementKind {
945 kPlacementNone,
946 kPlacementAbove, kPlacementBelow };
947
948msrPlacementKind msrPlacementKindFromString (
949 int inputLineNumber,
950 string placementString);
951
952string msrPlacementKindAsString (
953 msrPlacementKind placementKind);
954
955// measure style
956//______________________________________________________________________________
957enum msrSlashTypeKind {
958 k_NoSlashType,
959 kSlashTypeStart, kSlashTypeStop };
960
961string msrSlashTypeKindAsString (
962 msrSlashTypeKind slashTypeKind);
963
964enum msrUseDotsKind {
965 k_NoUseDots,
966 kUseDotsYes, kUseDotsNo };
967
968msrUseDotsKind msrUseDotsFromString (
969 int inputLineNumber,
970 string useDotsString);
971
972string msrUseDotsKindAsString (
973 msrUseDotsKind useDotsKind);
974
975enum msrSlashUseStemsKind {
976 k_NoSlashUseStems,
977 kSlashUseStemsYes, kSlashUseStemsNo };
978
979string msrSlashUseStemsKindAsString (
980 msrSlashUseStemsKind slashUseStemsKind);
981
982// line types
983//______________________________________________________________________________
984enum msrLineTypeKind {
985 kLineTypeSolid, kLineTypeDashed,
986 kLineTypeDotted, kLineTypeWavy };
987
988string msrLineTypeKindAsString (
989 msrLineTypeKind lineTypeKind);
990
991// tremolo types
992//______________________________________________________________________________
993enum msrTremoloTypeKind {
994 k_NoTremoloType,
995 kTremoloTypeSingle, kTremoloTypeStart, kTremoloTypeStop };
996
997string msrTremoloTypeKindAsString (
998 msrTremoloTypeKind tremoloTypeKind);
999
1000// technical types
1001//______________________________________________________________________________
1002enum msrTechnicalTypeKind { // JMI ???
1003 k_NoTechnicalType,
1004 kTechnicalTypeStart, kTechnicalTypeStop };
1005
1006string msrTechnicalTypeKindAsString (
1007 msrTechnicalTypeKind technicalTypeKind);
1008
1009// spanner types
1010//______________________________________________________________________________
1011enum msrSpannerTypeKind {
1012 k_NoSpannerType,
1013 kSpannerTypeStart, kSpannerTypeContinue, kSpannerTypeStop };
1014
1015string msrSpannerTypeKindAsString (
1016 msrSpannerTypeKind spannerTypeKind);
1017
1018// tuplet factors
1019//______________________________________________________________________________
1021{
1022 public:
1023
1024 // constructors/destructor
1025 // ------------------------------------------------------
1026
1027 msrTupletFactor ();
1028
1030 int tupletActualNotes,
1031 int tupletNormalNotes);
1032
1034 rational rationalTupletFactor);
1035
1036 virtual ~msrTupletFactor ();
1037
1038 public:
1039
1040 // set and get
1041 // ------------------------------------------------------
1042
1043 void setTupletActualNotes (int actualNotes)
1044 { fTupletActualNotes = actualNotes; }
1045
1046 int getTupletActualNotes () const
1047 { return fTupletActualNotes; }
1048
1049 void setTupletNormalNotes (int normalNotes)
1050 { fTupletNormalNotes = normalNotes; }
1051
1052 int getTupletNormalNotes () const
1053 { return fTupletNormalNotes; }
1054
1055 // services
1056 // ------------------------------------------------------
1057
1058 bool isEqualToOne () const
1059 {
1060 return
1061 fTupletActualNotes == fTupletNormalNotes;
1062 }
1063
1064 rational asRational () const
1065 {
1066 return
1067 rational (
1068 fTupletActualNotes,
1069 fTupletNormalNotes);
1070 }
1071
1072 // visitors
1073 // ------------------------------------------------------
1074
1075/* JMI
1076 virtual void acceptIn (basevisitor* v);
1077 virtual void acceptOut (basevisitor* v);
1078
1079 virtual void browseData (basevisitor* v);
1080*/
1081
1082 public:
1083
1084 // ------------------------------------------------------
1085
1086 string asString () const;
1087
1088 virtual void print (ostream& os) const;
1089
1090 private:
1091
1092 // fields
1093 // ------------------------------------------------------
1094
1095 int fTupletActualNotes;
1096 int fTupletNormalNotes;
1097};
1098EXP ostream& operator<< (ostream& os, const msrTupletFactor& elt);
1099
1100// chords intervals
1101//______________________________________________________________________________
1102class msrChordInterval;
1104
1106{
1107 public:
1108
1109 // creation from MusicXML
1110 // ------------------------------------------------------
1111
1112 static SMARTP<msrChordInterval> create (
1113 msrIntervalKind chordIntervalIntervalKind,
1114 int chordIntervalRelativeOctave = 0);
1115 // 0: up to the thirteenth,
1116 // no relative octave is needed
1117
1118 SMARTP<msrChordInterval> createChordIntervalNewbornClone ();
1119
1120 protected:
1121
1122 // constructors/destructor
1123 // ------------------------------------------------------
1124
1126 msrIntervalKind chordIntervalIntervalKind,
1127 int chordIntervalRelativeOctave);
1128
1129 virtual ~msrChordInterval ();
1130
1131 public:
1132
1133 // set and get
1134 // ------------------------------------------------------
1135
1136 msrIntervalKind getChordIntervalIntervalKind () const
1137 { return fChordIntervalIntervalKind; }
1138
1139 void incrementChordIntervalRelativeOctave ()
1140 { fChordIntervalRelativeOctave++; }
1141
1142 void decrementChordIntervalRelativeOctave ()
1143 { fChordIntervalRelativeOctave--; }
1144
1145 int getChordIntervalRelativeOctave () const
1146 { return fChordIntervalRelativeOctave; }
1147
1148 // services
1149 // ------------------------------------------------------
1150
1151 int chordIntervalAsSemitones () const
1152 {
1153 return
1154 msrIntervalKindAsSemiTones (
1155 fChordIntervalIntervalKind);
1156 }
1157
1158 string chordIntervalIntervalKindAsString () const;
1159 string chordIntervalIntervalKindAsShortString () const;
1160
1161 string chordIntervalAsString () const;
1162 string chordIntervalAsShortString () const;
1163
1164 /*
1165 we handle intervals up to the thirteenth in chords,
1166 but operations on intervals are easier to compute
1167 in a normal form limited to an octave, hence:
1168 */
1169 void normalizeInterval ();
1170 void deNormalizeInterval ();
1171
1172 S_msrChordInterval intervalDifference (
1173 S_msrChordInterval otherChordInterval);
1174 S_msrChordInterval intervalSum (
1175 S_msrChordInterval otherChordInterval);
1176
1177 string asString () const;
1178 string asShortString () const;
1179
1180 // visitors
1181 // ------------------------------------------------------
1182
1183/* JMI
1184 virtual void acceptIn (basevisitor* v);
1185 virtual void acceptOut (basevisitor* v);
1186
1187 virtual void browseData (basevisitor* v);
1188*/
1189
1190 public:
1191
1192 // ------------------------------------------------------
1193
1194 virtual void print (ostream& os) const;
1195
1196 private:
1197
1198 // fields
1199 // ------------------------------------------------------
1200
1201 msrIntervalKind fChordIntervalIntervalKind;
1202
1203 int fChordIntervalRelativeOctave;
1204};
1206EXP ostream& operator<< (ostream& os, const S_msrChordInterval& elt);
1207
1208// chords structure
1209//______________________________________________________________________________
1210class msrChordStructure;
1212
1214{
1215 public:
1216
1217 // creation from MusicXML
1218 // ------------------------------------------------------
1219
1220 static SMARTP<msrChordStructure> createBare (
1221 msrHarmonyKind chordStructureHarmonyKind);
1222
1223 static SMARTP<msrChordStructure> create (
1224 msrHarmonyKind chordStructureHarmonyKind);
1225
1226 SMARTP<msrChordStructure> createChordStructureNewbornClone ();
1227
1228 protected:
1229
1230 // constructors/destructor
1231 // ------------------------------------------------------
1232
1234 msrHarmonyKind chordStructureHarmonyKind);
1235
1236 virtual ~msrChordStructure ();
1237
1238 private:
1239
1240 // initialization
1241 // ------------------------------------------------------
1242
1243 public:
1244
1245 // set and get
1246 // ------------------------------------------------------
1247
1248 msrHarmonyKind getChordStructureHarmonyKind () const
1249 { return fChordStructureHarmonyKind; }
1250
1251 const vector <S_msrChordInterval>&
1252 getChordStructureIntervals () const
1253 { return fChordStructureIntervals; }
1254
1255 // services
1256 // ------------------------------------------------------
1257
1258 void appendChordIntervalToChordStructure (
1259 S_msrChordInterval chordInterval);
1260
1261 void populateChordStructure ();
1262
1263 string chordStructureAsString () const;
1264 string chordStructureAsShortString () const;
1265
1266 S_msrChordInterval bassChordIntervalForChordInversion (
1267 int inputLineNumber,
1268 int inversionNumber);
1269
1270 S_msrChordStructure invertChordStructure (int inversion);
1271
1272 static void printAllChordsStructures (ostream& os);
1273
1274 // visitors
1275 // ------------------------------------------------------
1276/* JMI
1277 virtual void acceptIn (basevisitor* v);
1278 virtual void acceptOut (basevisitor* v);
1279
1280 virtual void browseData (basevisitor* v);
1281*/
1282
1283 public:
1284
1285 // ------------------------------------------------------
1286
1287 virtual void print (ostream& os) const;
1288
1289 private:
1290
1291 // fields
1292 // ------------------------------------------------------
1293
1294 msrHarmonyKind fChordStructureHarmonyKind;
1295 vector<S_msrChordInterval>
1296 fChordStructureIntervals;
1297};
1299EXP ostream& operator<< (ostream& os, const S_msrChordStructure& elt);
1300
1301// chords contents
1302//______________________________________________________________________________
1304{
1305 public:
1306
1307 // creation from MusicXML
1308 // ------------------------------------------------------
1309
1310 static SMARTP<msrChordContents> create (
1311 // JMI int inputLineNumber,
1312 msrSemiTonesPitchKind chordContentsRootNote,
1313 msrHarmonyKind chordContentsHarmonyKind);
1314
1315 protected:
1316
1317 // constructors/destructor
1318 // ------------------------------------------------------
1319
1321 // JMI int inputLineNumber,
1322 msrSemiTonesPitchKind chordContentsRootNote,
1323 msrHarmonyKind chordContentsHarmonyKind);
1324
1325 virtual ~msrChordContents ();
1326
1327 public:
1328
1329 // set and get
1330 // ------------------------------------------------------
1331
1332 msrSemiTonesPitchKind
1333 getChordContentsRootNote () const
1334 { return fChordContentsRootNote; }
1335
1336 msrHarmonyKind getChordContentsHarmonyKind () const
1337 { return fChordContentsHarmonyKind; }
1338
1339 const vector<S_msrSemiTonesPitchAndOctave>&
1340 getChordElementsVector () const
1341 { return fChordElementsVector; }
1342
1343 // services
1344 // ------------------------------------------------------
1345
1346 string chordContentsAsString () const;
1347 string chordContentsAsShortString () const;
1348
1349 msrSemiTonesPitchKind bassSemiTonesPitchKindForChordInversion (
1350 int inputLineNumber,
1351 int inversionNumber);
1352
1353 static void printAllChordsContents (
1354 ostream& os,
1355 msrSemiTonesPitchKind semiTonesPitchKind);
1356
1357 // visitors
1358 // ------------------------------------------------------
1359/* JMI
1360 virtual void acceptIn (basevisitor* v);
1361 virtual void acceptOut (basevisitor* v);
1362
1363 virtual void browseData (basevisitor* v);
1364*/
1365
1366 public:
1367
1368 // ------------------------------------------------------
1369
1370 virtual void print (ostream& os) const;
1371
1372 private:
1373
1374 // fields
1375 // ------------------------------------------------------
1376
1377 msrSemiTonesPitchKind fChordContentsRootNote;
1378 msrHarmonyKind fChordContentsHarmonyKind;
1379
1380 vector<S_msrSemiTonesPitchAndOctave>
1381 fChordElementsVector;
1382};
1384EXP ostream& operator<< (ostream& os, const S_msrChordContents& elt);
1385
1386// chords details and analysis
1387//______________________________________________________________________________
1388void printChordDetails (
1389 ostream& os,
1390 msrSemiTonesPitchKind rootSemiTonesPitchKind,
1391 msrHarmonyKind harmonyKind);
1392
1393void printChordAnalysis (
1394 ostream& os,
1395 msrSemiTonesPitchKind rootSemiTonesPitchKind,
1396 msrHarmonyKind harmonyKind,
1397 int inversion);
1398
1399// RGB colors
1400//______________________________________________________________________________
1402 public:
1403
1404 // constructors/destructor
1405 // ------------------------------------------------------
1406
1407 msrRGBColor ();
1408
1409 msrRGBColor (
1410 float theR,
1411 float theG,
1412 float theB);
1413
1414 msrRGBColor (
1415 std::string theString);
1416
1417 // set and get
1418 // ------------------------------------------------------
1419
1420 float getR () const
1421 { return fR; }
1422
1423 float getG () const
1424 { return fG; }
1425
1426 float getB () const
1427 { return fB; }
1428
1429 public:
1430
1431 // services
1432 // ------------------------------------------------------
1433
1434 bool isEmpty () const
1435 {
1436 return
1437 fR < 0.0
1438 &&
1439 fG < 0.0
1440 &&
1441 fB < 0.0;
1442 }
1443
1444 public:
1445
1446 // print
1447 // ------------------------------------------------------
1448
1449 std::string asString () const;
1450
1451 void print (ostream& os) const;
1452
1453 private:
1454
1455 // fields
1456 // ------------------------------------------------------
1457
1458 float fR;
1459 float fG;
1460 float fB;
1461};
1462EXP ostream& operator<< (ostream& os, const msrRGBColor& elt);
1463
1464// AlphaRGB colors
1465//______________________________________________________________________________
1467{
1468 public:
1469
1470 // constructors/destructor
1471 // ------------------------------------------------------
1472
1474 string colorRGB,
1475 string colorAlpha);
1476
1478 string colorRGB);
1479
1480 virtual ~msrAlphaRGBColor ();
1481
1482 public:
1483
1484 // set and get
1485 // ------------------------------------------------------
1486
1487 string getColorRGB () const
1488 { return fColorRGB; }
1489
1490 string getColorAlpha () const
1491 { return fColorAlpha; }
1492
1493 // services
1494 // ------------------------------------------------------
1495
1496 bool isEmpty () const
1497 {
1498 return
1499 fColorRGB.size () == 0
1500 &&
1501 fColorAlpha.size () == 0;
1502 }
1503
1504 public:
1505
1506 // print
1507 // ------------------------------------------------------
1508
1509 string asString () const;
1510
1511 void print (ostream& os) const;
1512
1513 private:
1514
1515 // fields
1516 // ------------------------------------------------------
1517
1518 string fColorRGB; // hexadecimal, 6 digits
1519 string fColorAlpha; // hexadecimal, 2 digits
1520};
1521EXP ostream& operator<< (ostream& os, const msrAlphaRGBColor& elt);
1522
1523// score notation kinds
1524//______________________________________________________________________________
1525enum msrScoreNotationKind {
1526 kScoreNotationWestern,
1527 kScoreNotationJianpu,
1528 kScoreNotationDiatonicAccordion };
1529
1530string msrScoreNotationKindAsString (
1531 msrScoreNotationKind scoreNotationKind);
1532
1533// global variables
1534//______________________________________________________________________________
1535extern map<msrHarmonyKind, S_msrChordStructure>
1536 gChordStructuresMap;
1537
1538void initializeChordStructuresMap ();
1539
1540void printChordStructuresMap ();
1541
1542extern map<string, msrQuarterTonesPitchesLanguageKind>
1543 gQuarterTonesPitchesLanguageKindsMap;
1544
1545extern map<msrQuarterTonesPitchKind, string> gNederlandsPitchNamesMap;
1546extern map<msrQuarterTonesPitchKind, string> gCatalanPitchNamesMap;
1547extern map<msrQuarterTonesPitchKind, string> gDeutschPitchNamesMap;
1548extern map<msrQuarterTonesPitchKind, string> gEnglishPitchNamesMap;
1549extern map<msrQuarterTonesPitchKind, string> gEspanolPitchNamesMap;
1550extern map<msrQuarterTonesPitchKind, string> gFrancaisPitchNamesMap;
1551extern map<msrQuarterTonesPitchKind, string> gItalianoPitchNamesMap;
1552extern map<msrQuarterTonesPitchKind, string> gNorskPitchNamesMap;
1553extern map<msrQuarterTonesPitchKind, string> gPortuguesPitchNamesMap;
1554extern map<msrQuarterTonesPitchKind, string> gSuomiPitchNamesMap;
1555extern map<msrQuarterTonesPitchKind, string> gSvenskaPitchNamesMap;
1556extern map<msrQuarterTonesPitchKind, string> gVlaamsPitchNamesMap;
1557
1558void initializeQuarterTonesPitchesLanguageKinds ();
1559
1560string existingQuarterTonesPitchesLanguageKinds (int namesListMaxLength);
1561
1562// initialization
1563//______________________________________________________________________________
1564void initializeMSRBasicTypes ();
1565
1566
1567} // namespace MusicXML2
1568
1569
1570#endif
Definition: msrBasicTypes.h:1467
Definition: msrBasicTypes.h:1304
Definition: msrBasicTypes.h:1106
Definition: msrBasicTypes.h:1214
Definition: msrBasicTypes.h:435
Definition: msrBasicTypes.h:780
Definition: msrBasicTypes.h:596
Definition: msrBasicTypes.h:698
Definition: msrBasicTypes.h:1401
Definition: msrBasicTypes.h:501
Definition: msrBasicTypes.h:1021
the base class for smart pointers implementation
Definition: smartpointer.h:29
Rational number representation.
Definition: rational.h:25