ChordDefinition

public struct ChordDefinition : Equatable, Codable, Identifiable, Hashable, Sendable

The structure of a chord definition

Database items

  • id

    The ID of the chord

    Declaration

    Swift

    public var id: UUID
  • The fret positions of the chord

    Declaration

    Swift

    public var frets: [Int]
  • The finger positions of the chord

    Declaration

    Swift

    public var fingers: [Int]
  • The base fret of the chord

    Declaration

    Swift

    public var baseFret: Int
  • The root of the chord

    Declaration

    Swift

    public var root: Chord.Root
  • The quality of the chord

    Declaration

    Swift

    public var quality: Chord.Quality

Other items

  • The name of the chord

    Declaration

    Swift

    public var name: String
  • The fingers you have to bar for the chord

    Note

    A calculated value by the init

    Declaration

    Swift

    public var barres: [Chord.Barre]
  • The instrument of the chord

    Declaration

    Swift

    public var instrument: Instrument
  • The appended notes on the chord

    Declaration

    Swift

    var appended: [String]
  • The base note of an optional ‘slash’ chord

    Declaration

    Swift

    public var bass: Chord.Root?
  • The components of the chord definition

    Declaration

    Swift

    public var components: [Chord.Component]
  • The status of the chord

    Declaration

    Swift

    public var status: Chord.Status

Coding keys

  • The coding keys

    Note

    Only those items will be in the database
    See more

    Declaration

    Swift

    enum CodingKeys : CodingKey
  • Custom encoder for the ChordDefinition

    Declaration

    Swift

    public func encode(to encoder: Encoder) throws
  • The structure for display options passed to the ChordDefinitionView

    See more

    Declaration

    Swift

    public struct DisplayOptions : Codable, Equatable, Sendable
  • Format the name of the chord for display

    Declaration

    Swift

    func displayName(options: DisplayOptions) -> String

    Parameters

    options

    Return Value

    A formatted string with the name of the chord

  • Try to validate a ChordDefinition

    Declaration

    Swift

    var validate: Chord.Status { get }
  • Convert a ChordDefinition into a ChordPro {define}

    Declaration

    Swift

    var define: String { get }
  • Play a ChordDefinition with MIDI

    Declaration

    Swift

    func play(instrument: Midi.Instrument = .acousticNylonGuitar)

    Parameters

    instrument

    The instrument to use

  • Mirror a Barre for a left-handed chord

    Declaration

    Swift

    func mirrorBarre(_ barre: Chord.Barre) -> Chord.Barre

    Parameters

    barre

    The original barre

    Return Value

    The left-handed barre

Init from the decoder

Init with a definition

  • Init the ChordDefinition with a ChordPro definition

    If the status is ‘unknown’, this function will try to find the chord in the database

    Declaration

    Swift

    init(definition: String, instrument: Instrument, status: Chord.Status) throws

    Parameters

    definition

    The ChordPro definition

    instrument
    status

    The Status

Init with a name

  • Init the ChordDefinition with the name of a chord

    Declaration

    Swift

    init?(name: String, instrument: Instrument)

    Parameters

    name

    The name of the chord, e.g ‘Am7’

    instrument

Init with an unknown name

  • Init the ChordDefinition with an unknown chord

    Declaration

    Swift

    init(unknown: String, instrument: Instrument)

    Parameters

    unknown

    The name of the unknown chord

    instrument
  • Transpose a ChordDefinition

    Declaration

    Swift

    mutating func transpose(transpose: Int, scale: Chord.Root)

    Parameters

    transpose

    The transpose value

    scale

    The scale of the chord