ritornello.core.conceitual
Class Interval

java.lang.Object
  |
  +--ritornello.core.conceitual.Interval

public class Interval
extends java.lang.Object


Field Summary
static int AUG_4TH_SEMITONES
          The aug 4th / dim 5th semitones value.
static int MAJOR_2ND_SEMITONES
          The major 2nd semitones value.
static int MAJOR_3RD_SEMITONES
          The major 3rd semitones value.
static int MAJOR_6TH_SEMITONES
          The major 6th semitones value.
static int MAJOR_7TH_SEMITONES
          The major 7th semitones value.
static int MINOR_2ND_SEMITONES
          The minor 2nd semitones value.
static int MINOR_3RD_SEMITONES
          The minor 3rd semitones value.
static int MINOR_6TH_SEMITONES
          The minor 6th semitones value.
static int MINOR_7TH_SEMITONES
          The minor 7th semitones value.
static int OCTAVE_SEMITONES
          The number of semitones within an octave.
static int PERFECT_4TH_SEMITONES
          The perfect 4th semitones value.
static int PERFECT_5TH_SEMITONES
          The perfect 5th semitones value.
static int UNISON_SEMITONES
          The unison semitones value.
 
Constructor Summary
Interval(int semitones)
          Constructor.
 
Method Summary
static int calculateLongestNoteInterval(Note note1, Note note2)
          Calculates the longest interval between two notes.
static int calculateNoteBackwardInterval(Note rootNote, Note secondNote)
          Calculates the semitones between two notes in a backward deslocation.
static int calculateNoteFowardInterval(Note rootNote, Note secondNote)
          Calculates the semitones between two notes in a foward deslocation.
static Note calculateNoteInterval(Note rootNote, int semitones)
          Calculates a note, given its root note and circular descolation (e.g. in a circular environment, a deslocation VALUE = 0 and VALUE=12 have the same result).
static PlayableNote calculatePlayableNoteInterval(PlayableNote rootNote, int semitones)
          Calculates the second note, given its root note and semitones interval.
static int calculatePlayableNoteInterval(PlayableNote note1, PlayableNote note2)
          Calculates the interval.
static int calculateShortestNoteInterval(Note note1, Note note2)
          Calculates the shortest interval between two notes.
static java.util.Vector getEnharmonicsList(Note note)
          Calculates all enharmonic notes, given a single note.
 java.lang.String getName()
          Assign an interval name, given its semitones number.
 int getSemitones()
          Returns the semitones value.
static boolean isEnharmonic(Note note1, Note note2)
          Verifies if two given note are enharmonics.
static void main(java.lang.String[] argv)
          Test unit.
 void setSemitones(int semitones)
          Set the interval kind.
 java.lang.String toString()
          Retrieves the interval name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

OCTAVE_SEMITONES

public static final int OCTAVE_SEMITONES
The number of semitones within an octave.

See Also:
Constant Field Values

UNISON_SEMITONES

public static final int UNISON_SEMITONES
The unison semitones value.

See Also:
Constant Field Values

MINOR_2ND_SEMITONES

public static final int MINOR_2ND_SEMITONES
The minor 2nd semitones value.

See Also:
Constant Field Values

MAJOR_2ND_SEMITONES

public static final int MAJOR_2ND_SEMITONES
The major 2nd semitones value.

See Also:
Constant Field Values

MINOR_3RD_SEMITONES

public static final int MINOR_3RD_SEMITONES
The minor 3rd semitones value.

See Also:
Constant Field Values

MAJOR_3RD_SEMITONES

public static final int MAJOR_3RD_SEMITONES
The major 3rd semitones value.

See Also:
Constant Field Values

PERFECT_4TH_SEMITONES

public static final int PERFECT_4TH_SEMITONES
The perfect 4th semitones value.

See Also:
Constant Field Values

AUG_4TH_SEMITONES

public static final int AUG_4TH_SEMITONES
The aug 4th / dim 5th semitones value.

See Also:
Constant Field Values

PERFECT_5TH_SEMITONES

public static final int PERFECT_5TH_SEMITONES
The perfect 5th semitones value.

See Also:
Constant Field Values

MINOR_6TH_SEMITONES

public static final int MINOR_6TH_SEMITONES
The minor 6th semitones value.

See Also:
Constant Field Values

MAJOR_6TH_SEMITONES

public static final int MAJOR_6TH_SEMITONES
The major 6th semitones value.

See Also:
Constant Field Values

MINOR_7TH_SEMITONES

public static final int MINOR_7TH_SEMITONES
The minor 7th semitones value.

See Also:
Constant Field Values

MAJOR_7TH_SEMITONES

public static final int MAJOR_7TH_SEMITONES
The major 7th semitones value.

See Also:
Constant Field Values
Constructor Detail

Interval

public Interval(int semitones)
Constructor. Receives the number of semitones for the interval.

Parameters:
semitones - - Number of semitones for the interval.
Method Detail

getName

public java.lang.String getName()
Assign an interval name, given its semitones number.

Returns:
String

setSemitones

public void setSemitones(int semitones)
Set the interval kind. Receives the number of semitones.

Parameters:
semitones - - The number of semitones between the notes in a interval.

getSemitones

public int getSemitones()
Returns the semitones value.

Returns:
int

calculateShortestNoteInterval

public static int calculateShortestNoteInterval(Note note1,
                                                Note note2)
Calculates the shortest interval between two notes. The parameter order does not matter.

Parameters:
note1 - - The first note.
note2 - - The second note.
Returns:
int

calculateLongestNoteInterval

public static int calculateLongestNoteInterval(Note note1,
                                               Note note2)
Calculates the longest interval between two notes. The parameter order does not matter.

Parameters:
note1 - - The first note.
note2 - - The second note.
Returns:
int

calculateNoteFowardInterval

public static int calculateNoteFowardInterval(Note rootNote,
                                              Note secondNote)
Calculates the semitones between two notes in a foward deslocation. The parameters order is important.

Parameters:
rootNote - - The root note.
secondNote - - The second note.
Returns:
int

calculateNoteBackwardInterval

public static int calculateNoteBackwardInterval(Note rootNote,
                                                Note secondNote)
Calculates the semitones between two notes in a backward deslocation. The parameters order is important.

Parameters:
rootNote - - The root note.
secondNote - - The second note.
Returns:
int

calculateNoteInterval

public static Note calculateNoteInterval(Note rootNote,
                                         int semitones)
                                  throws ValidationException
Calculates a note, given its root note and circular descolation (e.g. in a circular environment, a deslocation VALUE = 0 and VALUE=12 have the same result).

Parameters:
rootNote - - The inicial note.
semitones - - The semitones deslocation. The negative deslocation means backward steps.
Returns:
DesignModel.mx.Note
Throws:
ValidationException

calculatePlayableNoteInterval

public static PlayableNote calculatePlayableNoteInterval(PlayableNote rootNote,
                                                         int semitones)
                                                  throws ValidationException
Calculates the second note, given its root note and semitones interval. It is not circular: when the last octave's last note is reached, a validation exception is thrown. The same above to first octave's first note.

Parameters:
rootNote - - The root note.
semitones - - The semitones deslocation. The negative deslocation means backward steps.
Returns:
DesignModel.mx.PlayableNote
Throws:
ValidationException

calculatePlayableNoteInterval

public static int calculatePlayableNoteInterval(PlayableNote note1,
                                                PlayableNote note2)
Calculates the interval. Receives the first and last component playable notes. The parameter order does not matter.

Parameters:
note1 - - The first note in a interval.
note2 - - The second note in a interval.
Returns:
int

isEnharmonic

public static boolean isEnharmonic(Note note1,
                                   Note note2)
Verifies if two given note are enharmonics.

Parameters:
note1 - - Note number one.
note2 - - Note number two.
Returns:
boolean

getEnharmonicsList

public static java.util.Vector getEnharmonicsList(Note note)
                                           throws ValidationException
Calculates all enharmonic notes, given a single note.

Parameters:
note - - The note.
Returns:
java.util.Vector
Throws:
ValidationException

main

public static void main(java.lang.String[] argv)
Test unit.

Parameters:
argv - - The command line arguments.

toString

public java.lang.String toString()
Retrieves the interval name.

Overrides:
toString in class java.lang.Object
Returns:
The interval name.