diff options
Diffstat (limited to 'src/App.js')
-rw-r--r-- | src/App.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/App.js b/src/App.js new file mode 100644 index 0000000..3127b5e --- /dev/null +++ b/src/App.js @@ -0,0 +1,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 = 440 * 2^(midiNumber - 69)/12; + fetch('http://127.0.0.1:5000/startfreq/' + freq); + }} + stopNote={(midiNumber) => { + const freq = 440 * 2^(midiNumber - 69)/12; + fetch('http://127.0.0.1:5000/stopfreq/' + freq); + }} + width={1000} + keyboardShortcuts={keyboardShortcuts} + /> + ); +} + +export default App; |