Canorus  0.7
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
interval.h
Go to the documentation of this file.
1 
8 #ifndef INTERVAL_H_
9 #define INTERVAL_H_
10 
11 #include <QString>
12 
13 class CADiatonicPitch;
14 
15 class CAInterval {
16 public:
17  enum CAQuality {
18  Major = 1,
19  Minor = -1,
20  Perfect = 0,
21  Augmented = 2,
23  };
24 
25  enum CAQuantity {
26  Undefined = 0,
27  Prime = 1,
28  Second = 2,
29  Third = 3,
30  Fourth = 4,
31  Fifth = 5,
32  Sixth = 6,
33  Seventh = 7,
34  Octave = 8
35  };
36 
37  CAInterval();
38  CAInterval( int qlt, int qnt );
39  CAInterval( CADiatonicPitch note1, CADiatonicPitch note2, bool absolute=true );
40 
44  return operator+( CAInterval( i.quality(), i.quantity()*(-1) ) );
45  }
46 
47  CAInterval operator*( int numerator ) {
48  CAInterval interval = *this;
49  while ( --numerator ) {
50  interval = interval + (*this);
51  }
52 
53  return interval;
54  }
55 
56  inline const int quality() { return _qlt; }
57  inline const int quantity() { return _qnt; }
58 
59  inline void setQuality( const int qlt ) { _qlt = qlt; }
60  inline void setQuantity( const int qnt ) { _qnt = qnt; }
61 
62  int semitones();
63 
64  static CAInterval fromSemitones( int semitones );
65  static const QString qualityToReadable( int k );
66  static const QString quantityToReadable( int k );
67 
68 private:
69  int _qlt;
70  int _qnt;
71 };
72 #endif /* INTERVAL_H_ */