This repository was archived by the owner on Oct 27, 2024. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathapp.js
More file actions
153 lines (142 loc) · 3.64 KB
/
Copy pathapp.js
File metadata and controls
153 lines (142 loc) · 3.64 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
const fs = require('fs');
const key = fs.readFileSync('./key.pem');
const cert = fs.readFileSync('./cert.pem');
const express = require('express');
const https = require('https'); // https required
const app = express();
const server = https.createServer({key: key, cert: cert }, app);
var io = require('socket.io')(server);
var osc = require('osc-min'),
dgram = require('dgram'),
remote;
////////////////////////////////////////////////////////////////////////
server.listen(8000);
console.log("SERVER LISTENING ON port 8000");
console.log("\n ------ \n sending osc on 3333\n");
app.use('/scripts', express.static(__dirname + '/node_modules/'));
app.use(express.static(__dirname + '/public'));
app.get('/', function(req, res,next) {
res.sendFile(__dirname + '/public/index.html');
});
app.use(express.static('public'));
////////////////////////////////////////////////////////
var udp = dgram.createSocket('udp4', function(msg, rinfo) {
console.log("msg : " + msg +"Remote : " + rinfo);
});
/////IO CLIENT MSGs
io.on('connection', function (socket){
console.log("user "+socket.id + " connected");
socket.on('kickVol',function(data){
var kickVol = osc.toBuffer({
oscType: 'message',
address: '/kick/vol',
args: [{
type: 'float',
value: data
}]
});
udp.send(kickVol, 0 , kickVol.length, 3333, "localhost");
});
socket.on('hatsVol',function(data){
var hatsVol = osc.toBuffer({
oscType: 'message',
address: '/hats/vol',
args: [{
type: 'float',
value: data
}]
});
udp.send(hatsVol, 0 , hatsVol.length, 3333, "localhost");
});
socket.on('seqVol',function(data){
var seqVol = osc.toBuffer({
oscType: 'message',
address: '/seq/vol',
args: [{
type: 'float',
value: data
}]
});
udp.send(seqVol, 0 , seqVol.length, 3333, "localhost");
});
socket.on('micVol',function(data){
var micVol = osc.toBuffer({
oscType: 'message',
address: '/mic/vol',
args: [{
type: 'float',
value: data
}]
});
udp.send(micVol, 0 , micVol.length, 3333, "localhost");
});
socket.on('seqNotes',function(data){
var seqSldVal = parseFloat(data.value);
var seqIndex = data.index + 1;
var seqOscMsg = "/s" + seqIndex;
var seqNotes = osc.toBuffer({
oscType: 'message',
address: seqOscMsg.toString(),
args: [{
type: 'float',
value: seqSldVal
}]
});
udp.send(seqNotes, 0 , seqNotes.length, 3333, "localhost");
});
socket.on('seqGate',function(data){
var micVol = osc.toBuffer({
oscType: 'message',
address: '/seqGate',
args: [{
type: 'float',
value: data
}]
});
udp.send(micVol, 0 , micVol.length, 3333, "localhost");
});
socket.on('seqFLT',function(data){
var seqFLT = osc.toBuffer({
oscType: 'message',
address: '/seq/flt',
args: [{
type: 'float',
value: data
}]
});
udp.send(seqFLT, 0 , seqFLT.length, 3333, "localhost");
});
socket.on('atRel',function(data){
var atRel = osc.toBuffer({
oscType: 'message',
address: '/seq/atRel',
args: [{
type: 'float',
value: data
}]
});
udp.send(atRel, 0 , atRel.length, 3333, "localhost");
});
socket.on('micDel',function(data){
var micDel = osc.toBuffer({
oscType: 'message',
address: '/micDel',
args: [{
type: 'float',
value: data
}]
});
udp.send(micDel, 0 , micDel.length, 3333, "localhost");
});
socket.on('masDel',function(data){
var masDel = osc.toBuffer({
oscType: 'message',
address: '/masDel',
args: [{
type: 'float',
value: data
}]
});
udp.send(masDel, 0 , masDel.length, 3333, "localhost");
});
});