osc: use 'address' instead of 'path' everywhere to avoid confusion

This commit is contained in:
jean-emmanuel 2016-11-02 08:54:53 +01:00
parent b397115e54
commit 4552bd6657
29 changed files with 80 additions and 77 deletions

View file

@ -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

View file

@ -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)
}
},

View file

@ -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)

View file

@ -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`

View file

@ -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`

View file

@ -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'}`

View file

@ -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`

View file

@ -2,7 +2,7 @@
WIDGETS = {}
WIDGETS_LINKED = {}
WIDGETS_BY_PATH = {}
WIDGETS_BY_ADDRESS = {}
SESSION = []
STATE = []

View file

@ -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})
}
}

View file

@ -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
}

View file

@ -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])

View file

@ -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

View file

@ -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}%`)

View file

@ -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]}%`)

View file

@ -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]}%`)

View file

@ -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<this.widgetData.points * 2;i=i+2) {
s[i]=this.widgetData.path + '/' + i/2 + '/x'
s[i+1]=this.widgetData.path + '/' + i/2 + '/y'
s[i]=this.widgetData.address + '/' + i/2 + '/x'
s[i+1]=this.widgetData.address + '/' + i/2 + '/y'
};
return s
})()

View file

@ -24,7 +24,7 @@ module.exports.options = {
separator3:'osc',
precision:0,
path:'auto',
address:'auto',
preArgs:[],
split:false,
target:[]
@ -37,7 +37,7 @@ var Rgb = module.exports.Rgb = function(widgetData) {
this.split = this.widgetData.split?
typeof this.widgetData.split == 'object'?
this.widgetData.split
: {r: this.widgetData.path + '/r', g: this.widgetData.path + '/g', b: this.widgetData.path + '/b'}
: {r: this.widgetData.address + '/r', g: this.widgetData.address + '/g', b: this.widgetData.address + '/b'}
: false
this.widget.append(`

View file

@ -28,7 +28,7 @@ module.exports.options = {
logScaleX:false,
logScaleY:false,
precision:2,
path:'auto',
address:'auto',
preArgs:[],
split:false,
target:[]
@ -41,7 +41,7 @@ var Xy = module.exports.Xy = function(widgetData) {
this.split = this.widgetData.split?
typeof this.widgetData.split == 'object'?
this.widgetData.split
: {x: this.widgetData.path + '/x', y: this.widgetData.path + '/y'}
: {x: this.widgetData.address + '/x', y: this.widgetData.address + '/y'}
: false
this.widget.append(`

View file

@ -26,7 +26,7 @@ module.exports.options = {
separator3:'osc',
path:'auto',
address:'auto',
preArgs:[],
}

View file

@ -19,7 +19,7 @@ module.exports.options = {
range:{min:0,max:1},
logScale:false,
preArgs:[],
path:'auto'
address:'auto'
}
module.exports.create = function(widgetData,container) {
var widget = $(`

View file

@ -20,7 +20,7 @@ module.exports.options = {
range:{min:0,max:1},
logScale:false,
path:'auto',
address:'auto',
preArgs:[]
}

View file

@ -26,7 +26,7 @@ module.exports.options = {
separator3:'osc',
path:'auto',
address:'auto',
preArgs:[],
}

View file

@ -16,7 +16,7 @@ module.exports.options = {
separator2:'osc',
preArgs:[],
path:'auto',
address:'auto',
defaultText:''
}
module.exports.create = function(widgetData,container) {

View file

@ -25,7 +25,7 @@ module.exports.options = {
separator3:'osc',
path:'auto',
address:'auto',
preArgs:[],
}

View file

@ -21,7 +21,7 @@ module.exports.options = {
off:0,
norelease:false,
precision:2,
path:'auto',
address:'auto',
preArgs:[],
target:[]
}
@ -105,7 +105,7 @@ module.exports.create = function(widgetData,container) {
sendOsc({
target:widgetData.target,
path:widgetData.path,
address:widgetData.address,
precision:widgetData.precision,
args:args,
syncOnly:norelease

View file

@ -33,7 +33,7 @@ module.exports.options = {
logScale:false,
precision:2,
meter:false,
path:'auto',
address:'auto',
preArgs:[],
target:[]
}
@ -94,7 +94,7 @@ var Fader = module.exports.Fader = function(widgetData){
horizontal:widgetData.horizontal,
range:widgetData.range,
logScale:widgetData.logScale,
path:widgetData.path + '/meter',
address:widgetData.address + '/meter',
preArgs:widgetData.preArgs,
color:widgetData.color
}

View file

@ -31,7 +31,7 @@ module.exports.options = {
origin: 'auto',
logScale:false,
precision:2,
path:'auto',
address:'auto',
preArgs:[],
target:[]
}

View file

@ -20,7 +20,7 @@ module.exports.options = {
values:{"Value 1":1,"Value 2":2},
precision:2,
path:'auto',
address:'auto',
preArgs:[],
target:[]
}
@ -71,7 +71,7 @@ module.exports.create = function(widgetData,container) {
sendOsc({
target:widgetData.target,
path:widgetData.path,
address:widgetData.address,
precision:widgetData.precision,
args:args
})

View file

@ -20,7 +20,7 @@ module.exports.options = {
on:1,
off:0,
precision:2,
path:'auto',
address:'auto',
preArgs:[],
target:[]
}
@ -79,7 +79,7 @@ module.exports.create = function(widgetData,container) {
sendOsc({
target:widgetData.target,
path:widgetData.path,
address:widgetData.address,
precision:widgetData.precision,
args:args
})