Key

public struct Key: Codable, Equatable, Hashable, ExpressibleByStringLiteral, CustomStringConvertible

Represents the keys that notes and pitches are based on.

  • 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.

    See more

    Declaration

    Swift

    public enum KeyType: Int, Codable, Equatable, Hashable, ExpressibleByStringLiteral, CustomStringConvertible
  • Type of the key.

    Declaration

    Swift

    public var type: KeyType
  • Accidental of the key.

    Declaration

    Swift

    public var accidental: Accidental
  • All notes in an octave with sharp notes.

    Declaration

    Swift

    public static let keysWithSharps = [
  • All notes in an octave with flat notes.

    Declaration

    Swift

    public static let keysWithFlats = [
  • Initilizes the key with its type and accidental.

    Declaration

    Swift

    public init(type: KeyType, accidental: Accidental = .natural)

    Parameters

    type

    The type of the key.

    accidental

    Accidental of the key. Defaults natural.

  • Returns the key notation with its type and accidental, if has any.

    Declaration

    Swift

    public var description: String