Enumeration
Note
public enum Note
A custom note.
Create a Note either by using its name:
Note("D#") // Note.D_sharp
or by directly using enum cases:
Note.B_flat
Flat and sharp versions are equivalent for the same note.
Note("C#") == Note("Db") // true
Relationships
Conforms To
CaseIterable
Equatable
Hashable
LosslessStringConvertible
Initializers
Enumeration Cases
Properties
allCasesInFlats
public static let allCasesInFlats: [Note] = [.C, .D_flat, .D, .E_flat, .E, .F, .G_flat, .G, .A_flat, .A, .B_flat, .B]
All notes enumerated with flat accidentals.
allCasesInSharps
public static let allCasesInSharps: [Note] = [.C, .C_sharp, .D, .D_sharp, .E, .F, .F_sharp, .G, .G_sharp, .A, .A_sharp, .B]
All notes enumerated with sharp accidentals.
absolutePosition
public var absolutePosition: Int
Absolute position of the note, for conveience of calulation.
By default, C is 0, C# is 1, ..., B is 11.
Methods
isConsonant(with:)
public func isConsonant(with anotherNote: Note) -> Bool
See if this note is consonant with another.
Operators
+
public static func + (_ lhs: Self, _ rhs: Interval) -> Self
Compute the note a certain Interval above it.
Parameters
Name | Type | Description |
---|---|---|
lhs | Self |
Base note. |
rhs | Interval |
Interval above the base note. |
Returns
The note a specified interval above the base note.
-
public static func - (_ lhs: Self, _ rhs: Interval) -> Self
Compute the note a certain Interval below it.
Parameters
Name | Type | Description |
---|---|---|
lhs | Self |
Base note. |
rhs | Interval |
Interval below the base note. |
Returns
The note a specified interval below the base note.
-
Compute the Interval between two notes within an octave.
The following expression will return Interval
.
Note.D - Note.E
Parameters
Name | Type | Description |
---|---|---|
lhs | Note |
The higher note. |
rhs | Note |
The lower note. |
Returns
The interval between the two notes.