public final class Pitch
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static Pitch |
getInstance(PitchUnit unit,
double value)
Return a new pitch object using value in a certain unit.
|
double |
getPitch(PitchUnit unit)
Get the pitch value in a given unit.
|
boolean |
isWesternMusicalPitch()
A pitch is seen as a western musical pitch if it is less than 15 cents
removed from the 'correct' pitch.
|
java.lang.String |
noteName()
Returns the name of the MIDI key corresponding to the given hertzValue.
|
int |
octaveIndex()
Calculates which octave this pitch falls into.
|
java.lang.String |
toString() |
public double getPitch(PitchUnit unit)
unit
- The requested unit.public int octaveIndex()
java.lang.IllegalArgumentException
- If the pitch does not fall within the range of valid MIDI
KEYS.public java.lang.String noteName()
java.lang.IllegalArgumentException
- When the hertzValue is outside the valid MIDI key range.public java.lang.String toString()
toString
in class java.lang.Object
public boolean isWesternMusicalPitch()
public static Pitch getInstance(PitchUnit unit, double value)
unit
- The unit of the pitch value.value
- The value Itself.java.lang.IllegalArgumentException
- If RELATIVE_CENTS is given: Cannot convert relative cent
value to absolute frequency.