Utils
enum Utils
Chord utilities
-
Get index value of a note
Declaration
Swift
static func noteToValue(note: Chord.Root) -> Int
-
Return note by index in a scale
-
Transpose the chord
Declaration
Parameters
transpose
Transpose key
note
The root note
scale
Key scale
-
Calculate the chord components
Declaration
Swift
static func fretsToComponents( root: Chord.Root, frets: [Int], baseFret: Int, instrument: Instrument ) -> [Chord.Component]
-
Check if fingers should be barred
Declaration
Swift
static func fingersToBarres( frets: [Int], fingers: [Int] ) -> [Chord.Barre]
Parameters
frets
The frets of the chord
fingers
The fingers of the chord
Return Value
An array with fingers that should be barred
-
Get all possible chord notes for a
ChordDefinition
Declaration
Swift
static func getChordComponents(chord: ChordDefinition, addBase: Bool = true) -> [[Chord.Root]]
Parameters
chord
The
ChordDefinition
addBase
Bool to add the optional bass to the notes
Return Value
An array with
Root
arrays -
Create a
ChordDefinition
struct from a string which defines a Chord with a ChordPro define directiveFor more information about the layout, have a look at https://www.chordpro.org/chordpro/directives-define/
Declaration
Swift
static func define(from define: String, instrument: Instrument) throws -> ChordDefinition
Parameters
define
ChordPro string definition of the chord
instrument
The
Instrument
to useReturn Value
A
ChordDefinition
struct, if found, else an Error -
Create a
ChordDefinition
structure from a ChordPro JSON chordFor more information about the layout, have a look at https://www.chordpro.org/chordpro/directives-define/
Declaration
Swift
static func define(from chord: ChordPro.Instrument.Chord, instrument: Instrument) throws -> ChordDefinition
Parameters
chord
A ChordPro JSON chord
instrument
The
Instrument
to useReturn Value
A
ChordDefinition
struct, if found, else an Error