Skip to main content

MPE Output

Connecting to device

To connect to the device, you need to instantiate new MPEMidivalOutput class. In the constructor you can pass sizes of the upper and lower zones.

import { MPEMidivalOutput } from "@midival/core/mpe"

const mpeOutput = new MPEMidivalOutput(output,
{ lowerZoneSize: 7, upperZoneSize: 3 }
)

MIDIVal will send appropriate setup messages and setup mpeOutput.lowerZone and mpeOutput.upperZone properties to allow you to send messages for each of the zones respectively.

Using already existing MIDIValOutput

You can use already existing output by calling initializeMPE method:

const output = new MIDIValOutput(accessOutput);

// other code

output.initializeMpe(7, 3);

The code will have the same effect as the previous example.

Sending notes

To send a note you can, similarly to original MIDIValInput call sendNoteOn message:

const note = mpeOutput.lowerZone.sendNoteOn(64, 120) // value, velocity

Unlike regular MIDIVal call, this one returns note object allowing you to modify note value during it's lifecycle.

Sending note updates

To modify note during it's lifecycle, you can use multiple name conventions. If you communicate with conventional synthesiser, probably using terms like pitch bend, pressure and timbre will be apropriate. But if you wish to use more abstract system, you can use x, y, z system instead.

note.changeBend(-0.2);
note.changeTimbre(20);
note.changePressure(50);

Sending Note Off

Once you decide to end note lifecycle, call .noteOff on the instance:

node.noteOff()

This will send note off on appropriate channel and free the channel for subsequent notes.