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": {
"displayName": "test",
"id": "3d47edcdc882",
"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);
const rtpmidi = require("rtpmidi");
var midisession = rtpmidi.manager.createSession({
localName: "Node Timecode",
bonjourName: "Node Timecode",
localName: "node",
bonjourName: "node",
port: 5004
});
class FrameTime {
@ -194,4 +194,8 @@ midisession.on("ready", () => {
//midisession.sendMessage([1, 5, 100]);
}, 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

File diff suppressed because one or more lines are too long

14
package-lock.json generated
View File

@ -6,17 +6,20 @@
"@types/node": {
"version": "7.0.31",
"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": {
"version": "1.4.29",
"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": {
"version": "1.4.29",
"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": {
"version": "1.3.3",
@ -33,6 +36,11 @@
"resolved": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.6.tgz",
"integrity": "sha1-8zshWfBTKj8xB6JywMz70a0peco="
},
"artnet": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/artnet/-/artnet-1.3.2.tgz",
"integrity": "sha1-ox3XjJoo6rnEa2932cxoyk5nChg="
},
"assertion-error": {
"version": "1.0.0",
"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",
"dependencies": {
"artnet": "^1.3.2",
"lowdb": "^0.16.2",
"rtpmidi": "^0.1.8",
"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 ios = io(http);
import rtpmidi = require("rtpmidi");
var midisession = rtpmidi.manager.createSession({
localName:"Node Timecode",
bonjourName:"Node Timecode",
port: 5004
});
const artnetp = require("artnet");
const universe = 21;
var artnet = artnetp({host:"192.168.1.255"});
class FrameTime{
lframe = 0;
@ -118,8 +115,8 @@ class Timecode {
var d = new Date().getTime() - this.startTime;
this.toTrigger.forEach(e=>{
if(e.time.milliseconds <= d) {
ios.emit("midi", e.midi);
midisession.sendMessage([e.midi.channel, e.midi.note, e.midi.value]);
ios.emit("artnet", e.art);
artnet.set(universe, e.art.subnet)
var i = this.toTrigger.indexOf(e);
this.toTrigger.splice(i, 1);
}
@ -167,9 +164,8 @@ class Timecode {
}
class TrackEvent {
midi: {
channel:number,
note:number,
art: {
subnet:number,
value:number
}
time:FrameTime;
@ -219,10 +215,9 @@ ios.on("connection", socket=>{
});
socket.on("set", (data)=>{
var tid = data.track;
var midi = data.midi;
var time = new FrameTime(data.time);
var tracke = new TrackEvent();
tracke.midi = midi;
tracke.art = data.art;
tracke.time = time;
db.get(tid + ".triggers").push(tracke).write();
socket.emit("set_finished", tracke);
@ -233,11 +228,4 @@ ios.on("connection", socket=>{
});
});
midisession.on("ready", ()=>{
http.listen(5001);
setInterval(()=>{
midisession.sendMessage([0x80, 0x40]);
midisession.sendMessage([0x90, 0x40, 0x7f]);
//midisession.sendMessage([1, 5, 100]);
}, 500);
});
http.listen(5001);

View File

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