Package

purescript-school-of-music

Repository
newlandsvalley/purescript-school-of-music
License
MIT
Uploaded by
newlandsvalley
Published on
2020-12-06T18:35:23Z

Latest release Build Status

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.

Supported Instruments

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.

DSL

Melodies are presented to the browser using a DSL which has been designed to be as close as possible to the API itself.

Editor

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.

To build

 spago build

or

 bower install
 pulp build

To test

 npm run test 

To build the Halogen editor

 npm run halogen-editor

and then navigate to haleogen-editor/dist/index.html

Design Questions

DSL

What features would make the DSL pleasant and convenient to use?

Volume

What would be a sensible default value for a note volume (currently 100)?

To Do

  • 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:

  • Custom
  • KeySig
  • Ornamentation
  • Articulation other than Staccato, Legato and Slurred

Questions on the HSoM Implementation

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.