blob: 808506e945cc45cfc95e8d475e296c8fabff461f (
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('a2');
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://dubdub.mit.edu:5000/startfreq/' + freq);
}}
stopNote={(midiNumber) => {
const freq = 880 * (2**((midiNumber - 69)/12));
fetch('http://dubdub.mit.edu:5000/stopfreq/' + freq);
}}
width={1000}
keyboardShortcuts={keyboardShortcuts}
/>
);
}
export default App;
|