blob: 3127b5e5d4bfe1792bc89bdcddfc6f41017b5d52 (
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 = 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;
|