Try it out here.
This is another attempt at porting the music notation part of the Haskell School of Music (HSoM) to the browser. It consists of a PSoM library (ported from HSoM) together with an editor that runs in the browser. This allows you to enter melodies using a DSL and then play them.
It follows an abortive attempt in Elm in conjunction with danigb. This failed largely because of the lack of type classes in Elm but also because of the time delays inherent in Elm's port system when requesting that a sound should actually be played.
PSoM uses instruments from Benjamin Gleitzman's soundfont library which are enumerated in purescript-midi. It recognizes all the instruments listed here. The names differ slightly from those originally used by HSoM - the mapping between the two is shown here. MIDI allows up to 10 such instruments to be available for any given melody.
Melodies are presented to the browser using a DSL which has been designed to be as close as possible to the API itself.
The editor hase been developed using Halogen and allows you to enter PSoM text and will parse the text after every keystroke. If it is valid, a player will appear, otherwise an error message is shown. On startup, it loads a pre-selected set of instrument soundfonts which you can later change if you prefer. It also allows you to import an ABC file as PSoM and to load or save the PSoM text.
There is also a deprecated Pux editor which will not be maintained beyond PureScript 0.11.
npm run test
npm run halogen-editor
and then navigate to haleogen-editor/dist/index.html
What features would make the DSL pleasant and convenient to use?
What would be a sensible default value for a note volume (currently 100)?
- Allow variable definitions to refer to other variables defined earlier in the same scope
- Add quickcheck style tests to the PSoM library
The following control mechanisms are unimplemented because they also have not been implemented in HSoM:
- Articulation other than Staccato, Legato and Slurred
There seem to be various problems surrounding volume in MEvent. Perhaps it is because I am using only a MIDI backend which has a maximum volume setting of 7F (127). Firstly, crescendos seem to start at this volume level, although diminuendos are OK. Secondly, the Loudness implementation seems correctly to set the volume in the context but then to ignore it, taking the volume only of the original note.
The various articulations don't seem to work properly. Not sure yet if it's a bug in HSoM or in the translation to PureScript.