Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mkaradeniz/use-midi

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mkaradeniz/use-midi

React Hook for the 'Web MIDI API'.

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

useMidi

useMidi is a low-level custom React Hook to access the Web MIDI API. It provides access to incoming MIDIMessageEvents and helpers to request and observe the user's permission.

Installation

yarn add @mkaradeniz/use-midi

or

npm install @mkaradeniz/use-midi

Demo

Usage

const [midiMessages, { isSupported, isRequested, isAllowed }, requestMidiAccess, midiAccess] = useMidi()

API

Input

TypeDefault
Options{ automaticallyRequestPermission: false, debug: false, suppressActiveSensing: true, sysex: false }
MidiMessage
PropertyTypeDescription
commandCodenumberRecieved command code.
note`numberundefined`
timestampDOMHighResTimeStampHigh-resolution time of when the event was received.
rawEventWebMidi.MIDIMessageEventThe raw WebMidi.MIDIMessageEvent.
velocity`numberundefined`
Options
OptionTypeDescriptionDefault
automaticallyRequestPermissionbooleanIf set to true, useMidi will automatically ask for the user's permission to access the MIDI devices, instead of waiting for the consumer to call requestAccess.false
callback(midiMessage: MidiMessage) => voidIf provided, the callback will be called on every received MidiMessage.undefined
messagesHistoryCountnumbermidiMessages will always contain the last messagesHistoryCount elements.256
debugbooleanIf set to true, useMidi will log every event to the console.false
suppressActiveSensingbooleanIf set to true, useMidi will ignore the Active Sensing event.true
sysexbooleanIf set to true, useMidi use the sysex option when requesting MIDI access.false

Returns

IndexVariableTypeDescriptionDefault
0midiMessagesMidiMessage[]An array of all MidiMessages, from oldest (index 0) to newest.[]
1statusStatusObject with all statuses.{isAllowed: false, isRequested: False, isSupported: false}
2requestAccess() => voidFunction to request the user's permission to access MIDI devices.() => void
3midiAccessMIDIAccessThe MIDIAccess interface.undefined
Status
StatusTypeDescriptionDefault
isAllowedbooleanWhether the user gave permission to access MIDI devices.false
isRequestedbooleanWhether we requested the user to grant permission to access MIDI devices.false
isSupportedbooleanWhether the Web MIDI API is supported by the browser.false

Development

This project is written in TypeScript and setup as a monorepo managed by Yarn-Workspaces & Lerna.

⚠️ Only release through yarn release in root. Do not npm publish individual packages.

Keywords

FAQs

Package last updated on 22 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc