This library provides music theory abstractions and functionalities.
Alpha stage: this library is not considered stable yet, and could be subject to API changes in the future.
elm-package oleiade/elm-maestro
or add the dependency in your elm-package.json
file directly
"oleiade/elm-maestro": "0.1.0 <= v < 0.2.0"
The Maestro.PitchClass
module exposes the following types:
type alias Pitch =
{ class : PitchClass, accidental : Accidental }
type PitchClass
= C
| D
| E
| F
| G
| A
| B
type Accidental
= Natural
| Sharp
| Flat
| SharpSharp
| FlatFlat
in order to represent pitches/pitches as follows:
import Maestro.PitchClass exposing(PitchClass(..), Accidental(..))
cNatural = newPitch C Natural
dSharp = newPitch D Sharp
bFlat = newPitch B Flat
The Maestro.Note
module exposes the following types:
type alias Note =
{ pitch : Pitch
, octave : Octave
}
type alias Octave =
Int
in order to represent notes as follows:
import Maestro.PitchClass exposing (Pitch, PitchClass(..), Accidental(..))
import Maestro.Note exposing (newNote)
e3Natural = newNote E Natural 3
f4Sharp = newNote F Sharp 4
a1Flat = newNote A Flat 1
The Maestro.Interval
module exposes the following type:
type Interval
= Unison
| MinorSecond
| MajorSecond
| MinorThird
| MajorThird
| PerfectFourth
| PerfectFifth
| MinorSixth
| MajorSixth
| MinorSeventh
| MajorSeventh
| PerfectOctave
| MinorNinth
| MajorNinth
| MinorTenth
| MajorTenth
| PerfectEleventh
| AugmentedEleventh
| PerfectTwelfth
| MinorThirteen
| MajorThirteen
| MinorFourteenth
| MajorFourteenth
| DoubleOctave
and will allow you to find the note at interval from a start note like follows:
import Maestro.PitchClass exposing (PitchClass(..), Accidental(..), newPitch)
import Maestro.Interval exposing (Interval(..), addInterval)
example : Note
example =
addInterval (newNote C Natural 3) MajorThird
A Scale is represented as a list of Pitch. It is built from a pitch and a mode as follows:
import Maestro.PitchClass exposing (newPitch, PitchClass(..), Accidental(..))
import Maestro.Scale exposing (scale, Mode(..))
example : Scale
example =
doSomethingWith <| scale (newPitch C Natural) Major