This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
1.0.0

Maestro.Note

This module provides types and functions to manipulate musical notes. Notes being represented as a tone and an octave convertible to an index (MIDI value)

Types

type alias Octave = Int

Octave represents an octave number, as represented in piano or MIDI notation

type alias Note = { tone : Tone , octave : Octave }

Note represents a tone on a given octave

Common Helpers

newNote : Key -> Adjustment -> Octave -> Note

newNote is a helper function to create a note

noteToIndex : Note -> Int

noteToIndex returns the MIDI value of a given note

module Maestro.Note exposing (..)

{-| This module provides types and functions to manipulate musical notes.
Notes being represented as a tone and an octave convertible to an index (MIDI value)

# Types
@docs Octave, Note

# Common Helpers
@docs newNote, noteToIndex

-}

import Maestro.Tone exposing (Tone, Key, Adjustment, newTone, adjustmentToValue, keyToValue)


{-| Octave represents an octave number, as represented in piano or MIDI notation
-}
type alias Octave =
    Int


{-| Note represents a tone on a given octave
-}
type alias Note =
    { tone : Tone
    , octave : Octave
    }


{-| newNote is a helper function to create a note
-}
newNote : Key -> Adjustment -> Octave -> Note
newNote key adjustment octave =
    { tone = newTone key adjustment, octave = octave }


{-| noteToIndex returns the MIDI value of a given note
-}
noteToIndex : Note -> Int
noteToIndex note =
    note.octave * 12 + (keyToValue note.tone.key) + (adjustmentToValue note.tone.adjustment)