-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.js
46 lines (38 loc) · 924 Bytes
/
main.js
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
var midi = require('midi');
output = new midi.output();
var device = 'Teensy';
/* Search the output port */
var ports = output.getPortCount();
for (var i = 0; i < ports; i++) {
name = output.getPortName(i);
if(name.indexOf(device)>-1){
output.openPort(i);
console.log('Opening output '+name);
break;
}
}
pitch = 32;
p1 = 0;
p2 = 0;
shape = 0;
setInterval(
function(){
pitch = pitch + 12;
if(pitch>64) pitch = 32;
output.sendMessage([0x90,pitch,100]);
setTimeout(
function(){
output.sendMessage([0x90,pitch,0]);
//output.sendMessage([0xB0,33,p1]);
//output.sendMessage([0xB0,34,p2]);
},50);
},300);
setInterval(
function(){
shape = Math.floor((Math.random() * 128));
p1 = Math.floor((Math.random() * 128));
p2 = Math.floor((Math.random() * 128));
//output.sendMessage([0xB0,32,shape]);
//output.sendMessage([0xB0,33,p1]);
//output.sendMessage([0xB0,34,p2]);
},3000);