-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMIDI-API-TEST.php
99 lines (82 loc) · 3.57 KB
/
MIDI-API-TEST.php
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
/**
* Created by PhpStorm.
* User: DZ
* Date: 4/8/2019
* Time: 6:54 PM
*/
$SERVER_HTTP_PATH = '/DZ1/'; /* <?php echo $SERVER_HTTP_PATH; ?> */
$HTTP_PROTOCOL = 'http'; /* <?php echo $HTTP_PROTOCOL; ?> */
$VERSION_CONTROL = '1.0.0.01'; /* <?php echo $VERSION_CONTROL; ?> */
?>
<!DOCTYPE html>
<html lang='en'>
<head>
<title>MIDIMACHTA</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- JQUERY MOBILE
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jquerymobile/1.4.3/jquery.mobile.min.css" />
<script src="//ajax.googleapis.com/ajax/libs/jquerymobile/1.4.3/jquery.mobile.min.js"></script>
-->
<!-- JQUERY UI -->
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
<!-- FONTS Source Sans Pro - Open Sans
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400|Open+Sans:400,300' rel='stylesheet' type='text/css'>
-->
</head>
<body>
<input type="button" value="REQUEST MIDI ACCESS" onclick="bootMIDI()" />
<script type="text/javascript">
function bootMIDI(){
if(navigator.requestMIDIAccess){
alert("MIDI SUPPORT AVAILABLE");
}else{
alert("MIDI SUPPORT NOT AVAILABLE");
}
window.navigator.requestMIDIAccess()
.then(onMIDISuccess, onMIDIFailure);
}
var MTEST;
function onMIDISuccess(midiAccess){
console.log(midiAccess);
console.log(midiAccess.inputs.values());
//var inputs = midiAccess.inputs;
//var outputs = midiAccess.outputs;
MTEST = midiAccess;
for (var input of midiAccess.inputs.values()){
console.log("ITERATOR SEQ");
console.log(input);
input.onmidimessage = getMIDIMessage;
}
}
function getMIDIMessage(midiMessage){
//console.log(midiMessage);
if(midiMessage.data.length == 3){
$('#log').append("<p style='margin:0;padding:0;font-family:arial;'>(<span style='color:red;'>"+midiMessage.data[0]+"</span>, <span style='color:green;'>"+midiMessage.data[1]+"</span>, <span style='color:blue;'>"+midiMessage.data[2]+"</span>)</p>");
}
}
function onMIDIFailure(){
alert("UNABLE TO ACCESS MIDI DEVICE(S).");
}
function startMIDIAccess(){
window.navigator.requestMIDIAccess()
.then(function(access){
console.log(access);
// lists of available MIDI controllers
const inputs = access.input.values();
const outputs = access.outputs.values();
access.onstatechange = function(e){
//print info about (dis)connected MIDI controller
console.log(e.port.name, e.port.manufacturer, e.port.state);
}
})
}
$(document).ready(function(){
//bootMIDI();
});
</script>
<div id="log">
</div>
</body>
</html>