midy
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

Midy

GitHub CI Status Code Coverage bundle size npm version

A super-minimalistic MIDI library.

Installation

yarn add midy
# or using npm 
npm i midy

Example

import Midy from 'midy';
 
const midy = new Midy();
if (await midy.requestAccess()) {
    midy.on('noteDown', (note, channel, velocity) => {
        console.log('A key was pressed!', note, channel, velocity);
    });
}

Methods

Method name Parameters Description Type
requestAccess none Request access to the Web MIDI API. Promise<boolean>
on event name string, listener function Register an event listener. See Houk API void
off event name string, listener function Unregister an event listener. See Houk API boolean

Events

Event name Description Parameters
noteUp Triggered once a key is released. MIDI note number, MIDI channel number, velocity number
noteDown Triggered once a key is pressed. MIDI note number, MIDI channel number, velocity number
midiMessage Raw MIDI events. MIDI event MIDIMessageEvent

Properties

Property name Description Type
access MIDI access MIDIAccess
inputs MIDI inputs MIDIInputMap
outputs MIDI outputs MIDIOutputMap
state Access state 'none' | 'pending' | 'granted' | 'denied'

Readme

Keywords

Package Sidebar

Install

npm i midy

Weekly Downloads

2

Version

1.2.0

License

MIT

Unpacked Size

7.27 kB

Total Files

7

Last publish

Collaborators

  • krmax44