public int getSemitones ( ) { int semitones = 0 ; switch ( getLabel ( ) % OCTAVE ) { case UNISON : semitones = 0 ; break ; //unison case SECOND : semitones = 2 ; break ; //major 2nd case THIRD : semitones = 4 ; break ; //major 3rd case FOURTH : semitones = 5 ; break ; //perfect 4th case FIFTH : semitones = 7 ; break ; //perfect 5th case SIXTH : semitones = 9 ; break ; //major 6th case SEVENTH : semitones = 11 ; break ; //major 7th } switch ( getQuality ( ) ) { case QUADRUPLE_DIMINISHED : case TRIPLE_DIMINISHED : case DOUBLE_DIMINISHED : case DIMINISHED : if ( allowPerfectQuality ( ) ) semitones += getQuality ( ) + 1 ; else semitones += getQuality ( ) ; break ; case MINOR : semitones -= 1 ; break ; case PERFECT : case MAJOR : break ; //do not change pitch for major and perfect case AUGMENTED : case DOUBLE_AUGMENTED : case TRIPLE_AUGMENTED : case QUADRUPLE_AUGMENTED : semitones += getQuality ( ) - 1 ; break ; } semitones += 12 * getOctaveNumber ( ) ; return semitones ; }
Return the number of semitones between 2 notes spaced by this Interval