Created
October 11, 2015 21:03
-
-
Save lukewestby/248bf991cd9259df021b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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