aboutsummaryrefslogtreecommitdiff
path: root/src/App.js
blob: 8190cb10aac109ba9bf014fd2472e7b5c15beb07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import logo from './logo.svg';
import './App.css';
import { Piano, KeyboardShortcuts, MidiNumbers } from 'react-piano';
import 'react-piano/dist/styles.css';


function App() {
    const firstNote = MidiNumbers.fromNote('c3');
  const lastNote = MidiNumbers.fromNote('f5');
  const keyboardShortcuts = KeyboardShortcuts.create({
    firstNote: firstNote,
    lastNote: lastNote,
    keyboardConfig: KeyboardShortcuts.HOME_ROW,
  });

  return (
    <Piano
      noteRange={{ first: firstNote, last: lastNote }}
      playNote={(midiNumber) => {
        console.log(midiNumber);
        const freq = 880 * (2**((midiNumber - 69)/12));
         fetch('http://10.242.6.228:5000/startfreq/' + freq);
      }}
      stopNote={(midiNumber) => {
        const freq = 880 * (2**((midiNumber - 69)/12));
         fetch('http://10.242.6.228:5000/stopfreq/' + freq);
      }}
      width={1000}
      keyboardShortcuts={keyboardShortcuts}
    />
  );
}

export default App;