Package com.tagtraum.audiokern.key
Class KeyFactory
- java.lang.Object
-
- com.tagtraum.audiokern.key.KeyFactory
-
public final class KeyFactory extends Object
Parses key values usually found in id3 tags or the like.- Author:
- Hendrik Schreiber
-
-
Field Summary
Fields Modifier and Type Field Description static List<Locale>
SUPPORTED_LOCALES
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Key
get(Tone tone, Mode mode)
Same astone.getKey(mode)
.static Key
guessFromTag(String tag)
Guess the key by interpreting the given textual tag.static Key
guessFromTags(AudioSong song)
Guess the key by interpreting other textual metadata like album, work and track name.static Key
keyForAccidentals(boolean major, int accidentals)
Convert the number of accidentals to a key.static Key
parse(MidiMessage message)
ParseMidiMessage
and return the corresponding key, if possible.static Key
parseKeyCode(String keyCode)
Parses a key code.static Key
parseTKEY(String id3TkeyTag)
TKEY
-
-
-
Method Detail
-
guessFromTags
public static Key guessFromTags(AudioSong song)
Guess the key by interpreting other textual metadata like album, work and track name.- Parameters:
song
- track- Returns:
- key or
null
, if no unambiguous key could be found
-
guessFromTag
public static Key guessFromTag(String tag)
Guess the key by interpreting the given textual tag.- Parameters:
tag
- textual tag- Returns:
- key or
null
, if no unambiguous key could be found
-
get
public static Key get(Tone tone, Mode mode)
Same astone.getKey(mode)
.- Parameters:
tone
- tonemode
- mode- Returns:
- key
-
parseTKEY
public static Key parseTKEY(String id3TkeyTag)
TKEYThe 'Initial key' frame contains the musical key in which the sound starts. It is represented as a string with a maximum length of three characters. The ground keys are represented with "A","B","C","D","E", "F" and "G" and halfkeys represented with "b" and "#". Minor is represented as "m", e.g. "Dbm". Off key is represented with an "o" only.
- Parameters:
id3TkeyTag
- id3 key tag- Returns:
- key
- See Also:
- http://www.id3.org/id3v2.4.0-frames.txt
-
parseKeyCode
public static Key parseKeyCode(String keyCode)
Parses a key code.- Parameters:
keyCode
- key code- Returns:
- key
- See Also:
Key.getKeyCode()
-
keyForAccidentals
public static Key keyForAccidentals(boolean major, int accidentals)
Convert the number of accidentals to a key.- Parameters:
major
- major key?accidentals
- number of accidentals (positive for sharps, negative for flats)- Returns:
- key
-
parse
public static Key parse(MidiMessage message)
ParseMidiMessage
and return the corresponding key, if possible.- Parameters:
message
- midi message- Returns:
- key or
null
, if the message is not a key change message
-
-