Lomse library. API documentation
0.30.0
|
#include <lomse_interval.h>
Class FIntval represents an interval. Intervals are defined using the properties of FPitch representation: An interval is just the difference between the two FPitches.
Intervals can be added and substracted. For example, a perfect fifth minus a major third is a minor third (p5-M3 = m3)
Intervals greater than one octave can also be build directly. For example, a major 10th:
But can also be computed by adding octaves to simple intervals. For example, a major 10th is a major third plus one octave (M3+p8 = M10), thus:
Intervals have sign: positive intervals are ascending and negative ones are descending but, appart from the sign, all other properties do not change. For example:
Macros for all the simple intervals are also defined, for convenience. They are named 'k_interval_xxxx', where 'xxxx' is the abbreviated name. See get_code().
Public Member Functions | |
FIntval (int number, EIntervalType type) | |
FIntval (const string &code, bool fDescending=false) | |
FIntval (int value) | |
FIntval () | |
operator int () | |
string | get_code () |
int | get_number () |
EIntervalType | get_type () |
int | get_num_semitones () |
bool | is_descending () |
void | make_descending () |
bool | is_ascending () |
void | make_ascending () |
bool | operator== (FIntval intv) |
bool | operator!= (FIntval intv) |
bool | operator< (FIntval intv) |
bool | operator> (FIntval intv) |
bool | operator<= (FIntval intv) |
bool | operator>= (FIntval intv) |
FIntval | operator- (FIntval intv) |
FIntval | operator+ (FIntval intv) |
FIntval | operator-= (FIntval intv) |
FIntval | operator+= (FIntval intv) |
FIntval::FIntval | ( | int | number, |
EIntervalType | type | ||
) |
Constructor for building an interval from its number and its type.
number | The interval number. Positive for ascending intervals or negative for descending intervals. |
type | A value from enum EIntervalType. |
Examples:
FIntval::FIntval | ( | const string & | code, |
bool | fDescending = false |
||
) |
Constructor for building an interval from its code. See get_code().
Examples:
|
inline |
Contructor for building an interval from an integer representing the interval value.
FIntval::FIntval | ( | ) |
Default empty constructor. Builds an invalid, null interval.
string FIntval::get_code | ( | ) |
Return string representing the interval code (its abbreviated name). Examples: "m2", "p4", "M3".
The code is the same for ascending and descending intervals. To check for a descending interval use is_descending() method.
The codes are formed by concatenating one or two characters with the interval number. The valid characters are as follows:
dd - double diminished d - diminished m - minor M - Major p - perfect a - augmented da - double augmented
Thus:
'm2' is a minor 2nd 'p4' is a perfect fourth 'M3' is a major third 'da9' is a double augmented ninth 'p15' is a two octaves
Macros for all the simple intervals are also defined, for convenience. They are named 'k_interval_xxxx', where 'xxxx' is the code of the interval. For example:
int FIntval::get_num_semitones | ( | ) |
Returns the number of semitones implied by this interval.
The numebr of semitones is always positive. It doesn't matter if the interval is ascending or descending. To check for a descending interval use is_descending() method.
int FIntval::get_number | ( | ) |
Returns the interval number: 1 for unison, 2 for second, 3 for third, ... , 8 for octave, 9 for ninth, ..., 15 for two octaves, and so on.
The number is the same for ascending and descending intervals. To check for a descending interval use is_descending() method.
EIntervalType FIntval::get_type | ( | ) |
Returns the interval type (diminished, major, etc.) as a value from enum EIntervalType.
The type is the same for ascending and descending intervals. To check for a descending interval use is_descending() method.
|
inline |
Returns true if the interval is ascending or unison and false when it is descending.
|
inline |
Returns true if the interval is descending and false when it is unison or ascending.
|
inline |
Transforms the interval in an ascending interval. If it is already ascending this method does nothing.
|
inline |
Transforms the interval in a descending interval. If it is already descending this method does nothing.
|
inline |
Operator to cast to an int. Negative for descending intervals.
|
inline |
Comparison operators
|
inline |
Comparison operators
|
inline |
Comparison operators
|
inline |
Comparison operators
|
inline |
Comparison operators
|
inline |
Comparison operators