This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
library for parsing MIDI files
version 3.0.0
license BSD3
native-modules False
elm-version 0.18.0 <= v < 0.19.0
Tag 3.0.0
Committed At 2018-05-27 07:51:45 UTC
elm-lang/core 5.0.0 <= v < 6.0.0 5.1.1
Bogdanp/elm-combine 3.1.1 <= v < 4.0.0 3.1.1

README

elm-comidi

Build Status

This is a parser for MIDI written in pure Elm 0.18 and using the elm-combine parser combinator library.

Unfortunately, Elm has very poor support for binary data. As from Elm 0.18, you can no longer load MIDI via http - instead you must rely on ports. The native javascript must use the readAsBinaryString function to access the MIDI recording which is then loaded into an Elm String. elm-comidi's normalise function is used to make sense of this String.

To parse a MIDI string that represents a MIDI file you can use:

midiFileData
  |> Midi.Parse.normalise
  |> Midi.Parse.file

This attempts to parse the contents and also translates running status messages to the appropriate underlying channel message (note on, note off, aftertouch etc.).

On the other hand, you may merely need to parse MIDI events (such as note on or note off) that come from a Web MIDI connection. In other words, you are connecting directly to a MIDI device through the browser and need to parse the stream of event messages as the instrument is played. To do this, use:

midiEventData
  |> Midi.Parse.event

This will attempt to parse an individual event. Note that Web MIDI does not generate running status messages and this method will not attempt to parse them.

The parser is intended to be a fully conformant with the MIDI standard and accepts Type-0, Type-1 and Type-2 files.

Dependencies

  • Bogdanp/elm-combine 3.1.1
  • elm-lang/core 5.0.0