KeyType
public enum KeyType: Int, Codable, Equatable, Hashable, ExpressibleByStringLiteral, CustomStringConvertible
Base pitch of the key without accidentals. Accidentals will take account in the parent struct, Key. Integer values are based on C = 0 on western chromatic scale.
-
C key.
Declaration
Swift
case c = 0
-
D key.
Declaration
Swift
case d = 2
-
E key.
Declaration
Swift
case e = 4
-
F key.
Declaration
Swift
case f = 5
-
G key.
Declaration
Swift
case g = 7
-
A key.
Declaration
Swift
case a = 9
-
B key.
Declaration
Swift
case b = 11
-
Returns neighbour
KeyTypeatdistanceaway. Works on both directions. Use negative distance value for going on left direction, positive distance value for going on right direction. This function iterates theKeyType.allarray circullar to find the target KeyType.Declaration
Swift
public func key(at distance: Int) -> KeyTypeParameters
distanceTarget KeyType distance. Zero is self.
Return Value
Returns the neighbouring KeyType distance away.
-
Calculates the distance of two
KeyTypes.Declaration
Swift
public func distance(from keyType: KeyType) -> IntParameters
keyTypeTarget
KeyTypeyou want to compare.Return Value
Returns the integer value of distance in terms of their array index values.
-
Calculates the octave difference for a neighbouring
KeyTypeat given interval away higher or lower.Declaration
Swift
public func octaveDiff(for interval: Interval, isHigher: Bool) -> IntParameters
intervalInterval you want to calculate octave difference.
isHigherYou want to calculate interval higher or lower from current key.
Return Value
Returns the octave difference for a given interval higher or lower.
-
Declaration
Swift
public typealias StringLiteralType = String -
Initilizes with a string.
Declaration
Swift
public init(stringLiteral value: KeyType.StringLiteralType)Parameters
valueString representation of type.
-
Returns the key notation.
Declaration
Swift
public var description: String
View on GitHub
KeyType Enumeration Reference