commit
55f160c5b5
@ -97,6 +97,7 @@ Additional functions can be found in the [includes](https://github.com/hundredra
|
|||||||
- `(js)` Javascript interop.
|
- `(js)` Javascript interop.
|
||||||
- `(test name a b)`
|
- `(test name a b)`
|
||||||
- `(benchmark fn)` logs time taken to execute a function.
|
- `(benchmark fn)` logs time taken to execute a function.
|
||||||
|
- `(osc ~address)` returns the last received osc msg on port 12940
|
||||||
|
|
||||||
## Extras
|
## Extras
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
const { app, BrowserWindow, webFrame, Menu } = require('electron')
|
const { app, BrowserWindow, webFrame, Menu } = require('electron')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const url = require('url')
|
const url = require('url')
|
||||||
|
const osc = require('osc')
|
||||||
const shell = require('electron').shell
|
const shell = require('electron').shell
|
||||||
|
|
||||||
let isShown = true
|
let isShown = true
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "electron .",
|
"start": "electron .",
|
||||||
|
"install": "electron-rebuild",
|
||||||
"clean": "rm -r ~/Desktop/Ronin-darwin-x64/ ; rm -r ~/Desktop/Ronin-linux-x64/ ; rm -r ~/Desktop/Ronin-win32-x64/ ; echo 'cleaned build location'",
|
"clean": "rm -r ~/Desktop/Ronin-darwin-x64/ ; rm -r ~/Desktop/Ronin-linux-x64/ ; rm -r ~/Desktop/Ronin-win32-x64/ ; echo 'cleaned build location'",
|
||||||
"build_osx": "electron-packager . Ronin --platform=darwin --arch=x64 --out ~/Desktop/ --overwrite --icon=icon.icns ; echo 'Built for OSX'",
|
"build_osx": "electron-packager . Ronin --platform=darwin --arch=x64 --out ~/Desktop/ --overwrite --icon=icon.icns ; echo 'Built for OSX'",
|
||||||
"build_linux": "electron-packager . Ronin --platform=linux --arch=x64 --out ~/Desktop/ --overwrite --icon=icon.ico ; echo 'Built for LINUX'",
|
"build_linux": "electron-packager . Ronin --platform=linux --arch=x64 --out ~/Desktop/ --overwrite --icon=icon.ico ; echo 'Built for LINUX'",
|
||||||
@ -16,8 +17,12 @@
|
|||||||
"push_status": "~/butler status hundredrabbits/ronin",
|
"push_status": "~/butler status hundredrabbits/ronin",
|
||||||
"push": "npm run build ; npm run push_theme ; npm run push_osx ; npm run push_linux ; npm run push_win ; npm run clean ; npm run push_status"
|
"push": "npm run build ; npm run push_theme ; npm run push_osx ; npm run push_linux ; npm run push_win ; npm run clean ; npm run push_status"
|
||||||
},
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"osc": "^2.3.1"
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"electron": "^5.0.6",
|
"electron": "^5.0.6",
|
||||||
"electron-packager": "^13.1.1"
|
"electron-packager": "^13.1.1",
|
||||||
|
"electron-rebuild": "^1.8.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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"/>
|
||||||
|
@ -377,4 +377,14 @@ function Library (ronin) {
|
|||||||
console.log(`time taken: ${Date.now() - start}ms`)
|
console.log(`time taken: ${Date.now() - start}ms`)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// osc
|
||||||
|
|
||||||
|
this.osc = (...args) => { // Returns a rect of the frame.
|
||||||
|
if (args.length >= 1) {
|
||||||
|
return ronin.getOsc()[args[0]]
|
||||||
|
} else {
|
||||||
|
return ronin.getOsc();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
26
desktop/sources/scripts/osc.js
Normal file
26
desktop/sources/scripts/osc.js
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
'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();
|
||||||
|
ronin.log("osc started")
|
||||||
|
}
|
||||||
|
|
||||||
|
this.onOscMsg = (oscMsg, timeTag, info) => {
|
||||||
|
this.oscMsg[oscMsg.address] = oscMsg;
|
||||||
|
ronin.log("An OSC message just arrived!", oscMsg)
|
||||||
|
ronin.log("Remote info is: ", info);
|
||||||
|
}
|
||||||
|
}
|
@ -22,7 +22,7 @@ function Ronin () {
|
|||||||
this.surface = new Surface(this)
|
this.surface = new Surface(this)
|
||||||
this.library = new Library(this)
|
this.library = new Library(this)
|
||||||
this.interpreter = new Lisp(this.library, this.includes)
|
this.interpreter = new Lisp(this.library, this.includes)
|
||||||
|
this.osc = new Osc(this)
|
||||||
// Parameters
|
// Parameters
|
||||||
|
|
||||||
this.always = false
|
this.always = false
|
||||||
@ -46,7 +46,11 @@ function Ronin () {
|
|||||||
this.source.start()
|
this.source.start()
|
||||||
this.commander.start()
|
this.commander.start()
|
||||||
this.surface.start()
|
this.surface.start()
|
||||||
console.log('Ronin', 'Started')
|
this.osc.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
this.getOsc = function() {
|
||||||
|
return this.osc.oscMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.reset = function () {
|
this.reset = function () {
|
||||||
|
11
examples/osc1.lisp
Normal file
11
examples/osc1.lisp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
(clear)
|
||||||
|
(def x (of (osc "/test") "args" "0" "value"))
|
||||||
|
(def y (of (osc "/test") "args" "1" "value"))
|
||||||
|
(def r (of (osc "/test") "args" "2" "value"))
|
||||||
|
|
||||||
|
(fill
|
||||||
|
(circle x y r)
|
||||||
|
"red")
|
||||||
|
(stroke
|
||||||
|
(circle x y r)
|
||||||
|
5 "white")
|
Loading…
x
Reference in New Issue
Block a user