Canorus  0.0
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
CAInterval Class Reference

Music interval expressed with diatonical quality and quantity. More...

#include <interval.h>

Public Types

enum  CAQuality {
  Major = 1, Minor = -1, Perfect = 0, Augmented = 2,
  Diminished = -2
}
 
enum  CAQuantity {
  Undefined = 0, Prime = 1, Second = 2, Third = 3,
  Fourth = 4, Fifth = 5, Sixth = 6, Seventh = 7,
  Octave = 8
}
 

Public Member Functions

 CAInterval ()
 
 CAInterval (int qlt, int qnt)
 
 CAInterval (CADiatonicPitch note1, CADiatonicPitch note2, bool absolute=true)
 
CAInterval operator~ ()
 
CAInterval operator+ (CAInterval)
 
CAInterval operator- (CAInterval i)
 
CAInterval operator* (int numerator)
 
bool operator== (CAInterval i)
 
bool operator!= (CAInterval i)
 
const int quality ()
 
const int quantity ()
 
void setQuality (const int qlt)
 
void setQuantity (const int qnt)
 
int semitones ()
 

Static Public Member Functions

static CAInterval fromSemitones (int semitones)
 
static const QString qualityToReadable (int k)
 
static const QString quantityToReadable (int k)
 

Private Attributes

int _qlt
 
int _qnt
 

Detailed Description

Music interval expressed with diatonical quality and quantity.

Copyright (c) 2008, Matevž Jekovec, Canorus development team All Rights Reserved. See AUTHORS for a complete list of authors.

Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.

This class represent an interval between two notes. eg. major second, minor sixth, perfect prime, perfect fifth, augmented fifth etc.

It consists of two properties:

Note
Quantity can also be negative for intervals down.

Intervals can be compared to each other, summed with other intervals or diatonic pitches and inverted.

See also
CADiatonicPitch, operator~()

Member Enumeration Documentation

◆ CAQuality

Enumerator
Major 
Minor 
Perfect 
Augmented 
Diminished 

◆ CAQuantity

Enumerator
Undefined 
Prime 
Second 
Third 
Fourth 
Fifth 
Sixth 
Seventh 
Octave 

Constructor & Destructor Documentation

◆ CAInterval() [1/3]

CAInterval::CAInterval ( )

Constructs a new undefined interval.

Call setQuality() and setQuantity() to set its properties.

References setQuality(), and setQuantity().

Referenced by fromSemitones(), operator+(), operator-(), and operator~().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CAInterval() [2/3]

CAInterval::CAInterval ( int  qlt,
int  qnt 
)

Constructs an interval with quality qlt and quantity qnt.

References setQuality(), and setQuantity().

Here is the call graph for this function:

◆ CAInterval() [3/3]

CAInterval::CAInterval ( CADiatonicPitch  pitch1,
CADiatonicPitch  pitch2,
bool  absolute = true 
)

Constructs an interval between the pitches pitch1 and pitch2. Interval quantity is positive regardless of the order of pitches, if absolute is True (default). Otherwise, quantity is negative, if second pitch is lower than the first one.

References CADiatonicPitch::accs(), CADiatonicPitch::noteName(), quantity(), setQuality(), and setQuantity().

Here is the call graph for this function:

Member Function Documentation

◆ fromSemitones()

CAInterval CAInterval::fromSemitones ( int  semitones)
static

Creates an interval out of the given semitones. Semitones can also be negative to produce intervals down.

The interval found in major/minor scales is returned. Augmented fourth is used for the tritone.

This is an injective mapping.

References Augmented, CAInterval(), Fifth, Fourth, Major, Minor, Perfect, Prime, quantity(), Second, semitones(), setQuantity(), Seventh, Sixth, and Third.

Referenced by CATranspose::transposeBySemitones().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator!=()

bool CAInterval::operator!= ( CAInterval  i)
inline

References operator==().

Here is the call graph for this function:

◆ operator*()

CAInterval CAInterval::operator* ( int  numerator)
inline

◆ operator+()

CAInterval CAInterval::operator+ ( CAInterval  i)

Returns the sum of two intervals.

eg. perfect fifth + major third = major seventh

References CAInterval(), quality(), and quantity().

Referenced by operator-().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator-()

CAInterval CAInterval::operator- ( CAInterval  i)
inline

References CAInterval(), operator+(), quality(), and quantity().

Here is the call graph for this function:

◆ operator==()

bool CAInterval::operator== ( CAInterval  i)
inline

References _qlt, _qnt, quality(), and quantity().

Referenced by operator!=().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator~()

CAInterval CAInterval::operator~ ( )

Returns the inverse of the interval. The reversed interval is always positive.

eg. seventh -> second, major -> minor and vice versa

References CAInterval(), quality(), and quantity().

Here is the call graph for this function:

◆ quality()

const int CAInterval::quality ( )
inline

References _qlt.

Referenced by CADiatonicPitch::operator+(), operator+(), CADiatonicPitch::operator-(), operator-(), operator==(), operator~(), and semitones().

Here is the caller graph for this function:

◆ qualityToReadable()

const QString CAInterval::qualityToReadable ( int  k)
static

Referenced by CATransposeView::on_uiIntervalQuantity_currentIndexChanged().

Here is the caller graph for this function:

◆ quantity()

const int CAInterval::quantity ( )
inline

◆ quantityToReadable()

const QString CAInterval::quantityToReadable ( int  k)
static

Referenced by CATransposeView::setupCustomUi().

Here is the caller graph for this function:

◆ semitones()

int CAInterval::semitones ( )

Returns the number of semitones in the interval.

This is a surjective mapping.

References Augmented, Diminished, Fifth, Fourth, Minor, Prime, quality(), quantity(), Second, Seventh, Sixth, and Third.

Referenced by CADiatonicPitch::diatonicPitchFromMidiPitchKey(), and fromSemitones().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setQuality()

void CAInterval::setQuality ( const int  qlt)
inline

References _qlt.

Referenced by CAInterval().

Here is the caller graph for this function:

◆ setQuantity()

void CAInterval::setQuantity ( const int  qnt)
inline

References _qnt.

Referenced by CAInterval(), CADiatonicPitch::diatonicPitchFromMidiPitchKey(), fromSemitones(), and CATranspose::transposeByKeySig().

Here is the caller graph for this function:

Member Data Documentation

◆ _qlt

int CAInterval::_qlt
private

Referenced by operator==(), quality(), and setQuality().

◆ _qnt

int CAInterval::_qnt
private

Referenced by operator==(), quantity(), and setQuantity().


The documentation for this class was generated from the following files: