|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD |
java.lang.Objectjava.lang.Enum<PitchUnit>
be.hogent.tarsos.sampled.pitch.PitchUnit
public enum PitchUnit
Defines the unit of the pitch value.
Enum Constant Summary | |
---|---|
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. |
Method Summary | |
---|---|
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 cents 69.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. |
Methods inherited from class java.lang.Enum |
---|
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Enum Constant Detail |
---|
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
Method Detail |
---|
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 name
java.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 cents
69.168 MIDI CENTS = 440Hz + x Hz
hertzValue
- 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)
PitchUnit.REF_FREQ
.
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 value
public static double centToRatio(double cent)
cent
- A cent value
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD |