GithubHelp home page GithubHelp logo

elm-comidi's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.