Giter Site home page Giter Site logo

webmidi-mapper's Introduction

Web Midi Mapper

An expansion to the original webmidi package to map devices in a simple way

npm node dependencies

Functionalities

  • Provides an extension to the original Web Midi package
  • Maps devices to easy to remember functions

Setup

Install the Midi Mapper package:

npm install webmidi-mapper

Import the Midi Mapper package somewhere in your code:

import {init as initWebmidi, onFaderChange, onButtonPress, onRotaryEncoderChange, onDrumPad, debugMidi, midiMaps} from 'webmidi-mapper';

Usage

Start by initializing the Midi Mapper by running the init function (this needs to be executed first before running other functions)

initWebmidi("korg-nanokontrol2", (deviceReady) => {
    console.log(deviceReady);
});

If your device isn't number 0 in the array than please adjust this like so:

initWebmidi("korg-nanokontrol2", (deviceReady) => {
    console.log(deviceReady);
}, 1);

Now you can start by assigning faders, rotary encoders and buttons:

To assign a fader:

onFaderChange("1", (value) => {
    console.log(value);
});

To assign a rotary encoder:

onRotaryEncoderChange("1", (value) => {
    console.log(value);
});

To assign a button:

onButtonPress("play", () => {
    console.log("Midi play button pressed!");
});

To assign a drumpad:

onDrumPad("1", () => {
    console.log("Midi drumpad pressed!");
});

If you want the RAW midi value instead of the 0 to 1 value:

onFaderChange("1", (value) => {
    console.log(value);
}, true);

onRotaryEncoderChange("1", (value) => {
    console.log(value);
}, true);

If you want the button function to respond on both on and off value's:

onButtonPress("play", () => {
    console.log("Midi play button pressed!");
}, true);

Create your own mapping

To create a new map start by copying an existing map from the maps folder. Then import and export your map in the maps.js.

To see on what note a button is use our debug function:

debugMidi((note, value, mapKey) => {
    console.log('note', note);
    console.log('value', value);
    console.log('mapKey', mapKey);
});

Then press a button, turn a knob or turn up a fader and see the result.

Maps

To see all the maps in the mapper:

console.log("Maps: ", midiMaps());

Contribute

When your map is complete please create a pull request or open an issue with your map attached. This so others can also start using that map.

License

MIT

webmidi-mapper's People

Contributors

dependabot-support avatar glenndehaan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.