blob: 96e4a7a3092a38a1d7826d96ae555d453fb7c7e8 (
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
<!DOCTYPE html>
<html>
<head>
<title>Refresh MIDI port list test</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"></meta>
</head>
<body>
<script>
var access = null;
async function get_access() {
access = await navigator.requestMIDIAccess({ sysex: true });
}
async function reset_access() {
access = null;
}
async function get_num_ports() {
return access.inputs.size + access.outputs.size;
}
async function add_port() {
let addPortPromise = new Promise(resolve => {
access.addEventListener("statechange", (event) => { dump("***** 1 event.port.name = " + event.port.name + "event.connection = " + event.port.connection + "\n"); if (event.port.connection != "open") { resolve(); } });
});
const outputs = access.outputs.values();
const output = outputs.next().value;
output.send([0x90, 0x01, 0x00]);
await addPortPromise;
}
async function remove_port() {
let removePortPromise = new Promise(resolve => {
access.addEventListener("statechange", (event) => { dump("***** 2 event.port.name = " + event.port.name + "event.connection = " + event.port.connection + "\n"); if (event.port.connection != "open") { resolve(); } });
});
const outputs = access.outputs.values();
const output = outputs.next().value;
output.send([0x90, 0x02, 0x00]);
await removePortPromise;
}
async function force_refresh() {
const outputs = access.outputs.values();
const output = outputs.next().value;
output.send([0x90, 0x04, 0x00]);
}
</script>
</body>
</html>
|