Simple monitor for displaying MIDI status for digital pianos.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

40 regels
996 B

  1. import * as React from 'react'
  2. import Keyboard from './components/Keyboard/Keyboard'
  3. import PedalBoard from './components/PedalBoard/PedalBoard'
  4. const search = new URLSearchParams(window.location.search)
  5. const App = () => {
  6. const [startKey, setStartKey, ] = React.useState<number>(Number(search.get('startKey')))
  7. const [endKey, setEndKey, ] = React.useState<number>(Number(search.get('endKey')))
  8. React.useEffect(() => {
  9. const onMessage = (e: MessageEvent) => {
  10. if (e.data.event !== 'spanchange') {
  11. return
  12. }
  13. const [startKey, endKey, ] = e.data.message.split(':')
  14. setStartKey(Number(startKey))
  15. setEndKey(Number(endKey))
  16. }
  17. window.addEventListener('message', onMessage)
  18. return () => {
  19. window.removeEventListener('message', onMessage)
  20. }
  21. }, [])
  22. return (
  23. <React.Fragment>
  24. <Keyboard
  25. startKey={startKey}
  26. endKey={endKey}
  27. />
  28. <PedalBoard />
  29. </React.Fragment>
  30. )
  31. }
  32. export default App;