move osc code to separate file
This commit is contained in:
parent
e65f266aca
commit
9d11b5ba89
@ -9,6 +9,8 @@
|
|||||||
<script type="text/javascript" src="scripts/surface.js"></script>
|
<script type="text/javascript" src="scripts/surface.js"></script>
|
||||||
<script type="text/javascript" src="scripts/lisp.js"></script>
|
<script type="text/javascript" src="scripts/lisp.js"></script>
|
||||||
<script type="text/javascript" src="scripts/library.js"></script>
|
<script type="text/javascript" src="scripts/library.js"></script>
|
||||||
|
<script type="text/javascript" src="scripts/osc.js"></script>
|
||||||
|
|
||||||
<link rel="stylesheet" type="text/css" href="links/reset.css"/>
|
<link rel="stylesheet" type="text/css" href="links/reset.css"/>
|
||||||
<link rel="stylesheet" type="text/css" href="links/fonts.css"/>
|
<link rel="stylesheet" type="text/css" href="links/fonts.css"/>
|
||||||
<link rel="stylesheet" type="text/css" href="links/main.css"/>
|
<link rel="stylesheet" type="text/css" href="links/main.css"/>
|
||||||
|
27
desktop/sources/scripts/osc.js
Normal file
27
desktop/sources/scripts/osc.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
'use strict'
|
||||||
|
|
||||||
|
function Osc (ronin) {
|
||||||
|
const osc = require('osc')
|
||||||
|
|
||||||
|
this.oscMsg = {}
|
||||||
|
|
||||||
|
this.start = function () {
|
||||||
|
var udpPort = new osc.UDPPort({
|
||||||
|
localAddress: "0.0.0.0",
|
||||||
|
localPort: 12940,
|
||||||
|
metadata: true
|
||||||
|
});
|
||||||
|
|
||||||
|
udpPort.on("message", this.onOscMsg)
|
||||||
|
|
||||||
|
udpPort.open();
|
||||||
|
this.ronin.log("osc started")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.onOscMsg = (oscMsg, timeTag, info) => {
|
||||||
|
this.oscMsg = oscMsg;
|
||||||
|
this.ronin.log("An OSC message just arrived!", oscMsg)
|
||||||
|
this.ronin.log("Remote info is: ", info);
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,3 @@
|
|||||||
const osc = require('osc')
|
|
||||||
|
|
||||||
function Ronin () {
|
function Ronin () {
|
||||||
const defaultTheme = {
|
const defaultTheme = {
|
||||||
background: '#111',
|
background: '#111',
|
||||||
@ -21,6 +19,7 @@ function Ronin () {
|
|||||||
this.commander = new Commander(this)
|
this.commander = new Commander(this)
|
||||||
this.surface = new Surface(this)
|
this.surface = new Surface(this)
|
||||||
this.library = new Library(this)
|
this.library = new Library(this)
|
||||||
|
this.osc = new Osc(this)
|
||||||
|
|
||||||
this.oscMsg = {}
|
this.oscMsg = {}
|
||||||
// Parameters
|
// Parameters
|
||||||
@ -46,29 +45,11 @@ function Ronin () {
|
|||||||
this.source.start()
|
this.source.start()
|
||||||
this.commander.start()
|
this.commander.start()
|
||||||
this.surface.start()
|
this.surface.start()
|
||||||
|
this.osc.start()
|
||||||
var udpPort = new osc.UDPPort({
|
|
||||||
localAddress: "0.0.0.0",
|
|
||||||
localPort: 57121,
|
|
||||||
metadata: true
|
|
||||||
});
|
|
||||||
|
|
||||||
udpPort.on("message", this.onOscMsg)
|
|
||||||
|
|
||||||
udpPort.open();
|
|
||||||
this.log("started")
|
|
||||||
|
|
||||||
console.log('Ronin', 'Started')
|
|
||||||
}
|
|
||||||
|
|
||||||
this.onOscMsg = (oscMsg, timeTag, info) => {
|
|
||||||
this.oscMsg = oscMsg;
|
|
||||||
console.log("An OSC message just arrived!", oscMsg)
|
|
||||||
this.log("Remote info is: ", info);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.getOsc = function() {
|
this.getOsc = function() {
|
||||||
return this.oscMsg;
|
return this.osc.oscMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.reset = function () {
|
this.reset = function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user