A customizable piano component
{ notes : Set Note
, noteRange : ( Note
, Note )
, interactive : Basics.Bool
, showSizeSelector : Basics.Bool
, debugNotes : Basics.Bool
}
The model of the component.
notes is the set of currently pressed notes.
noteRange determines the first and last notes of the keyboard.
If interactive is True, the component will generate KeyUp and KeyDown messages when the user clicks on a note. (Now this mode is experimental and has some UI issues).
If showSizeSelector is True a button group will be shown to select the keyboard size.
If debugNotes is True a text will appear, showin the note names of each currently pressed note.
initialModel : Model
Common initial configuration for the component
Now it starts with no keys being pressed in a 25-key keyboard, in interactive mode and with the size selector and the note debugger.
Basics.Int
Represents a note giving its MIDI Note Number
See http://www.electronics.dit.ie/staff/tscarff/Music_technology/midi/midi_note_numbers_for_octaves.htm for more information
update : Msg -> Model -> Model
Handle the messages by updating model.notes or model.noteRange
Messages received when clicking a key or changing the keyboard's size
keyboard12Keys : ( Basics.Int, Basics.Int )
Note range of a 12-key keyboard
keyboard25Keys : ( Basics.Int, Basics.Int )
Note range of a 25-key keyboard
keyboard49Keys : ( Basics.Int, Basics.Int )
Note range of a 49-key keyboard
keyboard61Keys : ( Basics.Int, Basics.Int )
Note range of a 61-key keyboard
keyboard76Keys : ( Basics.Int, Basics.Int )
Note range of a 76-key keyboard
keyboard88Keys : ( Basics.Int, Basics.Int )
Note range of a 88-key keyboard
view : Model -> Html Msg
Show the Piano component and, if set in the model, the debug text and the keyboard size changer.
noteName : Note -> String
Represent a note number as a string
isNatural : Note -> Basics.Bool
Return False is note is a flat or sharp, True otherwise
octave : Note -> Basics.Int
Octave number of a note