- replaced osc.js dependency with node-osc which is 100x lighter and compatbile with electron 0.32 !!
This commit is contained in:
parent
4ba84f43a9
commit
0697a2e727
6 changed files with 40 additions and 49 deletions
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
ipc.on('receiveOsc',function(data){
|
||||
// fetch id
|
||||
var path = data.address;
|
||||
var path = data.path;
|
||||
var id = __widgetsIds__[path]
|
||||
|
||||
// update
|
||||
|
|
|
|||
|
|
@ -74,7 +74,8 @@ init = function(callback) {
|
|||
var scrollbar = 10
|
||||
var h = $('#container').innerHeight()-scrollbar-$(this).parents('.tab').length*5;
|
||||
if ($(this).get(0).scrollHeight+scrollbar == $(this).height()) {
|
||||
$(this).scrollLeft($(this).scrollLeft()+e.originalEvent.deltaY);
|
||||
var scroll = e.originalEvent.deltaY || e.originalEvent.deltaX
|
||||
$(this).scrollLeft($(this).scrollLeft()+scroll);
|
||||
e.preventDefault();
|
||||
} else if (e.pageY>=h) {
|
||||
$(this).scrollLeft($(this).scrollLeft()+e.originalEvent.deltaY);
|
||||
|
|
|
|||
|
|
@ -222,7 +222,9 @@ rgbToHsb = function (rgb) {
|
|||
|
||||
clip = function(value,range) {
|
||||
var max = Math.max,
|
||||
min = Math.min
|
||||
min = Math.min,
|
||||
value = parseFloat(value)
|
||||
if (isNaN(value)) value = range[0]
|
||||
|
||||
return max(min(range[0],range[1]),min(parseFloat(value),max(range[0],range[1])))
|
||||
|
||||
|
|
@ -233,9 +235,8 @@ mapToScale = function(value,rangeIn,rangeOut,reverse) {
|
|||
|
||||
var max = Math.max,
|
||||
min = Math.min,
|
||||
round = Math.round
|
||||
|
||||
value = max(min(rangeIn[0],rangeIn[1]),min(parseFloat(value),max(rangeIn[0],rangeIn[1])))
|
||||
round = Math.round,
|
||||
value = clip(value,[rangeIn[0],rangeIn[1]])
|
||||
|
||||
value = ((value-rangeIn[0])/(rangeIn[1]-rangeIn[0])) * (rangeOut[1]-rangeOut[0]) + rangeOut[0]
|
||||
|
||||
|
|
|
|||
|
|
@ -6,13 +6,14 @@ var app = require('app')
|
|||
, BrowserWindow = require('browser-window')
|
||||
, dialog = require('dialog')
|
||||
, express = require('express')()
|
||||
, osc = require("osc-electron")
|
||||
, osc = require('node-osc')
|
||||
, fs = require("fs")
|
||||
, ipc = require('ipc')
|
||||
, configPath = __dirname + '/config.json'
|
||||
, config = require(configPath)
|
||||
, args = process.argv.slice(0);
|
||||
|
||||
|
||||
dialog.showErrorBox = function(title,err) {
|
||||
console.log(title + ': ' + err)
|
||||
}
|
||||
|
|
@ -71,16 +72,6 @@ restartApp = function(){
|
|||
|
||||
|
||||
|
||||
// static files serving
|
||||
express.get('/', function (req, res) {
|
||||
res.sendFile(__dirname + '/../browser/index.html');
|
||||
});
|
||||
|
||||
express.get('/*', function (req, res) {
|
||||
res.sendFile(__dirname + '/../browser/' + req.path);
|
||||
});
|
||||
|
||||
|
||||
var window = null;
|
||||
// Quit when all windows are closed.
|
||||
app.on('window-all-closed', function() {
|
||||
|
|
@ -96,7 +87,7 @@ app.on('window-all-closed', function() {
|
|||
app.on('ready', function() {
|
||||
// Create the browser window.
|
||||
window = new BrowserWindow({
|
||||
width: 800,
|
||||
width: 810,
|
||||
height: 600,
|
||||
'auto-hide-menu-bar':true
|
||||
});
|
||||
|
|
@ -148,26 +139,15 @@ app.on('ready', function() {
|
|||
|
||||
|
||||
|
||||
var oscServer = new osc.Server(readConfig('oscInPort'), '127.0.0.1');
|
||||
|
||||
// osc event listener
|
||||
var udpPort = new osc.UDPPort({
|
||||
localAddress: "127.0.0.1",
|
||||
localPort: readConfig('oscInPort')
|
||||
});
|
||||
|
||||
|
||||
// Forward OSC incomming messages to renderProcess via upd
|
||||
|
||||
udpPort.open();
|
||||
|
||||
udpPort.on("message", function (data) {
|
||||
oscServer.on("message", function (msg, rinfo) {
|
||||
var data = {path:msg.shift(),args:msg}
|
||||
if (data.args.length==1) data.args = data.args[0]
|
||||
renderProcess.send('receiveOsc',data);
|
||||
// console.log('Received OSC : ',data)
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
// mainProcess & renderProcess async i/o
|
||||
|
||||
renderProcess = {
|
||||
|
|
@ -252,14 +232,22 @@ ipc.on('sendOsc', function (event,data) {
|
|||
var host = targets[i].split(':')[0],
|
||||
port = targets[i].split(':')[1];
|
||||
|
||||
try {
|
||||
udpPort.send({
|
||||
address: data.path,
|
||||
args: data.args
|
||||
}, host, port);
|
||||
} catch(err) {
|
||||
console.log(err)
|
||||
if (port) {
|
||||
var client = new osc.Client(host, port);
|
||||
client.send(data.path, data.args, function () {
|
||||
client.kill();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// try {
|
||||
// udpPort.send({
|
||||
// address: data.path,
|
||||
// args: data.args
|
||||
// }, host, port);
|
||||
// } catch(err) {
|
||||
// console.log(err)
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "pornosc",
|
||||
"description": "OSC control GUI (node/electron)",
|
||||
"name": "open-stage-control",
|
||||
"description": "Osc control surface",
|
||||
"version": "0.0.1",
|
||||
"main": "index.js",
|
||||
"author": {
|
||||
|
|
@ -8,10 +8,8 @@
|
|||
"email": "jeannot@ammd.net"
|
||||
},
|
||||
"dependencies": {
|
||||
"osc-electron": "1.3",
|
||||
"express": "4.x",
|
||||
"socket.io": "1.x"
|
||||
},
|
||||
"node-osc": "1.1"
|
||||
},
|
||||
"keywords": [
|
||||
"osc",
|
||||
"gui"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
|
||||
TABS = function(){
|
||||
var db = {'min': -70,'20%': -40,'45%': -20,'60%': -10,'71%':-6,'78%':-3,'85%':0,'92%':3,'max': 6}
|
||||
var target = '127.0.0.1:6666'
|
||||
var tabs = new Array()
|
||||
tabs.push(function(){
|
||||
var tab = {}
|
||||
|
|
@ -14,17 +15,20 @@ TABS = function(){
|
|||
widgets: [
|
||||
{
|
||||
id:'knob_'+i,
|
||||
type:"knob"
|
||||
type:"knob",
|
||||
target:target
|
||||
},
|
||||
{
|
||||
id:'fader_'+i,
|
||||
type:"fader",
|
||||
range:db
|
||||
range:db,
|
||||
target:target
|
||||
},
|
||||
{
|
||||
id:'toggle1_'+i,
|
||||
label:'Mute',
|
||||
type:"toggle",
|
||||
target:target
|
||||
// color:'orange'
|
||||
}
|
||||
]
|
||||
|
|
@ -43,4 +47,3 @@ TABS = function(){
|
|||
|
||||
return tabs
|
||||
}()
|
||||
console.log(TABS)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue