import * as React from 'react' import ReactDOM from 'react-dom' import Keyboard, { KeyboardMap } from '../src' import * as Channel from './controllers/Channel' import * as Instrument from './controllers/Instrument' import * as Generator from './controllers/Generator' import keyboardMapping from './services/keyboardMapping' import SoundGenerator from './services/SoundGenerator' const App = () => { const [channel, setChannel] = React.useState(0) const [keyChannels, setKeyChannels] = React.useState<{ key: number; velocity: number; channel: number }[]>([]) const [instruments, setInstruments, ] = React.useState([]) const [instrument, setInstrument] = React.useState(0) const generator = React.useRef(undefined) const scrollRef = React.useRef(null) React.useEffect(() => { if (!generator.current) { return } Instrument.reflect({ generator: generator.current, channel, instrument }) }, [channel, instrument]) React.useEffect(() => { Generator .load() .then(g => { Instrument.initialize({ setInstruments, generator: generator.current = g, }) }) }, []) React.useEffect(() => { const { current } = scrollRef if (current) { current.scrollLeft = current.scrollWidth * 0.4668 } }, [scrollRef]) return (
) } const container = window.document.createElement('div') container.style.display = 'contents' window.document.body.appendChild(container) ReactDOM.render(, container)