Chord

public struct Chord: Equatable

The Chord type provides an abstraction for dealing with vertically-oriented harmonic structures. Can be initialized with a pitch-class set, with a chord symbol (e.g. Chord(Fmaj7#11)), or with MIDI note numbers as an Int array. Chord parity, considering inversional equivalence, can be checked using the == operator.

  • The underlying pitch-class set.

    Declaration

    Swift

    public var pitchClasses = PCSet()
  • key

    The chord’s key context, useful for certain operations. Defaults to C Major. Expressed as a tuplet (Key, KeyType).

    Declaration

    Swift

    public var key = (Key.C, KeyType.major)
  • The chord represented as scale degrees, if available, according to the ‘key’ property.

    Declaration

    Swift

    public var tones: [ScaleDegree]
  • Check chord parity.

    Declaration

    Swift

    public static func ==(lhs: Chord, rhs: Chord) -> Bool
  • Initialize with scale degrees.

    Declaration

    Swift

    public init(scaleDegrees: [ScaleDegree], in initialKey: (Key, KeyType))
  • Initialize from a pitch-class set.

    Declaration

    Swift

    public init(pitchClassSet: PCSet)
  • Initialize from a chord symbol. E.g. Chord(Gbm7).

    Declaration

    Swift

    public init?(_ chordSymbol: String)
  • Parse a chord symbol and return an Optional. Returns nil if the chord symbol could not be parsed.

    Declaration

    Swift

    public init?(parse chordSymbol: String)
  • Convert from pitch-class to scale-degree.

    Declaration

    Swift

    public func toScaleDegree(from pc: PitchClass) -> ScaleDegree?
  • Convert from scale-degree to pitch-class.

    Declaration

    Swift

    public func toPitchClass(from degree: ScaleDegree) -> PitchClass
  • Use the Chord abstraction to voice-lead from one set of MIDI note numbers to another. E.g. Chord.voiceLead(from: [60, 64, 67], to: Chord(Fmaj7)).

    Declaration

    Swift

    public static func voiceLead(from chord: [UInt8], to nextChord: Chord) -> [UInt8]