| Enum Constant and Description |
|---|
ABSOLUTE_CENTS
Number of cents compared to the "absolute zero" a configured, low
frequency.
|
HERTZ
Oscillations per second.
|
MIDI_CENT
An double from 0 to 127 that represents the closest MIDI key.
|
MIDI_KEY
An integer from 0 to 127 that represents the closest MIDI key.
|
RELATIVE_CENTS
Number of cents (between 0 and 1200) relative to the start of the octave.
|
| Modifier and Type | Method and Description |
|---|---|
static double |
absoluteCentToHertz(double absoluteCent)
Returns the frequency (Hz) of an absolute cent value.
|
static double |
centToRatio(double cent)
Converts cent values to ratios.
|
static java.lang.String |
closestRatio(double cent) |
double |
convert(double value,
PitchUnit valueUnit)
Convert the given pitch in the given unit to this unit.
|
java.lang.String |
getHumanName() |
static double |
hertzToAbsoluteCent(double hertzValue)
The reference frequency is configured.
|
static double |
hertzToMidiCent(double hertzValue)
Converts a frequency in Hz to a MIDI CENT value using
(12 ^ log2 (f / 440)) + 69 E.g. 69.168 MIDI CENTS = MIDI NOTE 69 + 16,8 cents69.168 MIDI CENTS = 440Hz + x Hz |
static int |
hertzToMidiKey(java.lang.Double hertzValue)
A MIDI key is an integer between 0 and 127, inclusive.
|
static double |
hertzToRelativeCent(double hertzValue)
Converts a Hertz value to relative cents.
|
static double |
midiCentToHertz(double midiCent)
Converts a MIDI CENT frequency to a frequency in Hz.
|
static double |
midiKeyToHertz(int midiKey)
Calculates the frequency (Hz) for a MIDI key.
|
static double |
ratioToCent(double ratio)
Converts a ratio to cents.
|
static double |
relativeCentToHertz(double relativeCent)
Converts a relative cent value to an absolute Hertz value by using
PitchUnit.REF_FREQ.
|
static PitchUnit |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static PitchUnit[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final PitchUnit HERTZ
public static final PitchUnit ABSOLUTE_CENTS
public static final PitchUnit RELATIVE_CENTS
public static final PitchUnit MIDI_KEY
public static final PitchUnit MIDI_CENT
public static PitchUnit[] values()
for (PitchUnit c : PitchUnit.values()) System.out.println(c);
public static PitchUnit valueOf(java.lang.String name)
name - the name of the enum constant to be returned.java.lang.IllegalArgumentException - if this enum type has no constant with the specified namejava.lang.NullPointerException - if the argument is nullpublic java.lang.String getHumanName()
public double convert(double value,
PitchUnit valueUnit)
PitchUnit.HERZ.convert(6900,PitchUnit.ABSOLUTE_CENTS) == 440 PitchUnit.HERZ.convert(69,PitchUnit.MIDI_KEY) == 440 PitchUnit.HERZ.convert(69.00,PitchUnit.MIDI_CENTS) == 440 PitchUnit.HERZ.convert(700,PitchUnit.RELATIVE_CENTS) == 440 PitchUnit.ABSOLUTE_CENTS.convert(440,PitchUnit.HERTZ) == 6900
value - The value of the given pitch.valueUnit - The unit of the given pitch.public static double midiCentToHertz(double midiCent)
midiCent - The pitch in MIDI CENT.public static double hertzToMidiCent(double hertzValue)
(12 ^ log2 (f / 440)) + 69 69.168 MIDI CENTS = MIDI NOTE 69 + 16,8 cents69.168 MIDI CENTS = 440Hz + x HzhertzValue - The pitch in Hertz.public static double absoluteCentToHertz(double absoluteCent)
absoluteCent - The pitch in absolute cent.public static double hertzToAbsoluteCent(double hertzValue)
hertzValue - The pitch in Hertz.public static double hertzToRelativeCent(double hertzValue)
hertzValue - A value in hertz.public static double relativeCentToHertz(double relativeCent)
relativeCent - a value in relative cents.public static double midiKeyToHertz(int midiKey)
midiKey - The MIDI key. A MIDI key is an integer between 0 and 127,
inclusive.java.lang.IllegalArgumentException - If midiKey is not in the valid range between 0 and 127,
inclusive.public static int hertzToMidiKey(java.lang.Double hertzValue)
hertzValue - The pitch in Hertz.java.lang.IllegalArgumentException - if the hertzValue does not fall within the range of valid
MIDI key frequencies.public static java.lang.String closestRatio(double cent)
public static double ratioToCent(double ratio)
ratio - A cent valuepublic static double centToRatio(double cent)
cent - A cent value