MidiDeviceProvider
Installation
yarn add react-midi-device-provider
or npm i -P react-midi-device-provider
Usage
Wrap all/part of your application in <MidiDeviceProvider />
.
;; const appElement = document;;
Then... expose midi
, setMidiInput
, and setMidiOutput
to your components using withMidi(Component)
;
Examples:
MidiDeviceSwitcher
;;; { super; thishandleInputChange = thishandleInputChange; thishandleOutputChange = thishandleOutputChange; } static propTypes = midi: PropTypesobject setMidiInput: PropTypesfunc setMidiOutput: PropTypesfunc { const setMidiInput = thisprops; ; } { const setMidiOutput = thisprops; ; } { const inputs outputs selectedInput selectedOutput } = thispropsmidi; return <div> <div> <h3>Inputs</h3> <select onChange=thishandleInputChange> inputs </select> <span>selectedInput && ` - `</span> </div> <div> <h3>Outputs</h3> <select onChange=thishandleOutputChange> outputs </select> <span>selectedOutput && ` - `</span> </div> </div> ; } MidiDeviceSwitcher;
MidiParamSlider
;;; { super; thishandleChange = thishandleChange; } static propTypes = channel: PropTypesnumber max: PropTypesnumber min: PropTypesnumber midi: PropTypesobjectisRequired static defaultProps = channel: 0x10 max: 127 min: 0 { const channel midi = thisprops; const selectedOutput = midi; if selectedOutput && typeof selectedOutputsend === 'function' selectedOutput; } { const max min = thisprops; return <div> <input type="range" max=max min=min onChange=thishandleChange /> </div> ; } MidiParamSlider;