Lomse library. API documentation  0.30.0
FPitch Class Reference

#include <lomse_pitch.h>

Detailed Description

Class FPitch is a compact base-40 absolute pitch representation. It is interval-invariant. And is restricted to a maximum of 2 accidentals

  • 'F' stands for Fourty.
  • It is an absolute pitch representation, with an interesting property: is interval-invariant, that is, the number obtained by subtracting two pitches represents the interval between them. Therefore, this representation is specially useful to deal with intervals.
  • Each octave requires a range of 40 values. So to represent 10 octaves (C0-B9) a range of 400 is required. An int is enough.

FPitch representation has shown to be optimal for representing pitch in cases where music analysis is an objective, as it greatly simplifies the analysis of intervals and chords.

This representation was taken from Walter B. Hewlett paper "A Base-40 Number-line Representation of Musical Pitch Notation", CCARH Publications, Stanford, California, 1986.

Public Member Functions

 FPitch ()
 
 FPitch (int value)
 
 FPitch (DiatonicPitch dp, int nAcc)
 
 FPitch (int nStep, int nOctave, int nAcc)
 
 FPitch (const string &note)
 
 ~FPitch ()
 
 operator int ()
 
bool is_valid ()
 
bool is_natural_note_for (EKeySignature nKey)
 
bool operator== (FPitch fp)
 
bool operator!= (FPitch fp)
 
bool operator< (FPitch fp)
 
bool operator> (FPitch fp)
 
bool operator<= (FPitch fp)
 
bool operator>= (FPitch fp)
 
int step ()
 
int octave ()
 
int num_accidentals ()
 
EAccidentals accidentals ()
 
EAccidentals notated_accidentals_for (EKeySignature nKey)
 
string to_abs_ldp_name ()
 
string to_rel_ldp_name (EKeySignature nKey)
 
MidiPitch to_midi_pitch ()
 
DiatonicPitch to_diatonic_pitch ()
 
FPitch add_semitone (EKeySignature nKey)
 
FPitch add_semitone (bool fUseSharps)
 
FPitch operator- (FIntval intv)
 
FPitch operator+ (FIntval intv)
 
FPitch operator-= (FIntval intv)
 
FPitch operator+= (FIntval intv)
 

Constructor & Destructor Documentation

◆ FPitch() [1/5]

FPitch::FPitch ( )
inline

Default constructor. Initializes with C4 pitch.

◆ FPitch() [2/5]

FPitch::FPitch ( int  value)
inline

Constructor using an integer representing an FPitch value.

◆ FPitch() [3/5]

FPitch::FPitch ( DiatonicPitch  dp,
int  nAcc 
)

Constructor using a DiatonicPitch plus accidentals information.

◆ FPitch() [4/5]

FPitch::FPitch ( int  nStep,
int  nOctave,
int  nAcc 
)

Constructor from pitch components.

◆ FPitch() [5/5]

FPitch::FPitch ( const string &  note)

Constructor from an string representing the pitch in LDP name, e.g., "+c4".

◆ ~FPitch()

FPitch::~FPitch ( )
inline

Destructor.

Member Function Documentation

◆ accidentals()

EAccidentals FPitch::accidentals ( )

Components extraction

◆ add_semitone() [1/2]

FPitch FPitch::add_semitone ( EKeySignature  nKey)

Operations

◆ add_semitone() [2/2]

FPitch FPitch::add_semitone ( bool  fUseSharps)

Operations

◆ is_natural_note_for()

bool FPitch::is_natural_note_for ( EKeySignature  nKey)

Returns TRUE if pitch is a diatonic note in the given key signature.

◆ is_valid()

bool FPitch::is_valid ( )

Returns TRUE if pitch value is valid. Invalid pitches correspond to numbers 6, 12, 23, 29 & 35 and all obtained by adding 40, 80, 120, etc. to them.

◆ notated_accidentals_for()

EAccidentals FPitch::notated_accidentals_for ( EKeySignature  nKey)

Components extraction

◆ num_accidentals()

int FPitch::num_accidentals ( )

Components extraction

◆ octave()

int FPitch::octave ( )
inline

Components extraction

◆ operator int()

FPitch::operator int ( )
inline

Operator to cast to an int.

◆ operator!=()

bool FPitch::operator!= ( FPitch  fp)
inline

Comparison operators

◆ operator+()

FPitch FPitch::operator+ ( FIntval  intv)
inline

Add/substract an interval

◆ operator+=()

FPitch FPitch::operator+= ( FIntval  intv)
inline

Add/substract an interval

◆ operator-()

FPitch FPitch::operator- ( FIntval  intv)
inline

Add/substract an interval

◆ operator-=()

FPitch FPitch::operator-= ( FIntval  intv)
inline

Add/substract an interval

◆ operator<()

bool FPitch::operator< ( FPitch  fp)
inline

Comparison operators

◆ operator<=()

bool FPitch::operator<= ( FPitch  fp)
inline

Comparison operators

◆ operator==()

bool FPitch::operator== ( FPitch  fp)
inline

Comparison operators

◆ operator>()

bool FPitch::operator> ( FPitch  fp)
inline

Comparison operators

◆ operator>=()

bool FPitch::operator>= ( FPitch  fp)
inline

Comparison operators

◆ step()

int FPitch::step ( )
inline

Components extraction

◆ to_abs_ldp_name()

string FPitch::to_abs_ldp_name ( )

Conversion

◆ to_diatonic_pitch()

DiatonicPitch FPitch::to_diatonic_pitch ( )

Conversion

◆ to_midi_pitch()

MidiPitch FPitch::to_midi_pitch ( )

Conversion

◆ to_rel_ldp_name()

string FPitch::to_rel_ldp_name ( EKeySignature  nKey)

Conversion