Skip to content
RxJS bindings for Web MIDI API
JavaScript HTML
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dist
example
lib
test
.eslintrc
.gitignore
README.md
package.json

README.md

RxJS bindings for Web MIDI API

Allows accessing Web MIDI API events as observable sequences.

API

The bindings module provides following functions:

statechangeAsObservable(MIDIAccess)

Returns an observable sequence of MIDIConnectionEvent objects. MIDIAccess object is to be given as an argument.

midimessageAsObservable(MIDIInput)

Returns an observable sequence of MIDIMessageEvent objects. MIDIInput object is to be given as an argument.

Example usage

import Rx from 'rx';
import { midimessageAsObservable } from 'rxjs-web-midi';

Rx.Observable.fromPromise(navigator.requestMIDIAccess())
    .map(midi => {
        // Select first available input
        return midi.inputs.values().next().value;
    })
    .flatMap(input => {
        // Get stream of messages
        return midimessageAsObservable(input);
    })
    .subscribe(message => {
        // Output the message
        console.log(message);
    });

A more complete example program is included and can be built with npm run build:example.

You can’t perform that action at this time.