Package com.tagtraum.audiokern.key
Enum MajorKey
- java.lang.Object
-
- java.lang.Enum<MajorKey>
-
- com.tagtraum.audiokern.key.MajorKey
-
- All Implemented Interfaces:
Key,Serializable,Comparable<MajorKey>,org.json.simple.JSONAware
public enum MajorKey extends Enum<MajorKey> implements Key, Serializable, org.json.simple.JSONAware
Major keys.- Author:
- Hendrik Schreiber
-
-
Enum Constant Summary
Enum Constants Enum Constant Description A_FLAT_MAJORAb major.A_MAJORA major.B_FLAT_MAJORBb major.B_MAJORB major.C_MAJORC major.D_FLAT_MAJORDb major.D_MAJORD major.E_FLAT_MAJOREb major.E_MAJORE major.F_MAJORF major.F_SHARP_MAJORF# major.G_MAJORG major.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description floatgetCorrelation(KeyProfile profile, float[] chromagram, Tone chromagramBase)Calculates the Pearson correlation coefficient between this key and the given chromagram using the provided profile.KeygetDiagonal()If major, this returns theKey.getTonicParallel()of theKey.getDominant().KeygetDominant()Dominant.SeventhChordgetDominantSeventh()StringgetKeyCode()Key code.ColorgetKeyCodeColor()Key code color.intgetKeyCodeNumeral()Key code numeral.StringgetOpenKeyCode()Open key code, followed by either d (German dur, Latin durus, Engl.intgetOpenKeyCodeNumeral()Position on the circle of fifths, clockwise, starting with C major = 1 for major keys and A minor = 1 for minor keys.KeygetSubdominant()Subdominant.StringgetTKey()Id3 representation of this key.Tone[]getTones()Tones in this key.TonegetTonic()Tonic of this key.StringgetTonicName()Tonic name, guaranteed to be the "typical" name (as in Circle of fifths) for the key.KeygetTonicParallel()Tonic parallel, i.e.TriadgetTriad()Triad for this key.intgetWallClockCodeNumeral()Wall clock position in the circle of fifths (C Major at 12 o'clock).StringgetWallClockKeyCode()Wall clock key code.Keyinc(int fifths)Increase key by the given number of fifths.KeyincBySemitones(int semitones)Return the key that would result in shifting all tones in this key by' the given number of semitones.booleanisCompatible(Key key)Indicates whether the given key is compatible to this key in the sense that one is either the sub/dominant or tonic parallel of the other.booleanisMajor()Is this a major key?booleanisMinor()Is this a minor key?intnegativeDistance(Key nextKey)Negative distance in semitones from this key to the given, next key.intpositiveDistance(Key nextKey)Positive distance in semitones from this key to the given, next key.StringtoJSONString()StringtoString()static MajorKeyvalueOf(String name)Returns the enum constant of this type with the specified name.static MajorKey[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
C_MAJOR
public static final MajorKey C_MAJOR
C major.
-
G_MAJOR
public static final MajorKey G_MAJOR
G major.
-
D_MAJOR
public static final MajorKey D_MAJOR
D major.
-
A_MAJOR
public static final MajorKey A_MAJOR
A major.
-
E_MAJOR
public static final MajorKey E_MAJOR
E major.
-
B_MAJOR
public static final MajorKey B_MAJOR
B major.
-
F_SHARP_MAJOR
public static final MajorKey F_SHARP_MAJOR
F# major.
-
D_FLAT_MAJOR
public static final MajorKey D_FLAT_MAJOR
Db major.
-
A_FLAT_MAJOR
public static final MajorKey A_FLAT_MAJOR
Ab major.
-
E_FLAT_MAJOR
public static final MajorKey E_FLAT_MAJOR
Eb major.
-
B_FLAT_MAJOR
public static final MajorKey B_FLAT_MAJOR
Bb major.
-
F_MAJOR
public static final MajorKey F_MAJOR
F major.
-
-
Method Detail
-
values
public static MajorKey[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (MajorKey c : MajorKey.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static MajorKey valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
getTonic
public Tone getTonic()
Description copied from interface:KeyTonic of this key.- Specified by:
getTonicin interfaceKey- Returns:
- tonic
- See Also:
Key.getTonicName(),Key.getDominant(),Key.getSubdominant()
-
getTonicName
public String getTonicName()
Description copied from interface:KeyTonic name, guaranteed to be the "typical" name (as in Circle of fifths) for the key.- Specified by:
getTonicNamein interfaceKey- Returns:
- tonic name
- See Also:
Key.getTonic()
-
isCompatible
public boolean isCompatible(Key key)
Description copied from interface:KeyIndicates whether the given key is compatible to this key in the sense that one is either the sub/dominant or tonic parallel of the other.- Specified by:
isCompatiblein interfaceKey- Returns:
- true or false
- See Also:
Key.getDominant(),Key.getSubdominant(),Key.getTonicParallel()
-
positiveDistance
public int positiveDistance(Key nextKey)
Description copied from interface:KeyPositive distance in semitones from this key to the given, next key.- Specified by:
positiveDistancein interfaceKey- Parameters:
nextKey- next key- Returns:
- distance in semitones
- See Also:
Tone.positiveDistance(Tone)
-
negativeDistance
public int negativeDistance(Key nextKey)
Description copied from interface:KeyNegative distance in semitones from this key to the given, next key.- Specified by:
negativeDistancein interfaceKey- Parameters:
nextKey- next key- Returns:
- distance in semitones
- See Also:
Tone.negativeDistance(Tone)
-
getDominantSeventh
public SeventhChord getDominantSeventh()
- Specified by:
getDominantSeventhin interfaceKey- Returns:
- dominant seventh
-
isMajor
public boolean isMajor()
Description copied from interface:KeyIs this a major key?
-
isMinor
public boolean isMinor()
Description copied from interface:KeyIs this a minor key?
-
getSubdominant
public Key getSubdominant()
Description copied from interface:KeySubdominant.- Specified by:
getSubdominantin interfaceKey- Returns:
- subdominant
- See Also:
Key.inc(int)
-
getDominant
public Key getDominant()
Description copied from interface:KeyDominant.- Specified by:
getDominantin interfaceKey- Returns:
- dominant
- See Also:
Key.inc(int)
-
inc
public Key inc(int fifths)
Description copied from interface:KeyIncrease key by the given number of fifths. This allows to travel easily around the circle of fifths.Key.getDominant()is the same asinc(1).Key.getSubdominant()is the same asinc(-1).
-
incBySemitones
public Key incBySemitones(int semitones)
Description copied from interface:KeyReturn the key that would result in shifting all tones in this key by' the given number of semitones. Such a shift may result, when the audio is played back at a higher or lower speed.- Specified by:
incBySemitonesin interfaceKey- Parameters:
semitones- number of semitones- Returns:
- shifted key
- See Also:
Tempo.incBySemitones(int)
-
getTonicParallel
public Key getTonicParallel()
Description copied from interface:KeyTonic parallel, i.e. major to minor or vice versa.- Specified by:
getTonicParallelin interfaceKey- Returns:
- tonic parallel
-
getDiagonal
public Key getDiagonal()
Description copied from interface:KeyIf major, this returns theKey.getTonicParallel()of theKey.getDominant(). If minor, this returns theKey.getTonicParallel()of theKey.getSubdominant(). On the circle of fifths this is an harmonic diagonal transition.- Specified by:
getDiagonalin interfaceKey- Returns:
- diagonal key
-
getWallClockCodeNumeral
public int getWallClockCodeNumeral()
Description copied from interface:KeyWall clock position in the circle of fifths (C Major at 12 o'clock).- Specified by:
getWallClockCodeNumeralin interfaceKey- Returns:
- key code numeral (1-12)
- See Also:
Key.getWallClockKeyCode()
-
getCorrelation
public float getCorrelation(KeyProfile profile, float[] chromagram, Tone chromagramBase)
Description copied from interface:KeyCalculates the Pearson correlation coefficient between this key and the given chromagram using the provided profile.- Specified by:
getCorrelationin interfaceKey- Parameters:
profile- key profilechromagram- chromagramchromagramBase- tone/pitch of the first chromagram bin- Returns:
- correlation coefficient
-
getKeyCodeNumeral
public int getKeyCodeNumeral()
Description copied from interface:KeyKey code numeral.- Specified by:
getKeyCodeNumeralin interfaceKey- Returns:
- key code numeral (1-12)
-
getOpenKeyCodeNumeral
public int getOpenKeyCodeNumeral()
Description copied from interface:KeyPosition on the circle of fifths, clockwise, starting with C major = 1 for major keys and A minor = 1 for minor keys.- Specified by:
getOpenKeyCodeNumeralin interfaceKey- Returns:
- open key code numeral (1-12)
- See Also:
Key.getOpenKeyCode()
-
getKeyCode
public String getKeyCode()
Description copied from interface:KeyKey code.- Specified by:
getKeyCodein interfaceKey- Returns:
- key code 1-12[A|B]
-
getWallClockKeyCode
public String getWallClockKeyCode()
Description copied from interface:KeyWall clock key code.- Specified by:
getWallClockKeyCodein interfaceKey- Returns:
- key code 1-12[M|m]
-
getOpenKeyCode
public String getOpenKeyCode()
Description copied from interface:KeyOpen key code, followed by either d (German dur, Latin durus, Engl. major) or m (German moll, Latin mollis, Engl. minor).- Specified by:
getOpenKeyCodein interfaceKey- Returns:
- open key code 1-12[d|m]
- See Also:
Key.getOpenKeyCodeNumeral()
-
getKeyCodeColor
public Color getKeyCodeColor()
Description copied from interface:KeyKey code color.- Specified by:
getKeyCodeColorin interfaceKey- Returns:
- key code color
-
getTKey
public String getTKey()
Description copied from interface:KeyId3 representation of this key.
-
toJSONString
public String toJSONString()
- Specified by:
toJSONStringin interfaceorg.json.simple.JSONAware
-
-