Code Monkey home page Code Monkey logo

midi-util's Introduction

midi-util

CommonJS constants for MIDI status types and some basic helper functions (mtof, ftom)

Install

npm i @lokua/midi-util --save

API

NOTE_OFF = 128
NOTE_ON = 144
POLYPHONIC_AFTERTOUCH = 160
CONTROL_CHANGE = 176
PROGRAM_CHANGE = 192
CHANNEL_AFTERTOUCH = 208
PITCHBEND = 224
SYSEX = 240
TIME_CODE = 241
SONG_POSITION = 242
SONG_SELECT = 243
TUNE_REQUEST = 246
END_OF_SYSEX = 247
CLOCK = 248
START = 250
CONTINUE = 251
STOP = 252
ACTIVE_SENSING = 254
SYSTEM_RESET = 255

lookup readable status string by status code or vis a versa

// status -> type
128 -> 'noteOff'
// etc...

// type -> status
'noteOff' -> 128
// ...

// screaming type -> status
'NOTE_OFF' -> 128
// ...

Check if a status byte or MIDI message is a certain status type

  • isNoteOff
  • isNoteOn
  • isPolyphonicAftertouch
  • isControlChange
  • isProgramChange
  • isChannelAftertouch
  • isPitchBend
  • isSysex
  • isSongPosition
  • isSongSelect
  • isTuneRequest
  • isEndOfSysex
  • isClock
  • isStart
  • isContinue
  • isStop
  • isActiveSensing
  • isSystemReset

Convert MIDI note number to frequency

Convert frequency to MIDI note number

Given a midi message status, returns the corresponding MIDI channel.

Returns the message type (ie. noteOn, controlChange) for a given status

Browser only. Converts the MIDIPortMap objects returned by navigator.requestMIDIAccess into a hash of inputs and outputs arrays.

Find a port instance within an array of ports or a Map<any, { name: string }> structure by exact string or RegExp. (Actually, this is really a generic findObjectByName that works with arrays or maps, but, whatever).

Hint - use the i flag when using RegExp to make matching easier on yourself

This method also supports partial application so you can do the following:

const { getPorts, findPortByName } = require('@lokua/midi-util')

// this
const findMidiFighterTwister = findPortByName(/fighter\/twister/i)

const { inputs, outputs } = await getPorts()
const input = findMidiFighterTwister(inputs)
const output = findMidiFighterTwister(outputs)

License

MIT

midi-util's People

Contributors

lokua avatar

Stargazers

 avatar

Watchers

James Cloos 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.