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_MAJOR
Ab major.A_MAJOR
A major.B_FLAT_MAJOR
Bb major.B_MAJOR
B major.C_MAJOR
C major.D_FLAT_MAJOR
Db major.D_MAJOR
D major.E_FLAT_MAJOR
Eb major.E_MAJOR
E major.F_MAJOR
F major.F_SHARP_MAJOR
F# major.G_MAJOR
G major.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description float
getCorrelation(KeyProfile profile, float[] chromagram, Tone chromagramBase)
Calculates the Pearson correlation coefficient between this key and the given chromagram using the provided profile.Key
getDiagonal()
If major, this returns theKey.getTonicParallel()
of theKey.getDominant()
.Key
getDominant()
Dominant.SeventhChord
getDominantSeventh()
String
getKeyCode()
Key code.Color
getKeyCodeColor()
Key code color.int
getKeyCodeNumeral()
Key code numeral.String
getOpenKeyCode()
Open key code, followed by either d (German dur, Latin durus, Engl.int
getOpenKeyCodeNumeral()
Position on the circle of fifths, clockwise, starting with C major = 1 for major keys and A minor = 1 for minor keys.Key
getSubdominant()
Subdominant.String
getTKey()
Id3 representation of this key.Tone[]
getTones()
Tones in this key.Tone
getTonic()
Tonic of this key.String
getTonicName()
Tonic name, guaranteed to be the "typical" name (as in Circle of fifths) for the key.Key
getTonicParallel()
Tonic parallel, i.e.Triad
getTriad()
Triad for this key.int
getWallClockCodeNumeral()
Wall clock position in the circle of fifths (C Major at 12 o'clock).String
getWallClockKeyCode()
Wall clock key code.Key
inc(int fifths)
Increase key by the given number of fifths.Key
incBySemitones(int semitones)
Return the key that would result in shifting all tones in this key by' the given number of semitones.boolean
isCompatible(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.boolean
isMajor()
Is this a major key?boolean
isMinor()
Is this a minor key?int
negativeDistance(Key nextKey)
Negative distance in semitones from this key to the given, next key.int
positiveDistance(Key nextKey)
Positive distance in semitones from this key to the given, next key.String
toJSONString()
String
toString()
static MajorKey
valueOf(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:Key
Tonic of this key.- Specified by:
getTonic
in interfaceKey
- Returns:
- tonic
- See Also:
Key.getTonicName()
,Key.getDominant()
,Key.getSubdominant()
-
getTonicName
public String getTonicName()
Description copied from interface:Key
Tonic name, guaranteed to be the "typical" name (as in Circle of fifths) for the key.- Specified by:
getTonicName
in interfaceKey
- Returns:
- tonic name
- See Also:
Key.getTonic()
-
isCompatible
public boolean isCompatible(Key key)
Description copied from interface: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.- Specified by:
isCompatible
in interfaceKey
- Returns:
- true or false
- See Also:
Key.getDominant()
,Key.getSubdominant()
,Key.getTonicParallel()
-
positiveDistance
public int positiveDistance(Key nextKey)
Description copied from interface:Key
Positive distance in semitones from this key to the given, next key.- Specified by:
positiveDistance
in interfaceKey
- Parameters:
nextKey
- next key- Returns:
- distance in semitones
- See Also:
Tone.positiveDistance(Tone)
-
negativeDistance
public int negativeDistance(Key nextKey)
Description copied from interface:Key
Negative distance in semitones from this key to the given, next key.- Specified by:
negativeDistance
in interfaceKey
- Parameters:
nextKey
- next key- Returns:
- distance in semitones
- See Also:
Tone.negativeDistance(Tone)
-
getDominantSeventh
public SeventhChord getDominantSeventh()
- Specified by:
getDominantSeventh
in interfaceKey
- Returns:
- dominant seventh
-
isMajor
public boolean isMajor()
Description copied from interface:Key
Is this a major key?
-
isMinor
public boolean isMinor()
Description copied from interface:Key
Is this a minor key?
-
getSubdominant
public Key getSubdominant()
Description copied from interface:Key
Subdominant.- Specified by:
getSubdominant
in interfaceKey
- Returns:
- subdominant
- See Also:
Key.inc(int)
-
getDominant
public Key getDominant()
Description copied from interface:Key
Dominant.- Specified by:
getDominant
in interfaceKey
- Returns:
- dominant
- See Also:
Key.inc(int)
-
inc
public Key inc(int fifths)
Description copied from interface:Key
Increase 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:Key
Return 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:
incBySemitones
in interfaceKey
- Parameters:
semitones
- number of semitones- Returns:
- shifted key
- See Also:
Tempo.incBySemitones(int)
-
getTonicParallel
public Key getTonicParallel()
Description copied from interface:Key
Tonic parallel, i.e. major to minor or vice versa.- Specified by:
getTonicParallel
in interfaceKey
- Returns:
- tonic parallel
-
getDiagonal
public Key getDiagonal()
Description copied from interface:Key
If 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:
getDiagonal
in interfaceKey
- Returns:
- diagonal key
-
getWallClockCodeNumeral
public int getWallClockCodeNumeral()
Description copied from interface:Key
Wall clock position in the circle of fifths (C Major at 12 o'clock).- Specified by:
getWallClockCodeNumeral
in 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:Key
Calculates the Pearson correlation coefficient between this key and the given chromagram using the provided profile.- Specified by:
getCorrelation
in interfaceKey
- Parameters:
profile
- key profilechromagram
- chromagramchromagramBase
- tone/pitch of the first chromagram bin- Returns:
- correlation coefficient
-
getKeyCodeNumeral
public int getKeyCodeNumeral()
Description copied from interface:Key
Key code numeral.- Specified by:
getKeyCodeNumeral
in interfaceKey
- Returns:
- key code numeral (1-12)
-
getOpenKeyCodeNumeral
public int getOpenKeyCodeNumeral()
Description copied from interface:Key
Position on the circle of fifths, clockwise, starting with C major = 1 for major keys and A minor = 1 for minor keys.- Specified by:
getOpenKeyCodeNumeral
in interfaceKey
- Returns:
- open key code numeral (1-12)
- See Also:
Key.getOpenKeyCode()
-
getKeyCode
public String getKeyCode()
Description copied from interface:Key
Key code.- Specified by:
getKeyCode
in interfaceKey
- Returns:
- key code 1-12[A|B]
-
getWallClockKeyCode
public String getWallClockKeyCode()
Description copied from interface:Key
Wall clock key code.- Specified by:
getWallClockKeyCode
in interfaceKey
- Returns:
- key code 1-12[M|m]
-
getOpenKeyCode
public String getOpenKeyCode()
Description copied from interface:Key
Open key code, followed by either d (German dur, Latin durus, Engl. major) or m (German moll, Latin mollis, Engl. minor).- Specified by:
getOpenKeyCode
in interfaceKey
- Returns:
- open key code 1-12[d|m]
- See Also:
Key.getOpenKeyCodeNumeral()
-
getKeyCodeColor
public Color getKeyCodeColor()
Description copied from interface:Key
Key code color.- Specified by:
getKeyCodeColor
in interfaceKey
- Returns:
- key code color
-
getTKey
public String getTKey()
Description copied from interface:Key
Id3 representation of this key.
-
toJSONString
public String toJSONString()
- Specified by:
toJSONString
in interfaceorg.json.simple.JSONAware
-
-