MusicTheory Documentation

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
%27 Note Note Hashable Hashable Note->Hashable Equatable Equatable Note->Equatable LosslessStringConvertible LosslessStringConvertible Note->LosslessStringConvertible CaseIterable CaseIterable Note->CaseIterable

Conforms To

CaseIterable
Equatable
Hashable
LosslessStringConvertible

Initializers

init?(_:​)

public init?(_ description: String)  

Initialize a note from its name.

Enumeration Cases

C

case C

The note C.

C_sharp

case C_sharp

The note C♯.

D_flat

case D_flat

The note D♭.

D

case D

The note D.

D_sharp

case D_sharp

The note D♯

E_flat

case E_flat

The note E♭.

E

case E

The note E.

F

case F

The note F.

F_sharp

case F_sharp

The note F♯.

G_flat

case G_flat

The note G♭.

G

case G

The note G.

G_sharp

case G_sharp

The note G♯.

A_flat

case A_flat

The note A♭.

A

case A

The note A.

A_sharp

case A_sharp

The note A♯.

B_flat

case B_flat

The note B♭.

B

case B

The note B.

Properties

all​Cases​InFlats

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.

all​Cases​InSharps

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.

description

public var description: String  

Name of the note.

absolute​Position

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

hash(into:​)

public func hash(into hasher: inout Hasher)  

Hash function.

is​Consonant(with:​)

public func isConsonant(with anotherNote: Note) -> Bool  

See if this note is consonant with another.

is​In(chord:​)

public func isIn(chord: Chord) -> Bool  

Check if this note is in a specific chord.

is​In(scale:​)

public func isIn(scale: Scale) -> Bool  

Check if this note is in a specific scale.

Operators

==

public static func == (lhs: Note, rhs: Note) -> Bool  

Check if two notes are equal or just alias.

+

public static func + (_ lhs: Self, _ rhs: Interval) -> Self  

Compute the note a certain Interval above it.

Parameters

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

lhs Self

Base note.

rhs Interval

Interval below the base note.

Returns

The note a specified interval below the base note.

-

public static func - (_ lhs: Note, _ rhs: Note) -> Interval  

Compute the Interval between two notes within an octave.

The following expression will return Interval.

Note.D - Note.E

Parameters

lhs Note

The higher note.

rhs Note

The lower note.

Returns

The interval between the two notes.