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
KeyType
atdistance
away. 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.all
array circullar to find the target KeyType.Declaration
Swift
public func key(at distance: Int) -> KeyType
Parameters
distance
Target KeyType distance. Zero is self.
Return Value
Returns the neighbouring KeyType distance away.
-
Calculates the distance of two
KeyType
s.Declaration
Swift
public func distance(from keyType: KeyType) -> Int
Parameters
keyType
Target
KeyType
you 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
KeyType
at given interval away higher or lower.Declaration
Swift
public func octaveDiff(for interval: Interval, isHigher: Bool) -> Int
Parameters
interval
Interval you want to calculate octave difference.
isHigher
You 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
value
String representation of type.
-
Returns the key notation.
Declaration
Swift
public var description: String