Rename NoteClass -> PitchClass
For the past two to three days, I've been searching for the name for the concept of "C" or "A". From what I read, notes are specific things like C0 or C4, but I wanted the name of the concept of a C. Thankfully today I discovered that this is called a pitch class.
This commit is contained in:
parent
edc8f4ef6e
commit
774c0ddf05
2 changed files with 151 additions and 148 deletions
|
@ -17,7 +17,7 @@ type alias Model =
|
||||||
{ whitelistedChords : List Theory.Chord
|
{ whitelistedChords : List Theory.Chord
|
||||||
, whitelistedChordTypes : List Theory.ChordType
|
, whitelistedChordTypes : List Theory.ChordType
|
||||||
, whitelistedInversions : List Theory.ChordInversion
|
, whitelistedInversions : List Theory.ChordInversion
|
||||||
, whitelistedNoteClasses : List Theory.NoteClass
|
, whitelistedPitchClasses : List Theory.PitchClass
|
||||||
, selectedChord : Maybe Theory.Chord
|
, selectedChord : Maybe Theory.Chord
|
||||||
, isPaused : Bool
|
, isPaused : Bool
|
||||||
, tempo : Int
|
, tempo : Int
|
||||||
|
@ -41,7 +41,7 @@ type Msg
|
||||||
| ToggleInspectChord
|
| ToggleInspectChord
|
||||||
| ToggleInversion Theory.ChordInversion
|
| ToggleInversion Theory.ChordInversion
|
||||||
| ToggleChordType Theory.ChordType
|
| ToggleChordType Theory.ChordType
|
||||||
| ToggleNoteClass Theory.NoteClass
|
| TogglePitchClass Theory.PitchClass
|
||||||
| DoNothing
|
| DoNothing
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,8 +78,8 @@ init =
|
||||||
chordTypes =
|
chordTypes =
|
||||||
Theory.allChordTypes
|
Theory.allChordTypes
|
||||||
|
|
||||||
noteClasses =
|
pitchClasses =
|
||||||
Theory.allNoteClasses
|
Theory.allPitchClasses
|
||||||
in
|
in
|
||||||
{ whitelistedChords =
|
{ whitelistedChords =
|
||||||
Theory.allChords
|
Theory.allChords
|
||||||
|
@ -87,11 +87,11 @@ init =
|
||||||
, end = lastNote
|
, end = lastNote
|
||||||
, inversions = inversions
|
, inversions = inversions
|
||||||
, chordTypes = chordTypes
|
, chordTypes = chordTypes
|
||||||
, noteClasses = noteClasses
|
, pitchClasses = pitchClasses
|
||||||
}
|
}
|
||||||
, whitelistedChordTypes = chordTypes
|
, whitelistedChordTypes = chordTypes
|
||||||
, whitelistedInversions = inversions
|
, whitelistedInversions = inversions
|
||||||
, whitelistedNoteClasses = noteClasses
|
, whitelistedPitchClasses = pitchClasses
|
||||||
, selectedChord = Nothing
|
, selectedChord = Nothing
|
||||||
, isPaused = True
|
, isPaused = True
|
||||||
, tempo = 60
|
, tempo = 60
|
||||||
|
@ -187,7 +187,7 @@ update msg model =
|
||||||
, end = model.lastNote
|
, end = model.lastNote
|
||||||
, inversions = model.whitelistedInversions
|
, inversions = model.whitelistedInversions
|
||||||
, chordTypes = chordTypes
|
, chordTypes = chordTypes
|
||||||
, noteClasses = model.whitelistedNoteClasses
|
, pitchClasses = model.whitelistedPitchClasses
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
, Cmd.none
|
, Cmd.none
|
||||||
|
@ -210,30 +210,30 @@ update msg model =
|
||||||
, end = model.lastNote
|
, end = model.lastNote
|
||||||
, inversions = inversions
|
, inversions = inversions
|
||||||
, chordTypes = model.whitelistedChordTypes
|
, chordTypes = model.whitelistedChordTypes
|
||||||
, noteClasses = model.whitelistedNoteClasses
|
, pitchClasses = model.whitelistedPitchClasses
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
, Cmd.none
|
, Cmd.none
|
||||||
)
|
)
|
||||||
|
|
||||||
ToggleNoteClass noteClass ->
|
TogglePitchClass pitchClass ->
|
||||||
let
|
let
|
||||||
noteClasses =
|
pitchClasses =
|
||||||
if List.member noteClass model.whitelistedNoteClasses then
|
if List.member pitchClass model.whitelistedPitchClasses then
|
||||||
List.filter ((/=) noteClass) model.whitelistedNoteClasses
|
List.filter ((/=) pitchClass) model.whitelistedPitchClasses
|
||||||
|
|
||||||
else
|
else
|
||||||
noteClass :: model.whitelistedNoteClasses
|
pitchClass :: model.whitelistedPitchClasses
|
||||||
in
|
in
|
||||||
( { model
|
( { model
|
||||||
| whitelistedNoteClasses = noteClasses
|
| whitelistedPitchClasses = pitchClasses
|
||||||
, whitelistedChords =
|
, whitelistedChords =
|
||||||
Theory.allChords
|
Theory.allChords
|
||||||
{ start = model.firstNote
|
{ start = model.firstNote
|
||||||
, end = model.lastNote
|
, end = model.lastNote
|
||||||
, inversions = model.whitelistedInversions
|
, inversions = model.whitelistedInversions
|
||||||
, chordTypes = model.whitelistedChordTypes
|
, chordTypes = model.whitelistedChordTypes
|
||||||
, noteClasses = noteClasses
|
, pitchClasses = pitchClasses
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
, Cmd.none
|
, Cmd.none
|
||||||
|
@ -270,18 +270,18 @@ debugger =
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
noteClassCheckboxes : List Theory.NoteClass -> Html Msg
|
pitchClassCheckboxes : List Theory.PitchClass -> Html Msg
|
||||||
noteClassCheckboxes noteClasses =
|
pitchClassCheckboxes pitchClasses =
|
||||||
ul []
|
ul []
|
||||||
(Theory.allNoteClasses
|
(Theory.allPitchClasses
|
||||||
|> List.map
|
|> List.map
|
||||||
(\noteClass ->
|
(\pitchClass ->
|
||||||
li []
|
li []
|
||||||
[ label [] [ text (Theory.viewNoteClass noteClass) ]
|
[ label [] [ text (Theory.viewPitchClass pitchClass) ]
|
||||||
, input
|
, input
|
||||||
[ type_ "checkbox"
|
[ type_ "checkbox"
|
||||||
, onClick (ToggleNoteClass noteClass)
|
, onClick (TogglePitchClass pitchClass)
|
||||||
, checked (List.member noteClass noteClasses)
|
, checked (List.member pitchClass pitchClasses)
|
||||||
]
|
]
|
||||||
[]
|
[]
|
||||||
]
|
]
|
||||||
|
@ -364,7 +364,7 @@ view model =
|
||||||
, handleDecrease = DecreaseTempo
|
, handleDecrease = DecreaseTempo
|
||||||
, handleInput = SetTempo
|
, handleInput = SetTempo
|
||||||
}
|
}
|
||||||
, noteClassCheckboxes model.whitelistedNoteClasses
|
, pitchClassCheckboxes model.whitelistedPitchClasses
|
||||||
, inversionCheckboxes model.whitelistedInversions
|
, inversionCheckboxes model.whitelistedInversions
|
||||||
, chordTypeCheckboxes model.whitelistedChordTypes
|
, chordTypeCheckboxes model.whitelistedChordTypes
|
||||||
, playPause model
|
, playPause model
|
||||||
|
|
|
@ -110,7 +110,7 @@ type Note
|
||||||
{-| I alluded to this concept in the Note type's documentation. These are the
|
{-| I alluded to this concept in the Note type's documentation. These are the
|
||||||
letters of notes. For instance C2, C3, C4 are all instances of C.
|
letters of notes. For instance C2, C3, C4 are all instances of C.
|
||||||
-}
|
-}
|
||||||
type NoteClass
|
type PitchClass
|
||||||
= C
|
= C
|
||||||
| C_sharp
|
| C_sharp
|
||||||
| D
|
| D
|
||||||
|
@ -205,7 +205,7 @@ type KeyClass
|
||||||
chords that harmonize with one another.
|
chords that harmonize with one another.
|
||||||
-}
|
-}
|
||||||
type alias Key =
|
type alias Key =
|
||||||
{ noteClass : NoteClass
|
{ pitchClass : PitchClass
|
||||||
, mode : Mode
|
, mode : Mode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,24 +225,24 @@ type Mode
|
||||||
type alias NoteMetadata =
|
type alias NoteMetadata =
|
||||||
{ note : Note
|
{ note : Note
|
||||||
, label : String
|
, label : String
|
||||||
, noteClass : NoteClass
|
, pitchClass : PitchClass
|
||||||
, natural : Bool
|
, natural : Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
scaleDegree : Int -> Key -> NoteClass
|
scaleDegree : Int -> Key -> PitchClass
|
||||||
scaleDegree which { noteClass } =
|
scaleDegree which { pitchClass } =
|
||||||
case noteClass of
|
case pitchClass of
|
||||||
_ ->
|
_ ->
|
||||||
C
|
C
|
||||||
|
|
||||||
|
|
||||||
{-| Returns the Note in the cental octave of the piano for a given
|
{-| Returns the Note in the cental octave of the piano for a given
|
||||||
NoteClass. For example, C4 -- or "middle C" -- for C.
|
PitchClass. For example, C4 -- or "middle C" -- for C.
|
||||||
-}
|
-}
|
||||||
noteInCentralOctave : NoteClass -> Note
|
noteInCentralOctave : PitchClass -> Note
|
||||||
noteInCentralOctave noteClass =
|
noteInCentralOctave pitchClass =
|
||||||
case noteClass of
|
case pitchClass of
|
||||||
C ->
|
C ->
|
||||||
C4
|
C4
|
||||||
|
|
||||||
|
@ -543,7 +543,7 @@ step { direction, interval } note =
|
||||||
{ direction = direction
|
{ direction = direction
|
||||||
, interval = Half
|
, interval = Half
|
||||||
}
|
}
|
||||||
|> (\x -> applySteps x note)
|
|> (\x -> walkNotes x note)
|
||||||
|> Maybe.andThen (List.reverse >> List.head)
|
|> Maybe.andThen (List.reverse >> List.head)
|
||||||
|
|
||||||
Whole ->
|
Whole ->
|
||||||
|
@ -598,13 +598,15 @@ In the case where applying any of the steps would result in running off of
|
||||||
either edge of the piano, this function returns a Nothing.
|
either edge of the piano, this function returns a Nothing.
|
||||||
|
|
||||||
-}
|
-}
|
||||||
applySteps : List IntervalVector -> Note -> Maybe (List Note)
|
walkNotes : List IntervalVector -> Note -> Maybe (List Note)
|
||||||
applySteps steps note =
|
walkNotes steps note =
|
||||||
doApplySteps steps note [] |> Maybe.map List.reverse
|
doWalkNotes steps note [] |> Maybe.map List.reverse
|
||||||
|
|
||||||
|
|
||||||
doApplySteps : List IntervalVector -> Note -> List Note -> Maybe (List Note)
|
{-| Recursive helper for `walkNotes`.
|
||||||
doApplySteps steps note result =
|
-}
|
||||||
|
doWalkNotes : List IntervalVector -> Note -> List Note -> Maybe (List Note)
|
||||||
|
doWalkNotes steps note result =
|
||||||
case steps of
|
case steps of
|
||||||
[] ->
|
[] ->
|
||||||
Just (note :: result)
|
Just (note :: result)
|
||||||
|
@ -612,7 +614,7 @@ doApplySteps steps note result =
|
||||||
s :: rest ->
|
s :: rest ->
|
||||||
case step s note of
|
case step s note of
|
||||||
Just x ->
|
Just x ->
|
||||||
doApplySteps rest x (note :: result)
|
doWalkNotes rest x (note :: result)
|
||||||
|
|
||||||
Nothing ->
|
Nothing ->
|
||||||
Nothing
|
Nothing
|
||||||
|
@ -629,11 +631,11 @@ keyClass note =
|
||||||
Accidental
|
Accidental
|
||||||
|
|
||||||
|
|
||||||
{-| Return the NoteClass for a given note.
|
{-| Return the PitchClass for a given note.
|
||||||
-}
|
-}
|
||||||
classifyNote : Note -> NoteClass
|
classifyNote : Note -> PitchClass
|
||||||
classifyNote note =
|
classifyNote note =
|
||||||
note |> getNoteMetadata |> .noteClass
|
note |> getNoteMetadata |> .pitchClass
|
||||||
|
|
||||||
|
|
||||||
{-| Return a list of the notes that comprise a `chord`
|
{-| Return a list of the notes that comprise a `chord`
|
||||||
|
@ -649,12 +651,12 @@ notesForChord { note, chordType, chordInversion } =
|
||||||
{-| Return the scale for a given `key`
|
{-| Return the scale for a given `key`
|
||||||
-}
|
-}
|
||||||
notesForKey : Key -> List Note
|
notesForKey : Key -> List Note
|
||||||
notesForKey { noteClass, mode } =
|
notesForKey { pitchClass, mode } =
|
||||||
let
|
let
|
||||||
origin =
|
origin =
|
||||||
noteInCentralOctave noteClass
|
noteInCentralOctave pitchClass
|
||||||
in
|
in
|
||||||
case applySteps (intervalsForMode mode) origin of
|
case walkNotes (intervalsForMode mode) origin of
|
||||||
-- We should never hit the Nothing case here.
|
-- We should never hit the Nothing case here.
|
||||||
Nothing ->
|
Nothing ->
|
||||||
[]
|
[]
|
||||||
|
@ -716,94 +718,98 @@ allChordTypes =
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
{-| Return an array of every note on a piano.
|
||||||
|
Note: Currently this piano has 85 keys, but modern pianos have 88 keys. I would
|
||||||
|
prefer to have 88 keys, but it's not urgent.
|
||||||
|
-}
|
||||||
noteMetadata : Array NoteMetadata
|
noteMetadata : Array NoteMetadata
|
||||||
noteMetadata =
|
noteMetadata =
|
||||||
Array.fromList
|
Array.fromList
|
||||||
[ { note = A1, label = "A1", noteClass = A, natural = True }
|
[ { note = A1, label = "A1", pitchClass = A, natural = True }
|
||||||
, { note = A_sharp1, label = "A♯/B♭1", noteClass = A_sharp, natural = False }
|
, { note = A_sharp1, label = "A♯/B♭1", pitchClass = A_sharp, natural = False }
|
||||||
, { note = B1, label = "B1", noteClass = B, natural = True }
|
, { note = B1, label = "B1", pitchClass = B, natural = True }
|
||||||
, { note = C1, label = "C1", noteClass = C, natural = True }
|
, { note = C1, label = "C1", pitchClass = C, natural = True }
|
||||||
, { note = C_sharp1, label = "C♯/D♭1", noteClass = C_sharp, natural = False }
|
, { note = C_sharp1, label = "C♯/D♭1", pitchClass = C_sharp, natural = False }
|
||||||
, { note = D1, label = "D1", noteClass = D, natural = True }
|
, { note = D1, label = "D1", pitchClass = D, natural = True }
|
||||||
, { note = D_sharp1, label = "D♯/E♭1", noteClass = D_sharp, natural = False }
|
, { note = D_sharp1, label = "D♯/E♭1", pitchClass = D_sharp, natural = False }
|
||||||
, { note = E1, label = "E1", noteClass = E, natural = True }
|
, { note = E1, label = "E1", pitchClass = E, natural = True }
|
||||||
, { note = F1, label = "F1", noteClass = F, natural = True }
|
, { note = F1, label = "F1", pitchClass = F, natural = True }
|
||||||
, { note = F_sharp1, label = "F♯/G♭1", noteClass = F_sharp, natural = False }
|
, { note = F_sharp1, label = "F♯/G♭1", pitchClass = F_sharp, natural = False }
|
||||||
, { note = G1, label = "G1", noteClass = G, natural = True }
|
, { note = G1, label = "G1", pitchClass = G, natural = True }
|
||||||
, { note = G_sharp1, label = "G♯/A♭1", noteClass = G, natural = False }
|
, { note = G_sharp1, label = "G♯/A♭1", pitchClass = G, natural = False }
|
||||||
, { note = A2, label = "A2", noteClass = A, natural = True }
|
, { note = A2, label = "A2", pitchClass = A, natural = True }
|
||||||
, { note = A_sharp2, label = "A♯/B♭2", noteClass = A_sharp, natural = False }
|
, { note = A_sharp2, label = "A♯/B♭2", pitchClass = A_sharp, natural = False }
|
||||||
, { note = B2, label = "B2", noteClass = B, natural = True }
|
, { note = B2, label = "B2", pitchClass = B, natural = True }
|
||||||
, { note = C2, label = "C2", noteClass = C, natural = True }
|
, { note = C2, label = "C2", pitchClass = C, natural = True }
|
||||||
, { note = C_sharp2, label = "C♯/D♭2", noteClass = C_sharp, natural = False }
|
, { note = C_sharp2, label = "C♯/D♭2", pitchClass = C_sharp, natural = False }
|
||||||
, { note = D2, label = "D2", noteClass = D, natural = True }
|
, { note = D2, label = "D2", pitchClass = D, natural = True }
|
||||||
, { note = D_sharp2, label = "D♯/E♭2", noteClass = D_sharp, natural = False }
|
, { note = D_sharp2, label = "D♯/E♭2", pitchClass = D_sharp, natural = False }
|
||||||
, { note = E2, label = "E2", noteClass = E, natural = True }
|
, { note = E2, label = "E2", pitchClass = E, natural = True }
|
||||||
, { note = F2, label = "F2", noteClass = F, natural = True }
|
, { note = F2, label = "F2", pitchClass = F, natural = True }
|
||||||
, { note = F_sharp2, label = "F♯/G♭2", noteClass = F_sharp, natural = False }
|
, { note = F_sharp2, label = "F♯/G♭2", pitchClass = F_sharp, natural = False }
|
||||||
, { note = G2, label = "G2", noteClass = G, natural = True }
|
, { note = G2, label = "G2", pitchClass = G, natural = True }
|
||||||
, { note = G_sharp2, label = "G♯/A♭2", noteClass = G, natural = False }
|
, { note = G_sharp2, label = "G♯/A♭2", pitchClass = G, natural = False }
|
||||||
, { note = A3, label = "A3", noteClass = A, natural = True }
|
, { note = A3, label = "A3", pitchClass = A, natural = True }
|
||||||
, { note = A_sharp3, label = "A♯/B♭3", noteClass = A_sharp, natural = False }
|
, { note = A_sharp3, label = "A♯/B♭3", pitchClass = A_sharp, natural = False }
|
||||||
, { note = B3, label = "B3", noteClass = B, natural = True }
|
, { note = B3, label = "B3", pitchClass = B, natural = True }
|
||||||
, { note = C3, label = "C3", noteClass = C, natural = True }
|
, { note = C3, label = "C3", pitchClass = C, natural = True }
|
||||||
, { note = C_sharp3, label = "C♯/D♭3", noteClass = C_sharp, natural = False }
|
, { note = C_sharp3, label = "C♯/D♭3", pitchClass = C_sharp, natural = False }
|
||||||
, { note = D3, label = "D3", noteClass = D, natural = True }
|
, { note = D3, label = "D3", pitchClass = D, natural = True }
|
||||||
, { note = D_sharp3, label = "D♯/E♭3", noteClass = D_sharp, natural = False }
|
, { note = D_sharp3, label = "D♯/E♭3", pitchClass = D_sharp, natural = False }
|
||||||
, { note = E3, label = "E3", noteClass = E, natural = True }
|
, { note = E3, label = "E3", pitchClass = E, natural = True }
|
||||||
, { note = F3, label = "F3", noteClass = F, natural = True }
|
, { note = F3, label = "F3", pitchClass = F, natural = True }
|
||||||
, { note = F_sharp3, label = "F♯/G♭3", noteClass = F_sharp, natural = False }
|
, { note = F_sharp3, label = "F♯/G♭3", pitchClass = F_sharp, natural = False }
|
||||||
, { note = G3, label = "G3", noteClass = G, natural = True }
|
, { note = G3, label = "G3", pitchClass = G, natural = True }
|
||||||
, { note = G_sharp3, label = "G♯/A♭3", noteClass = G, natural = False }
|
, { note = G_sharp3, label = "G♯/A♭3", pitchClass = G, natural = False }
|
||||||
, { note = A4, label = "A4", noteClass = A, natural = True }
|
, { note = A4, label = "A4", pitchClass = A, natural = True }
|
||||||
, { note = A_sharp4, label = "A♯/B♭4", noteClass = A_sharp, natural = False }
|
, { note = A_sharp4, label = "A♯/B♭4", pitchClass = A_sharp, natural = False }
|
||||||
, { note = B4, label = "B4", noteClass = B, natural = True }
|
, { note = B4, label = "B4", pitchClass = B, natural = True }
|
||||||
, { note = C4, label = "C4", noteClass = C, natural = True }
|
, { note = C4, label = "C4", pitchClass = C, natural = True }
|
||||||
, { note = C_sharp4, label = "C♯/D♭4", noteClass = C_sharp, natural = False }
|
, { note = C_sharp4, label = "C♯/D♭4", pitchClass = C_sharp, natural = False }
|
||||||
, { note = D4, label = "D4", noteClass = D, natural = True }
|
, { note = D4, label = "D4", pitchClass = D, natural = True }
|
||||||
, { note = D_sharp4, label = "D♯/E♭4", noteClass = D_sharp, natural = False }
|
, { note = D_sharp4, label = "D♯/E♭4", pitchClass = D_sharp, natural = False }
|
||||||
, { note = E4, label = "E4", noteClass = E, natural = True }
|
, { note = E4, label = "E4", pitchClass = E, natural = True }
|
||||||
, { note = F4, label = "F4", noteClass = F, natural = True }
|
, { note = F4, label = "F4", pitchClass = F, natural = True }
|
||||||
, { note = F_sharp4, label = "F♯/G♭4", noteClass = F_sharp, natural = False }
|
, { note = F_sharp4, label = "F♯/G♭4", pitchClass = F_sharp, natural = False }
|
||||||
, { note = G4, label = "G4", noteClass = G, natural = True }
|
, { note = G4, label = "G4", pitchClass = G, natural = True }
|
||||||
, { note = G_sharp4, label = "G♯/A♭4", noteClass = G, natural = False }
|
, { note = G_sharp4, label = "G♯/A♭4", pitchClass = G, natural = False }
|
||||||
, { note = A5, label = "A5", noteClass = A, natural = True }
|
, { note = A5, label = "A5", pitchClass = A, natural = True }
|
||||||
, { note = A_sharp5, label = "A♯/B♭5", noteClass = A_sharp, natural = False }
|
, { note = A_sharp5, label = "A♯/B♭5", pitchClass = A_sharp, natural = False }
|
||||||
, { note = B5, label = "B5", noteClass = B, natural = True }
|
, { note = B5, label = "B5", pitchClass = B, natural = True }
|
||||||
, { note = C5, label = "C5", noteClass = C, natural = True }
|
, { note = C5, label = "C5", pitchClass = C, natural = True }
|
||||||
, { note = C_sharp5, label = "C♯/D♭5", noteClass = C_sharp, natural = False }
|
, { note = C_sharp5, label = "C♯/D♭5", pitchClass = C_sharp, natural = False }
|
||||||
, { note = D5, label = "D5", noteClass = D, natural = True }
|
, { note = D5, label = "D5", pitchClass = D, natural = True }
|
||||||
, { note = D_sharp5, label = "D♯/E♭5", noteClass = D_sharp, natural = False }
|
, { note = D_sharp5, label = "D♯/E♭5", pitchClass = D_sharp, natural = False }
|
||||||
, { note = E5, label = "E5", noteClass = E, natural = True }
|
, { note = E5, label = "E5", pitchClass = E, natural = True }
|
||||||
, { note = F5, label = "F5", noteClass = F, natural = True }
|
, { note = F5, label = "F5", pitchClass = F, natural = True }
|
||||||
, { note = F_sharp5, label = "F♯/G♭5", noteClass = F_sharp, natural = False }
|
, { note = F_sharp5, label = "F♯/G♭5", pitchClass = F_sharp, natural = False }
|
||||||
, { note = G5, label = "G5", noteClass = G, natural = True }
|
, { note = G5, label = "G5", pitchClass = G, natural = True }
|
||||||
, { note = G_sharp5, label = "G♯/A♭5", noteClass = G, natural = False }
|
, { note = G_sharp5, label = "G♯/A♭5", pitchClass = G, natural = False }
|
||||||
, { note = A6, label = "A6", noteClass = A, natural = True }
|
, { note = A6, label = "A6", pitchClass = A, natural = True }
|
||||||
, { note = A_sharp6, label = "A♯/B♭6", noteClass = A_sharp, natural = False }
|
, { note = A_sharp6, label = "A♯/B♭6", pitchClass = A_sharp, natural = False }
|
||||||
, { note = B6, label = "B6", noteClass = B, natural = True }
|
, { note = B6, label = "B6", pitchClass = B, natural = True }
|
||||||
, { note = C6, label = "C6", noteClass = C, natural = True }
|
, { note = C6, label = "C6", pitchClass = C, natural = True }
|
||||||
, { note = C_sharp6, label = "C♯/D♭6", noteClass = C_sharp, natural = False }
|
, { note = C_sharp6, label = "C♯/D♭6", pitchClass = C_sharp, natural = False }
|
||||||
, { note = D6, label = "D6", noteClass = D, natural = True }
|
, { note = D6, label = "D6", pitchClass = D, natural = True }
|
||||||
, { note = D_sharp6, label = "D♯/E♭6", noteClass = D_sharp, natural = False }
|
, { note = D_sharp6, label = "D♯/E♭6", pitchClass = D_sharp, natural = False }
|
||||||
, { note = E6, label = "E6", noteClass = E, natural = True }
|
, { note = E6, label = "E6", pitchClass = E, natural = True }
|
||||||
, { note = F6, label = "F6", noteClass = F, natural = True }
|
, { note = F6, label = "F6", pitchClass = F, natural = True }
|
||||||
, { note = F_sharp6, label = "F♯/G♭6", noteClass = F_sharp, natural = False }
|
, { note = F_sharp6, label = "F♯/G♭6", pitchClass = F_sharp, natural = False }
|
||||||
, { note = G6, label = "G6", noteClass = G, natural = True }
|
, { note = G6, label = "G6", pitchClass = G, natural = True }
|
||||||
, { note = G_sharp6, label = "G♯/A♭6", noteClass = G, natural = False }
|
, { note = G_sharp6, label = "G♯/A♭6", pitchClass = G, natural = False }
|
||||||
, { note = A7, label = "A7", noteClass = A, natural = True }
|
, { note = A7, label = "A7", pitchClass = A, natural = True }
|
||||||
, { note = A_sharp7, label = "A♯/B♭7", noteClass = A_sharp, natural = False }
|
, { note = A_sharp7, label = "A♯/B♭7", pitchClass = A_sharp, natural = False }
|
||||||
, { note = B7, label = "B7", noteClass = B, natural = True }
|
, { note = B7, label = "B7", pitchClass = B, natural = True }
|
||||||
, { note = C7, label = "C7", noteClass = C, natural = True }
|
, { note = C7, label = "C7", pitchClass = C, natural = True }
|
||||||
, { note = C_sharp7, label = "C♯/D♭7", noteClass = C_sharp, natural = False }
|
, { note = C_sharp7, label = "C♯/D♭7", pitchClass = C_sharp, natural = False }
|
||||||
, { note = D7, label = "D7", noteClass = D, natural = True }
|
, { note = D7, label = "D7", pitchClass = D, natural = True }
|
||||||
, { note = D_sharp7, label = "D♯/E♭7", noteClass = D_sharp, natural = False }
|
, { note = D_sharp7, label = "D♯/E♭7", pitchClass = D_sharp, natural = False }
|
||||||
, { note = E7, label = "E7", noteClass = E, natural = True }
|
, { note = E7, label = "E7", pitchClass = E, natural = True }
|
||||||
, { note = F7, label = "F7", noteClass = F, natural = True }
|
, { note = F7, label = "F7", pitchClass = F, natural = True }
|
||||||
, { note = F_sharp7, label = "F♯/G♭7", noteClass = F_sharp, natural = False }
|
, { note = F_sharp7, label = "F♯/G♭7", pitchClass = F_sharp, natural = False }
|
||||||
, { note = G7, label = "G7", noteClass = G, natural = True }
|
, { note = G7, label = "G7", pitchClass = G, natural = True }
|
||||||
, { note = G_sharp7, label = "G♯/A♭7", noteClass = G, natural = False }
|
, { note = G_sharp7, label = "G♯/A♭7", pitchClass = G, natural = False }
|
||||||
, { note = C8, label = "C8", noteClass = C, natural = True }
|
, { note = C8, label = "C8", pitchClass = C, natural = True }
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -1106,10 +1112,10 @@ chordWithinRange start end chord =
|
||||||
False
|
False
|
||||||
|
|
||||||
|
|
||||||
{-| Return a list of all of the chords that we know about.
|
{-| Return a list of all of the pitch classes that we know about.
|
||||||
-}
|
-}
|
||||||
allNoteClasses : List NoteClass
|
allPitchClasses : List PitchClass
|
||||||
allNoteClasses =
|
allPitchClasses =
|
||||||
[ C
|
[ C
|
||||||
, C_sharp
|
, C_sharp
|
||||||
, D
|
, D
|
||||||
|
@ -1134,14 +1140,14 @@ allChords :
|
||||||
, end : Note
|
, end : Note
|
||||||
, inversions : List ChordInversion
|
, inversions : List ChordInversion
|
||||||
, chordTypes : List ChordType
|
, chordTypes : List ChordType
|
||||||
, noteClasses : List NoteClass
|
, pitchClasses : List PitchClass
|
||||||
}
|
}
|
||||||
-> List Chord
|
-> List Chord
|
||||||
allChords { start, end, inversions, chordTypes, noteClasses } =
|
allChords { start, end, inversions, chordTypes, pitchClasses } =
|
||||||
let
|
let
|
||||||
notes =
|
notes =
|
||||||
notesFromRange start end
|
notesFromRange start end
|
||||||
|> List.filter (\note -> List.member (classifyNote note) noteClasses)
|
|> List.filter (\note -> List.member (classifyNote note) pitchClasses)
|
||||||
in
|
in
|
||||||
notes
|
notes
|
||||||
|> List.Extra.andThen
|
|> List.Extra.andThen
|
||||||
|
@ -1163,28 +1169,25 @@ allChords { start, end, inversions, chordTypes, noteClasses } =
|
||||||
|> List.filter (chordWithinRange start end)
|
|> List.filter (chordWithinRange start end)
|
||||||
|
|
||||||
|
|
||||||
{-| Serialize a human-readable format of `note`.
|
{-| Return a human-readable format of `note`.
|
||||||
-}
|
-}
|
||||||
viewNote : Note -> String
|
viewNote : Note -> String
|
||||||
viewNote note =
|
viewNote note =
|
||||||
note |> getNoteMetadata |> .label
|
note |> getNoteMetadata |> .label
|
||||||
|
|
||||||
|
|
||||||
inspectChord : Chord -> String
|
{-| Return a human-readable format of `chord`.
|
||||||
inspectChord { note, chordType, chordInversion } =
|
-}
|
||||||
viewNote note ++ " " ++ chordTypeName chordType ++ " " ++ inversionName chordInversion ++ " position"
|
|
||||||
|
|
||||||
|
|
||||||
viewChord : Chord -> String
|
viewChord : Chord -> String
|
||||||
viewChord { note, chordType, chordInversion } =
|
viewChord { note, chordType, chordInversion } =
|
||||||
viewNoteClass (classifyNote note) ++ " " ++ chordTypeName chordType ++ " " ++ inversionName chordInversion ++ " position"
|
viewPitchClass (classifyNote note) ++ " " ++ chordTypeName chordType ++ " " ++ inversionName chordInversion ++ " position"
|
||||||
|
|
||||||
|
|
||||||
{-| Serialize a human-readable format of `noteClass`.
|
{-| Return a human-readable format of `pitchClass`.
|
||||||
-}
|
-}
|
||||||
viewNoteClass : NoteClass -> String
|
viewPitchClass : PitchClass -> String
|
||||||
viewNoteClass noteClass =
|
viewPitchClass pitchClass =
|
||||||
case noteClass of
|
case pitchClass of
|
||||||
C ->
|
C ->
|
||||||
"C"
|
"C"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue