Skip to content

Instantly share code, notes, and snippets.

@lukewestby
Created October 11, 2015 21:03
Show Gist options
  • Save lukewestby/248bf991cd9259df021b to your computer and use it in GitHub Desktop.
Save lukewestby/248bf991cd9259df021b to your computer and use it in GitHub Desktop.
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 }
});
}
const notes = noteStates.map(({ note, velocity, command }) => (
<MidiNote key={note}
note={note}
channel={channel}
velocity={velocity}
command={command}
onMessage={patial(onMessage, note)}>
</MidiNote>
));
return (
<MidiDevice input={input} output={output}>
{notes}
</MidiDevice>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment