/fable-import-webmidi

Fable Library to support WebMIDI

Primary LanguageF#MIT LicenseMIT

Fable.Import.WebMIDI

Fable bindings for Web MIDI

install with DotNet:

dotnet add package Fable.Import.WebMIDI

or with Paket:

paket add Fable.Import.WebMIDI

Usage

Example in Elmish:

open Fable.Import.WebMIDI

type Model = { MIDIAccess: IMIDIAccess option 
               ErrorMessage: string option }

type Msg = | MIDISuccess of IMIDIAccess
           | MIDIError of exn
           | MIDIStateChanged of IMIDIConnectionEvent

let init () : Model*Cmd<Msg> =
  { MIDIAccess = None 
    ErrorMessage = None }, Cmd.ofPromise MIDI.requestAccess [ Sysex true ] MIDISuccess MIDIError 

let update (msg: Msg) (model: Model) : Model*Cmd<Msg> = 
  match msg with
  | MIDISuccess of midiAccess ->
    let stateChangeSub dispatch =
      let onStateChange ev =
        dispatch (MIDIStateChanged ev)

      midiAccess.OnStateChange <- onStateChange

    { model with MIDIAccess = Some midiAccess }, Cmd.ofSub stateChangeSub
  | MIDIError of ex ->
    { model with ErrorMessage = Some ex.Message }, Cmd.none
  | MIDIStateChanged ev ->
    printfn "MIDI state changed"
    model, Cmd.none

...

Building

Make sure the following requirements are installed in your system:

Then you just need to type ./build.cmd or ./build.sh

Release

In order to push your package to [nuget.org][https://nuget.org] you need to add your API keys to NUGET_KEY environmental variable. You can create a key here.

#### 0.2.0 - 30.04.2017
* FEATURE: Does cool stuff!
* BUGFIX: Fixes that silly oversight
  • You can then use the Release target. This will:
    • make a commit bumping the version: Bump version to 0.2.0
    • publish the package to nuget
    • push a git tag

./build.sh Release

MacOS/Linux Windows
Travis build status AppVeyor Build status
Travis Build History AppVeyor Build History

Nuget

Stable Prerelease
NuGet Badge NuGet Badge