Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/krmax44/midy
A super-minimalistic MIDI library.
https://github.com/krmax44/midy
midi web-midi
Last synced: about 2 months ago
JSON representation
A super-minimalistic MIDI library.
- Host: GitHub
- URL: https://github.com/krmax44/midy
- Owner: krmax44
- License: mit
- Created: 2020-02-25T18:21:14.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-09-12T12:04:11.000Z (over 4 years ago)
- Last Synced: 2024-09-30T08:36:21.760Z (3 months ago)
- Topics: midi, web-midi
- Language: TypeScript
- Size: 160 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Midy
[![GitHub CI Status](https://img.shields.io/github/workflow/status/krmax44/midy/build/master)](https://github.com/krmax44/midy/actions?query=workflow%3Abuild)
[![Code Coverage](https://img.shields.io/codecov/c/github/krmax44/midy)](https://codecov.io/gh/krmax44/midy)
[![bundle size](https://img.shields.io/bundlephobia/minzip/midy)](https://bundlephobia.com/result?p=midy)
[![npm version](https://img.shields.io/npm/v/midy)](https://www.npmjs.com/package/midy)A super-minimalistic MIDI library.
## Installation
```bash
yarn add midy
# or using npm
npm i midy
```## Example
```js
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` |
| `on` | event name `string`, listener `function` | Register an event listener. See [Houk API](https://github.com/krmax44/houk/#api) | `void` |
| `off` | event name `string`, listener `function` | Unregister an event listener. See [Houk API](https://github.com/krmax44/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'` |