adding event triggering with artnet support

This commit is contained in:
Fabian Stamm 2017-06-18 16:14:01 +02:00
parent 3ad9a89768
commit 880636a183
7 changed files with 31 additions and 54 deletions

25
db.json
View File

@ -1,32 +1,9 @@
{ {
"t2mp4": [
{
"id": "f786c17431e6",
"time": "1500",
"channel": "1",
"note": "2",
"name": "test",
"value": "5"
}
],
"3d47edcdc882": { "3d47edcdc882": {
"displayName": "test", "displayName": "test",
"id": "3d47edcdc882", "id": "3d47edcdc882",
"triggers": [ "triggers": [
{
"midi": {
"channel": 1,
"note": 3,
"value": 4
},
"time": {
"lframe": 15,
"lseconds": 5,
"lminutes": 0,
"lhours": 0,
"lmilliseconds": 5600
}
}
] ]
} }
} }

View File

@ -13,8 +13,8 @@ var ioClient = require("socket.io-client")("http://localhost:5000");
var ios = io(http); var ios = io(http);
const rtpmidi = require("rtpmidi"); const rtpmidi = require("rtpmidi");
var midisession = rtpmidi.manager.createSession({ var midisession = rtpmidi.manager.createSession({
localName: "Node Timecode", localName: "node",
bonjourName: "Node Timecode", bonjourName: "node",
port: 5004 port: 5004
}); });
class FrameTime { class FrameTime {
@ -194,4 +194,8 @@ midisession.on("ready", () => {
//midisession.sendMessage([1, 5, 100]); //midisession.sendMessage([1, 5, 100]);
}, 500); }, 500);
}); });
midisession.on('message', function (deltaTime, message) {
console.log('Received a message', message);
});
midisession.connect({ address: "dmx.event.margau.net", port: 5004 });
//# sourceMappingURL=timec.js.map //# sourceMappingURL=timec.js.map

File diff suppressed because one or more lines are too long

14
package-lock.json generated
View File

@ -6,17 +6,20 @@
"@types/node": { "@types/node": {
"version": "7.0.31", "version": "7.0.31",
"resolved": "https://registry.npmjs.org/@types/node/-/node-7.0.31.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-7.0.31.tgz",
"integrity": "sha512-+KrE1LDddn97ip+gXZAnzNQ0pupKH/6tcKwTpo96BDVNpzmhIKGHug0Wd3H0dN4WEqYB1tXYI5m2mZuIZNI8tg==" "integrity": "sha512-+KrE1LDddn97ip+gXZAnzNQ0pupKH/6tcKwTpo96BDVNpzmhIKGHug0Wd3H0dN4WEqYB1tXYI5m2mZuIZNI8tg==",
"dev": true
}, },
"@types/socket.io": { "@types/socket.io": {
"version": "1.4.29", "version": "1.4.29",
"resolved": "https://registry.npmjs.org/@types/socket.io/-/socket.io-1.4.29.tgz", "resolved": "https://registry.npmjs.org/@types/socket.io/-/socket.io-1.4.29.tgz",
"integrity": "sha1-hqazqat4z5qQDO74W5totr6oZxI=" "integrity": "sha1-hqazqat4z5qQDO74W5totr6oZxI=",
"dev": true
}, },
"@types/socket.io-client": { "@types/socket.io-client": {
"version": "1.4.29", "version": "1.4.29",
"resolved": "https://registry.npmjs.org/@types/socket.io-client/-/socket.io-client-1.4.29.tgz", "resolved": "https://registry.npmjs.org/@types/socket.io-client/-/socket.io-client-1.4.29.tgz",
"integrity": "sha1-+HQwcM7pMXXjbgtqd6ivc+WMyzI=" "integrity": "sha1-+HQwcM7pMXXjbgtqd6ivc+WMyzI=",
"dev": true
}, },
"accepts": { "accepts": {
"version": "1.3.3", "version": "1.3.3",
@ -33,6 +36,11 @@
"resolved": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.6.tgz", "resolved": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.6.tgz",
"integrity": "sha1-8zshWfBTKj8xB6JywMz70a0peco=" "integrity": "sha1-8zshWfBTKj8xB6JywMz70a0peco="
}, },
"artnet": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/artnet/-/artnet-1.3.2.tgz",
"integrity": "sha1-ox3XjJoo6rnEa2932cxoyk5nChg="
},
"assertion-error": { "assertion-error": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.0.0.tgz", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.0.0.tgz",

View File

@ -26,6 +26,7 @@
}, },
"homepage": "https://github.com/margau/node_vlc_rc#readme", "homepage": "https://github.com/margau/node_vlc_rc#readme",
"dependencies": { "dependencies": {
"artnet": "^1.3.2",
"lowdb": "^0.16.2", "lowdb": "^0.16.2",
"rtpmidi": "^0.1.8", "rtpmidi": "^0.1.8",
"short-id": "0.1.0-1", "short-id": "0.1.0-1",

View File

@ -13,12 +13,9 @@ import io = require("socket.io");
var ioClient = require("socket.io-client")("http://localhost:5000"); var ioClient = require("socket.io-client")("http://localhost:5000");
var ios = io(http); var ios = io(http);
import rtpmidi = require("rtpmidi"); const artnetp = require("artnet");
var midisession = rtpmidi.manager.createSession({ const universe = 21;
localName:"Node Timecode", var artnet = artnetp({host:"192.168.1.255"});
bonjourName:"Node Timecode",
port: 5004
});
class FrameTime{ class FrameTime{
lframe = 0; lframe = 0;
@ -118,8 +115,8 @@ class Timecode {
var d = new Date().getTime() - this.startTime; var d = new Date().getTime() - this.startTime;
this.toTrigger.forEach(e=>{ this.toTrigger.forEach(e=>{
if(e.time.milliseconds <= d) { if(e.time.milliseconds <= d) {
ios.emit("midi", e.midi); ios.emit("artnet", e.art);
midisession.sendMessage([e.midi.channel, e.midi.note, e.midi.value]); artnet.set(universe, e.art.subnet)
var i = this.toTrigger.indexOf(e); var i = this.toTrigger.indexOf(e);
this.toTrigger.splice(i, 1); this.toTrigger.splice(i, 1);
} }
@ -167,9 +164,8 @@ class Timecode {
} }
class TrackEvent { class TrackEvent {
midi: { art: {
channel:number, subnet:number,
note:number,
value:number value:number
} }
time:FrameTime; time:FrameTime;
@ -219,10 +215,9 @@ ios.on("connection", socket=>{
}); });
socket.on("set", (data)=>{ socket.on("set", (data)=>{
var tid = data.track; var tid = data.track;
var midi = data.midi;
var time = new FrameTime(data.time); var time = new FrameTime(data.time);
var tracke = new TrackEvent(); var tracke = new TrackEvent();
tracke.midi = midi; tracke.art = data.art;
tracke.time = time; tracke.time = time;
db.get(tid + ".triggers").push(tracke).write(); db.get(tid + ".triggers").push(tracke).write();
socket.emit("set_finished", tracke); socket.emit("set_finished", tracke);
@ -233,11 +228,4 @@ ios.on("connection", socket=>{
}); });
}); });
midisession.on("ready", ()=>{
http.listen(5001); http.listen(5001);
setInterval(()=>{
midisession.sendMessage([0x80, 0x40]);
midisession.sendMessage([0x90, 0x40, 0x7f]);
//midisession.sendMessage([1, 5, 100]);
}, 500);
});

View File

@ -1,8 +1,7 @@
{ {
"track": "3d47edcdc882", "track": "3d47edcdc882",
"midi":{ "art":{
"channel":1, "subnet":1,
"note":3,
"value":4 "value":4
}, "time": { }, "time": {
"hours":0, "hours":0,