Skip to content

Instantly share code, notes, and snippets.

View lukewestby's full-sized avatar

Luke Westby lukewestby

View GitHub Profile
import React from 'react';
import { MidiNote, MidiDevice } from 'hypothetical-react-midi';
import partial from 'lodash.partial';
export default function App({ input, output, noteStates, dispatch }) {
function onMessage(note, { command, velocity }) {
dispatch({
type: 'MESSAGE_RECIEVED',
payload: { command, velocity, note }
import React from 'react';
import { MidiDevice } from 'hypothetical-react-midi';
import { render } from 'react-dom';
function App({ input, output }) {
return (
<MidiDevice input={input} output={output}>
// ...
</MidiDevice>
);
@lukewestby
lukewestby / findMidiDevices.js
Created October 11, 2015 20:40
Get MIDI input and output devices from the Web MIDI API by name
function findMidiDevices(name) {
return navigator
.requestMIDIAccess()
.then((midiAccess) => {
let input, output;
midiAccess.inputs.forEach((currentInput) => {
if(currentInput.name === name) input = currentInput;
});
midiAccess.outputs.forEach((currentOutput) => {
if(currentOutput.name === name) output = currentOutput;