ChordDefinition
struct ChordDefinition: Equatable, Codable, Identifiable, Hashable, Sendable
The structure of a chord definition
-
The ID of the chord
Declaration
Swift
var id: UUID -
The fret positions of the chord
Declaration
Swift
var frets: [Int] -
The finger positions of the chord
Declaration
Swift
var fingers: [Int] -
The base fret of the chord
Declaration
Swift
var baseFret: Int -
The root of the chord
Declaration
Swift
var root: Chord.Root -
The quality of the chord
Declaration
Swift
var quality: Chord.Quality
-
The name of the chord
Declaration
Swift
var name: String -
The fingers you have to bar for the chord
Note
A calculated value by the initDeclaration
Swift
var barres: [Chord.Barre] -
The instrument of the chord
Declaration
Swift
var instrument: Instrument -
The base note of an optional ‘slash’ chord
Declaration
Swift
var bass: Chord.Root? -
The components of the chord definition
Declaration
Swift
var components: [Chord.Component] = [] -
The status of the chord
Declaration
Swift
var status: Chord.Status
-
Declaration
Swift
enum CodingKeys: CodingKey -
Custom encoder for the
ChordDefinitionDeclaration
Swift
func encode(to encoder: Encoder) throws -
Get the name of the chord for internal use
Declaration
Swift
var getName: StringReturn Value
A string with the name of the chord
-
Format the name of the chord for display
Declaration
Swift
var display: StringReturn Value
A formatted string with the name of the chord
-
Format the name of the chord with a flat version for display
Declaration
Swift
var displayFlatForSharp: StringReturn Value
A formatted string with the flat name of the chord
-
Try to validate a
ChordDefinitionDeclaration
Swift
var validate: Chord.Status -
Convert a
ChordDefinitioninto a ChordPro{define}Declaration
Swift
var define: String -
Play a
ChordDefinitionwith MIDIDeclaration
Swift
func play(instrument: Midi.Instrument = .acousticNylonGuitar)Parameters
instrumentThe
instrumentto use -
Mirror a
Barrefor a left-handed chordParameters
barreThe original barre
Return Value
The left-handed barre
-
Init the
ChordDefinitionfrom the decoderDeclaration
Swift
init(from decoder: Decoder) throws
-
Init the
ChordDefinitionwith 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
ChordDefinitionwith 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) throwsParameters
definitionThe ChordPro definition
instrumentThe
InstrumentstatusThe
Status
-
Init the
ChordDefinitionwith the name of a chordDeclaration
Swift
init?(name: String, instrument: Instrument)Parameters
nameThe name of the chord, e.g ‘Am7’
instrumentThe
Instrument
-
Init the
ChordDefinitionwith the name of a chordDeclaration
Swift
init?(chord: ChordPro.Instrument.Chord, instrument: Instrument)Parameters
chordThe ChordPro JSON chord
instrumentThe
Instrument
-
Init the
ChordDefinitionwith an unknown chordDeclaration
Swift
init(unknown: String, instrument: Instrument)Parameters
unknownThe name of the unknown chord
instrumentThe
Instrument -
Transpose a
ChordDefinitionDeclaration
Swift
mutating func transpose(transpose: Int, scale: Chord.Root)Parameters
transposeThe transpose value
scaleThe scale of the chord
View on GitHub