ChordDefinition
public struct ChordDefinition: Equatable, Codable, Identifiable, Hashable, Sendable
The structure of a chord definition
-
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
-
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 initDeclaration
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
-
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
See moreChordDefinitionView
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
The
DisplayOptions
Return Value
A formatted string with the name of the chord
-
Try to validate a
ChordDefinition
Declaration
Swift
var validate: Chord.Status
-
Convert a
ChordDefinition
into a ChordPro{define}
Declaration
Swift
var define: String
-
Play a
ChordDefinition
with MIDIDeclaration
Swift
func play(instrument: Midi.Instrument = .acousticNylonGuitar)
Parameters
instrument
The
instrument
to use
-
Init the
ChordDefinition
from the decoderDeclaration
Swift
init(from decoder: Decoder) throws
-
Init the
ChordDefinition
with all known valuesDeclaration
Swift
init( id: UUID, name: String, frets: [Int], fingers: [Int], baseFret: Int, root: Chord.Root, quality: Chord.Quality, bass: Chord.Root?, instrument: Instrument, status: Chord.Status = .customChord )
-
Init the
ChordDefinition
with a ChordPro definitionIf 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
The
Instrument
status
The
Status
-
Init the
ChordDefinition
with the name of a chordDeclaration
Swift
init?(name: String, instrument: Instrument)
Parameters
name
The name of the chord, e.g ‘Am7’
instrument
The
Instrument
-
Init the
ChordDefinition
with an unknown chordDeclaration
Swift
init(unknown: String, instrument: Instrument)
Parameters
unknown
The name of the unknown chord
instrument
The
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