From 4552bd66572132ed2e8bf0a42e1eb39a60f4de72 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Wed, 2 Nov 2016 08:54:53 +0100 Subject: [PATCH] osc: use 'address' instead of 'path' everywhere to avoid confusion --- CHANGELOG.md | 1 + app/main/callbacks.js | 2 +- app/main/osc.js | 10 +++++----- resources/docs/user-guide/widgets-generics.md | 4 ++-- .../user-guide/widgets-specifics/matrices.md | 6 +++--- .../docs/user-guide/widgets-specifics/pads.md | 16 +++++++-------- .../user-guide/widgets-specifics/sliders.md | 2 +- src/browser/js/app.js | 2 +- src/browser/js/app/callbacks.js | 18 ++++++++--------- src/browser/js/app/editor/data-workers.js | 20 +++++++++---------- src/browser/js/app/parser.js | 16 ++++++++------- .../js/app/widgets/common/_widgets_base.js | 4 ++-- .../js/app/widgets/matrices/multifader.js | 4 ++-- .../js/app/widgets/matrices/multipush.js | 4 ++-- .../js/app/widgets/matrices/multitoggle.js | 4 ++-- src/browser/js/app/widgets/pads/multixy.js | 6 +++--- src/browser/js/app/widgets/pads/rgb.js | 4 ++-- src/browser/js/app/widgets/pads/xy.js | 4 ++-- src/browser/js/app/widgets/plots/eq.js | 2 +- src/browser/js/app/widgets/plots/led.js | 2 +- src/browser/js/app/widgets/plots/meter.js | 2 +- src/browser/js/app/widgets/plots/plot.js | 2 +- src/browser/js/app/widgets/plots/text.js | 2 +- .../js/app/widgets/plots/visualizer.js | 2 +- src/browser/js/app/widgets/push.js | 4 ++-- src/browser/js/app/widgets/sliders/fader.js | 4 ++-- src/browser/js/app/widgets/sliders/knob.js | 2 +- src/browser/js/app/widgets/switch.js | 4 ++-- src/browser/js/app/widgets/toggle.js | 4 ++-- 29 files changed, 80 insertions(+), 77 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62798646..5c1593d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - main - **new** `-c / --custom-module` switch allowing user to define custom osc filtering fonctions + - `address` is now used everywhere instead of `path` to describe osc address to avoid confusion. Session files using the old `path` option for widgets are still supported. ## 0.9.2 diff --git a/app/main/callbacks.js b/app/main/callbacks.js index ffc8a83e..763eb783 100644 --- a/app/main/callbacks.js +++ b/app/main/callbacks.js @@ -80,7 +80,7 @@ module.exports = { var host = targets[i].split(':')[0], port = targets[i].split(':')[1] - if (port) osc.send(host,port,data.path,data.args,data.precision) + if (port) osc.send(host,port,data.address,data.args,data.precision) } }, diff --git a/app/main/osc.js b/app/main/osc.js index 244d62d4..1ced4919 100644 --- a/app/main/osc.js +++ b/app/main/osc.js @@ -50,7 +50,7 @@ var sendOsc = function(data){ args: data.args }, data.host, data.port); - if (debug) console.log('OSC sent: ',{path:data.address, args: data.args}, 'To : ' + data.host + ':' + data.port) + if (debug) console.log('OSC sent: ',{address:data.address, args: data.args}, 'To : ' + data.host + ':' + data.port) } @@ -62,7 +62,7 @@ var receiveOsc = function(data, info){ ipc.send('receiveOsc',data) - if (debug) console.log('OSC received: ', {path:data.address, args: data.args}, 'From : ' + data.address + ':' + data.port) + if (debug) console.log('OSC received: ', {address:data.address, args: data.args}, 'From : ' + data.address + ':' + data.port) } @@ -102,7 +102,7 @@ var oscOutFilter = function(data){ oscServer.on('message', function (msg, bundle, info) { - var data = oscInFilter({path: msg.address, args: msg.args, host: info.address, port: info.port}) + var data = oscInFilter({address: msg.address, args: msg.args, host: info.address, port: info.port}) receiveOsc(data) }) @@ -115,7 +115,7 @@ oscServer.open() module.exports = { - send: function(host,port,path,args,precision) { + send: function(host,port,address,args,precision) { var message = [] @@ -129,7 +129,7 @@ module.exports = { if (arg!=null) message.push(arg) } - var data = oscOutFilter({address:path, args: message, host: host, port: port}) + var data = oscOutFilter({address:address, args: message, host: host, port: port}) sendOsc(data) diff --git a/resources/docs/user-guide/widgets-generics.md b/resources/docs/user-guide/widgets-generics.md index 2fc1d5e6..322d7a7d 100644 --- a/resources/docs/user-guide/widgets-generics.md +++ b/resources/docs/user-guide/widgets-generics.md @@ -85,10 +85,10 @@ A widget object is a javascript object. All widgets share a set of generic prope - each element of the `array` must be a string formatted as follows : `"ip:port"` - multiple targets can be specified : `["ip1:port1","ip2:port2"]` -#### `path` +#### `address` - type: `string` - default: `/widgets_id` -- usage: this is the `path` of the osc messages sent by the widget +- usage: this is the `address` of the osc messages sent by the widget #### `preArgs` - type: `array` diff --git a/resources/docs/user-guide/widgets-specifics/matrices.md b/resources/docs/user-guide/widgets-specifics/matrices.md index b35c6e4d..13a9115c 100644 --- a/resources/docs/user-guide/widgets-specifics/matrices.md +++ b/resources/docs/user-guide/widgets-specifics/matrices.md @@ -19,7 +19,7 @@ Multifader creates a row of vertical faders that respond to the same gestures. - usage: number of faders in the row, each fader will inherit its parent's properties and the following ones (where `i` is the fader's index in the row) - `id`: same as the widget's with `/i` appended to it - `label`: `i` - - `path`: same as the widget's with `/i` appended to it + - `address`: same as the widget's with `/i` appended to it #### `traversing` - type: `boolean` @@ -46,7 +46,7 @@ Multifader creates a row of vertical faders that respond to the same gestures. - usage: defines the number of columns and and rows. Each cell will contain a toggle button that will inherit its parent's properties and the following ones (where `i` is the fader's index in the row) - `id`: same as the widget's with `/i` appended to it - `label`: `i` - - `path`: same as the widget's with `/i` appended to it + - `address`: same as the widget's with `/i` appended to it #### `traversing` - type: `boolean` @@ -72,7 +72,7 @@ Multifader creates a row of vertical faders that respond to the same gestures. - usage: defines the number of columns and and rows. Each cell will contain a push button that will inherit its parent's properties and the following ones (where `i` is the fader's index in the row) - `id`: same as the widget's with `/i` appended to it - `label`: `i` - - `path`: same as the widget's with `/i` appended to it + - `address`: same as the widget's with `/i` appended to it #### `traversing` - type: `boolean` diff --git a/resources/docs/user-guide/widgets-specifics/pads.md b/resources/docs/user-guide/widgets-specifics/pads.md index cde99b5c..9d775232 100644 --- a/resources/docs/user-guide/widgets-specifics/pads.md +++ b/resources/docs/user-guide/widgets-specifics/pads.md @@ -46,9 +46,9 @@ Pads are multidimensional widgets that output multiple values. - type: `boolean|object` - default: `false` - usage: - - set to `true` to send separate osc messages for `x` and `y` axis. The `path` will be the same as the widget's with `/x` or `/y` appended to it - - can be set as an object to specify a different `path` : `{x:'/osc_path_x', y:'/osc_path_y'}` -- note: the widget will only respond to its original osc path, not to the splitted version + - set to `true` to send separate osc messages for `x` and `y` axis. The `address` will be the same as the widget's with `/x` or `/y` appended to it + - can be set as an object to specify a different `address` : `{x:'/osc_address_x', y:'/osc_address_y'}` +- note: the widget will only respond to its original osc address, not to the splitted version ---- @@ -98,9 +98,9 @@ Pads are multidimensional widgets that output multiple values. - type: `boolean|object` - default: `false` - usage: - - set to `true` to send separate osc messages for each point's `x` and `y` axis. The `path` will be the same as the widget's with `/N/x` or `/N/y` appended to it, where `N` is the point's id. - - can be set as an object to specify a different `path` : `{0:'/osc_path/0', 1:'/osc_path_/1'}` (each path will be appended `/x` or `y`) -- note: the widget will only respond to its original osc path, not to the splitted version + - set to `true` to send separate osc messages for each point's `x` and `y` axis. The `address` will be the same as the widget's with `/N/x` or `/N/y` appended to it, where `N` is the point's id. + - can be set as an object to specify a different `address` : `{0:'/osc_address/0', 1:'/osc_address_/1'}` (each address will be appended `/x` or `y`) +- note: the widget will only respond to its original osc address, not to the splitted version ---- @@ -128,5 +128,5 @@ RGB is a variant of XY, it outputs rgb values between 0 and 255. - type: `boolean|object` - default: `false` - usage: - - set to `true` to send separate osc messages for `r` and `g` & `b`. The `path` will be the same as the widget's with `/r`, `/g` or `/b` appended to it - - can be set as an object to specify a different `path` : `{r:'/osc_path_r', g:'/osc_path_g',b:'/osc_path_b'}` + - set to `true` to send separate osc messages for `r` and `g` & `b`. The `address` will be the same as the widget's with `/r`, `/g` or `/b` appended to it + - can be set as an object to specify a different `address` : `{r:'/osc_address_r', g:'/osc_address_g',b:'/osc_address_b'}` diff --git a/resources/docs/user-guide/widgets-specifics/sliders.md b/resources/docs/user-guide/widgets-specifics/sliders.md index 5e535923..5df00591 100644 --- a/resources/docs/user-guide/widgets-specifics/sliders.md +++ b/resources/docs/user-guide/widgets-specifics/sliders.md @@ -77,7 +77,7 @@ range: { - default: `false` - usage: set to true to display a vu-meter next in the fader - the meter's `id` will be the same as the widget's with `/meter` appended to it - - the meter's `path `will be the same as the widget's with `/meter` appended to it + - the meter's `address `will be the same as the widget's with `/meter` appended to it #### `css` diff --git a/src/browser/js/app.js b/src/browser/js/app.js index b9e9e992..acccf1b5 100644 --- a/src/browser/js/app.js +++ b/src/browser/js/app.js @@ -2,7 +2,7 @@ WIDGETS = {} WIDGETS_LINKED = {} -WIDGETS_BY_PATH = {} +WIDGETS_BY_ADDRESS = {} SESSION = [] STATE = [] diff --git a/src/browser/js/app/callbacks.js b/src/browser/js/app/callbacks.js index edf58607..48286665 100644 --- a/src/browser/js/app/callbacks.js +++ b/src/browser/js/app/callbacks.js @@ -8,17 +8,17 @@ module.exports = { receiveOsc: function(event,data){ var data = data || event - // fetch ids corresponding to the osc path - var path = data.path, - pathref = path, + // fetch ids corresponding to the osc address + var address = data.address, + addressref = address, args = data.args, target = data.target if (typeof data.args == 'object') { for (var i=data.args.length-1;i>=0;i--) { - var ref = path+'||||'+data.args.slice(0,i).join('||||') - if (WIDGETS_BY_PATH[ref]) { - pathref = ref + var ref = address+'||||'+data.args.slice(0,i).join('||||') + if (WIDGETS_BY_ADDRESS[ref]) { + addressref = ref args = data.args.slice(i,data.args.length) continue } @@ -31,13 +31,13 @@ module.exports = { if (args.length==0) args = null else if (args.length==1) args = args[0] - for (i in WIDGETS_BY_PATH[pathref]) { + for (i in WIDGETS_BY_ADDRESS[addressref]) { // if the message target is provided (when message comes from another client connected to the same server) // then we only update the widgets that have the same target // compare arrays using > and < operators (both false = equality) - if (!target || !(WIDGETS_BY_PATH[pathref][i].target < target || WIDGETS_BY_PATH[pathref][i].target > target)) { + if (!target || !(WIDGETS_BY_ADDRESS[addressref][i].target < target || WIDGETS_BY_ADDRESS[addressref][i].target > target)) { // update matching widgets - if (WIDGETS_BY_PATH[pathref][i]) WIDGETS_BY_PATH[pathref][i].setValue(args,{send:false,sync:true,fromExternal:!target}) + if (WIDGETS_BY_ADDRESS[addressref][i]) WIDGETS_BY_ADDRESS[addressref][i].setValue(args,{send:false,sync:true,fromExternal:!target}) } } diff --git a/src/browser/js/app/editor/data-workers.js b/src/browser/js/app/editor/data-workers.js index 2c70bf5a..3f81f7e3 100644 --- a/src/browser/js/app/editor/data-workers.js +++ b/src/browser/js/app/editor/data-workers.js @@ -117,27 +117,27 @@ var incrementWidget = function(data){ var id = data.id, label = data.label, - path = data.path + address = data.address if (id && id==label) { data.label = 'auto' } - if (id && path == '/'+id) { + if (id && address == '/'+id) { - data.path = 'auto' + data.address = 'auto' - } else if (path){ - var pathref - while (WIDGETS_BY_PATH[pathref]) { - path = path.replace(/([0-9]*)$/,function(m){ + } else if (address){ + var addressref + while (WIDGETS_BY_ADDRESS[addressref]) { + address = address.replace(/([0-9]*)$/,function(m){ var n = parseInt(m)+1 n = isNaN(n)?1:n return n }) - pathref = data.preArgs&&data.preArgs.length?path+'||||'+data.preArgs.join('||||'):path + addressref = data.preArgs&&data.preArgs.length?address+'||||'+data.preArgs.join('||||'):address } - WIDGETS_BY_PATH[pathref] = [] - data.path = path + WIDGETS_BY_ADDRESS[addressref] = [] + data.address = address } diff --git a/src/browser/js/app/parser.js b/src/browser/js/app/parser.js index 60dfe002..ac86cbdf 100644 --- a/src/browser/js/app/parser.js +++ b/src/browser/js/app/parser.js @@ -20,7 +20,7 @@ module.exports.tabs = function(data,parent,main,parentLabel){ // Reset Globals WIDGETS = {} WIDGETS_LINKED = {} - WIDGETS_BY_PATH = {} + WIDGETS_BY_ADDRESS = {} SESSION = data for (i in TABS) { if (i!='#container') { @@ -101,7 +101,9 @@ module.exports.widgets = function(data,parent) { widgetData.id = id } - widgetData.path = widgetData.path=='auto'?'/' + widgetData.id:widgetData.path + if (widgetData.path) widgetData.address = widgetData.path + + widgetData.address = widgetData.address=='auto'?'/' + widgetData.id:widgetData.address widgetData.target = widgetData.target?(Array.isArray(widgetData.target)?widgetData.target:[widgetData.target]):false for (i in widgetData) { @@ -170,11 +172,11 @@ module.exports.widgets = function(data,parent) { WIDGETS_LINKED[widgetData.linkId].push(widgetInner) } - // store widget by path and encode preArgs for perfect cross-app sync - if (widgetData.path)  { - var pathref = widgetData.preArgs&&widgetData.preArgs.length?widgetData.path+'||||'+widgetData.preArgs.join('||||'):widgetData.path - if (WIDGETS_BY_PATH[pathref]==undefined) WIDGETS_BY_PATH[pathref] = [] - WIDGETS_BY_PATH[pathref].push(widgetInner) + // store widget by address and encode preArgs for perfect cross-app sync + if (widgetData.address)  { + var addressref = widgetData.preArgs&&widgetData.preArgs.length?widgetData.address+'||||'+widgetData.preArgs.join('||||'):widgetData.address + if (WIDGETS_BY_ADDRESS[addressref]==undefined) WIDGETS_BY_ADDRESS[addressref] = [] + WIDGETS_BY_ADDRESS[addressref].push(widgetInner) } parent[0].appendChild(widgetContainer[0]) diff --git a/src/browser/js/app/widgets/common/_widgets_base.js b/src/browser/js/app/widgets/common/_widgets_base.js index ecb0ab39..c28de28d 100644 --- a/src/browser/js/app/widgets/common/_widgets_base.js +++ b/src/browser/js/app/widgets/common/_widgets_base.js @@ -11,7 +11,7 @@ _widget_base.prototype.sendValue = function() { sendOsc({ target:this.widgetData.target, - path:this.widgetData.path, + address:this.widgetData.address, precision:this.widgetData.precision, args:args, syncOnly:this.split?true:false @@ -22,7 +22,7 @@ _widget_base.prototype.sendValue = function() { for (i in this.split) { sendOsc({ target:this.widgetData.target, - path:this.split[i], + address:this.split[i], precision:this.widgetData.precision, args:this.widgetData.preArgs.concat(this.value[n]), sync:false diff --git a/src/browser/js/app/widgets/matrices/multifader.js b/src/browser/js/app/widgets/matrices/multifader.js index 5d48a7ba..e7256251 100644 --- a/src/browser/js/app/widgets/matrices/multifader.js +++ b/src/browser/js/app/widgets/matrices/multifader.js @@ -34,7 +34,7 @@ module.exports.options = { logScale:false, precision:2, meter:false, - path:'auto', + address:'auto', preArgs:[], target:[] } @@ -58,7 +58,7 @@ var Multifader = module.exports.Multifader = function(widgetData) { data.type = 'fader' data.id = widgetData.id + '/' + i data.label = i - data.path = widgetData.path + '/' + i + data.address = widgetData.address + '/' + i var element = parsewidgets([data],this.widget) element[0].setAttribute('style',`${widgetData.horizontal?'height':'width'}:${100/widgetData.strips}%`) diff --git a/src/browser/js/app/widgets/matrices/multipush.js b/src/browser/js/app/widgets/matrices/multipush.js index d985e073..eded254a 100644 --- a/src/browser/js/app/widgets/matrices/multipush.js +++ b/src/browser/js/app/widgets/matrices/multipush.js @@ -28,7 +28,7 @@ module.exports.options = { off:0, norelease:false, precision:2, - path:'auto', + address:'auto', preArgs:[], target:[] } @@ -49,7 +49,7 @@ var Multipush = module.exports.Multipush = function(widgetData) { data.type = 'push' data.id = widgetData.id + '/' + i data.label = i - data.path = widgetData.path + '/' + i + data.address = widgetData.address + '/' + i var element = parsewidgets([data],this.widget) element[0].setAttribute('style',`width:${100/widgetData.matrix[0]}%`) diff --git a/src/browser/js/app/widgets/matrices/multitoggle.js b/src/browser/js/app/widgets/matrices/multitoggle.js index 25a3cf1f..b34b5ea0 100644 --- a/src/browser/js/app/widgets/matrices/multitoggle.js +++ b/src/browser/js/app/widgets/matrices/multitoggle.js @@ -27,7 +27,7 @@ module.exports.options = { on:1, off:0, precision:2, - path:'auto', + address:'auto', preArgs:[], target:[] } @@ -47,7 +47,7 @@ var Multitoggle = module.exports.Multitoggle = function(widgetData) { data.type = 'toggle' data.id = widgetData.id + '/' + i data.label = i - data.path = widgetData.path + '/' + i + data.address = widgetData.address + '/' + i var element = parsewidgets([data],this.widget) element[0].setAttribute('style',`width:${100/widgetData.matrix[0]}%`) diff --git a/src/browser/js/app/widgets/pads/multixy.js b/src/browser/js/app/widgets/pads/multixy.js index 9d31272a..7ea840d3 100644 --- a/src/browser/js/app/widgets/pads/multixy.js +++ b/src/browser/js/app/widgets/pads/multixy.js @@ -29,7 +29,7 @@ module.exports.options = { logScaleX:false, logScaleY:false, precision:2, - path:'auto', + address:'auto', preArgs:[], split:false, target:[] @@ -48,8 +48,8 @@ var MultiXy = module.exports.MultiXy = function(widgetData) { : (()=>{ var s={}; for (var i=0; i