Canorus  0.7
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
/home/iurt/rpm/BUILD/canorus-0.7.R1002/src/core/interval.h
Go to the documentation of this file.
00001 
00008 #ifndef INTERVAL_H_
00009 #define INTERVAL_H_
00010 
00011 #include <QString>
00012 
00013 class CADiatonicPitch;
00014 
00015 class CAInterval {
00016 public:
00017         enum CAQuality {
00018                 Major = 1,
00019                 Minor = -1,
00020                 Perfect = 0,
00021                 Augmented = 2,
00022                 Diminished = -2
00023         };
00024 
00025         enum CAQuantity {
00026                 Undefined = 0,
00027                 Prime = 1,
00028                 Second = 2,
00029                 Third = 3,
00030                 Fourth = 4,
00031                 Fifth = 5,
00032                 Sixth = 6,
00033                 Seventh = 7,
00034                 Octave = 8
00035         };
00036 
00037         CAInterval();
00038         CAInterval( int qlt, int qnt );
00039         CAInterval( CADiatonicPitch note1, CADiatonicPitch note2, bool absolute=true );
00040 
00041         CAInterval operator~();
00042         CAInterval operator+( CAInterval );
00043         CAInterval operator-(CAInterval i) {
00044                 return operator+( CAInterval( i.quality(), i.quantity()*(-1) ) );
00045         }
00046 
00047         CAInterval operator*( int numerator ) {
00048                 CAInterval interval = *this;
00049                 while ( --numerator ) {
00050                         interval = interval + (*this);
00051                 }
00052 
00053                 return interval;
00054         }
00055 
00056         inline const int quality() { return _qlt; }
00057         inline const int quantity() { return _qnt; }
00058 
00059         inline void setQuality( const int qlt ) { _qlt = qlt; }
00060         inline void setQuantity( const int qnt ) { _qnt = qnt; }
00061 
00062         int semitones();
00063 
00064         static CAInterval fromSemitones( int semitones );
00065         static const QString qualityToReadable( int k );
00066         static const QString quantityToReadable( int k );
00067 
00068 private:
00069         int _qlt;
00070         int _qnt;
00071 };
00072 #endif /* INTERVAL_H_ */