npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mpe-kt

v0.0.6

Published

Kotlin implementation of the Midi Polyphonic Expression spec. Use in your Java, Kotlin, and JS projects to parse and generate MPE messages.

Downloads

20

Readme

Kotlin implementation of the Midi Polyphonic Expression spec. Use in your Java, Kotlin, and JS projects to parse and generate MPE messages.

Travis

Example Usage

Parse

 var MpeParser = require('mpe-kt').MpeParser
 var midi = require('midi');
 
 var parser = new MpeParser()
 parser.on("newNote", function (zone, finger) {
   console.log("New note: ", finger.getNote(), finger.getVelocity());
   finger.on("update", function (pitch, pressure, timbre, pitchBend) {
     // track note modulation!
     console.log(finger.getNote(), pitch, pressure, timbre);
   })
 
   finger.on("end", function () {
     console.log("Note removed: ", finger.getNote());
   })
 })
 
 var input = new midi.input();
 // ... configure midi input, see https://www.npmjs.com/package/midi
 input.openPort(0);
 input.on('message', function(deltaTime, message) {
   parser.parse(message);
 });

Generate

 var MpeSender = require('mpe-kt').MpeSender
 var midi = require('midi');
 var output = new midi.output();
 // ... configure midi output, see https://www.npmjs.com/package/midi
 output.openVirtualPort('Virtual Midi Output');
 
 var sender = new MpeSender()
 sender.on("data", function (bytes) {
   // forward midi messages to virtual output
   output.sendMessage(bytes)
 })
 
 var finger = sender.sendNewNote(55, 127)
 // have fun with it
 finger.sendPitchBend(8888)
 finger.sendTimbreChange(122)
 finger.sendPressureChange(50)
 finger.release()

There are two main classes to use:

MpeParser : feed your raw midi bytes, receive MPE-specific callbacks.

  • parse(bytes) : send in raw midi bytes to be parsed.
  • This class acts as an EventEmitter, and will emit the following events:
    • newNote: emits a FingerInput instance (see below) and the id of the MPE zone that it belongs to. This event indicates that a new midi "NoteOn" message has been received by that zone. In other words, a key has been pressed on the MPE instrument.
    • zoneMessage: emits the original midi byte array and the id of the MPE zone that it was sent to. In the future, this will likely be broken out into more specific events (such as zonePitchBend)
    • globalMessage: emits the original midi byte array. In the future, this will likely be broken out into more specific events (such as programChange)

MpeSender : simulates an MPE controller. Use it's simple API, and register a callback to receive the raw midi messages that it generates. These can be piped directly into your MPE instrument.

  • sendNewNote(note, velocity) : play a new note on your simulated controller. This will generate raw midi for a "NoteOn" event and will return a FingerOutput instance (see below), which can be modulated and eventually released.
  • This class acts as an EventEmitter, and will emit the following events:
    • data: emits raw midi data in the form of a byte array that can be sent directly to your MPE instrument.

FingerInput: represents a note being held on an MPE instrument.

  • This class acts as an EventEmitter, and will emit the following events:
    • pitchBend: emits a 7 bit integer representing the new pitch bend for this specific "finger", as well as the current pitch bend range in +/- semitones
    • timbreChange: emits a 7 bit integer representing the new timbre value for this specific "finger".
    • pressureChange: emits a 7 bit integer representing the new pressure value for this specific "finger".
    • update: emits all of the above as a single event, in the order: pitch, pressure, timbre, pitchRange.
    • end: emits nothing; indicates that this "finger" has been released.

FingerOutput: represents a note being held on your simulated MPE controller.

  • sendPitchBend(pitchBend) : generates a midi pitch bend message for this specific "finger". That message will be emitted via the parent MidiSender. The value for pitchBend should be a 14 bit integer (8192 meaning no bend)

  • sendPressureChange(pressure) : generates a pressure change message for this specific "finger". That message will be emitted via the parent MidiSender.
    The value for pressure should be a 7 bit integer

  • sendTimbreChange(timbre) : generates a timbre change message for this specific "finger". That message will be emitted via the parent MidiSender. This is really a midi control change message (CC74), but the MPE spec has given it special meaning. The value for timbre should be a 7 bit integer