# midy

> A super-minimalistic MIDI library.

Latest version **1.2.0** (published 2020-09-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install midy
pnpm add midy
yarn add midy
bun add midy
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2020-09-12 |
| First published | 2020-02-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 7.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | krmax44 |
| Maintainers | krmax44 |
| Keywords | midi, web midi |

## Links

- npm: https://www.npmjs.com/package/midy
- Repository: https://github.com/krmax44/midy
- npm.io page: https://npm.io/package/midy

## Dependencies (2)

- [houk](https://npm.io/package/houk.md) ^3.0.2
- [@types/webmidi](https://npm.io/package/@types/webmidi.md) ^2.0.4

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.2.0 (latest) — 2020-09-12
- 1.1.0 — 2020-08-27
- 1.0.1 — 2020-02-25
- 1.0.0 — 2020-02-25

## 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<boolean>` |
| `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'` |

---
_Source: https://npm.io/package/midy · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
