Skip to main content

TypeScript library for all your MIDI needs

MIDIVal allows you to connect your MIDI keyboards, synthesisers, control pads and drum machines with your browsers, Node.js and React Native iOS / Android apps using universal, high-level API.

ic_fluent_midi_24_filled

MIDI Compliant

MIDIVal implements standard MIDI protocol making it compatible with wide range of MIDI devices like synthesisers, control pads and generic controllers.

TypeScript

Library is fully written in TypeScript. It exports all type definitions making is extremely easy to get started.

Platform agnostic

MIDIVal integrates with browsers, Node.js and iOS and Android apps (React Native). Whatever your platform of choice, the code will look identical.

Open Sourced

All code is open-sourced. Contributions are welcome.

MIDIVal Packages

@midival/core

Core library. Includes all logic to connect and manage your MIDI Input and Outputs as well as Browser adapter (applied by default).

console

@midival/node

Adapter for Node.js

@midival/react-native

Adapter for React Native

Getting Started

The following code sets up connection with your MIDI keyboard and listens to all the notes.

import { MIDIVal } from "@midival/core";

MIDIVal.connect()
.then(access => {
const input = new MIDIValInput(access.inputs[0]);
input.onAllNoteOn(event => {
console.log("Note on", event.note, event.velocity);
});
});

Sending Messages to your synth

MIDIVal can also be used to control your synthesiser.

import { MIDIVal } from "@midival/core";

MIDIVal.connect()
.then(access => {
const output = new MIDIValOutput(access.outputs[0]);
output.sendNoteOn(64, 127);
output.sendControlChange(5, 50); // increasing portamento time.
});

MPE Support

MIDIVal can both recieve and send MPE messages

const input = new MPEMidivalInput(new MIDIValInput(input));
input.onLowerZoneUpdate(lowerZone => {
if (!lowerZone) {
console.log("Lower Zone was disabled");
return;
}
lowerZone.onNoteOn(note => {
// React to note being pressed.
})
lowerZone.onNoteOff(note => {
// React to note being depressed
})
lowerZone.onMemberPitchBend(bend => {
// React to note being bent
})
lowerZone.onMemberTimbre(tim => {
// React to notes timbre being changed
})
lowerZone.onMemberPressure(pres => {
// React to notes pressure being changed
})
})

Using MIDIVal with Node and React Native

MIDIVal is compatible with modern browsers, Node.js and React Native. To configure it, simply provide corresponding adapter. The rest of the code stays the same between environments!

// For Node.js
import { MIDIVal } from "@midival/core";
import { NodeMIDIAccess } from "@midival/node";
import * as midi from "midi";

MIDIVal.configureAccessObject(new NodeMIDIAccess(midi));