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

    C key.

    Declaration

    Swift

    case c = 0
  • d

    D key.

    Declaration

    Swift

    case d = 2
  • e

    E key.

    Declaration

    Swift

    case e = 4
  • f

    F key.

    Declaration

    Swift

    case f = 5
  • g

    G key.

    Declaration

    Swift

    case g = 7
  • a

    A key.

    Declaration

    Swift

    case a = 9
  • b

    B key.

    Declaration

    Swift

    case b = 11
  • all

    Returns all members of the KeyType.

    Declaration

    Swift

    public static let all: [KeyType] = [.c, .d, .e, .f, .g, .a, .b]
  • Returns neighbour KeyType at distance 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 the KeyType.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 KeyTypes.

    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.

  • Returns the key notation.

    Declaration

    Swift

    public var description: String