Skip to content

Commit

Permalink
CVCenter: use set(n) instead of xset(n) when creating a GUI from Node…
Browse files Browse the repository at this point in the history
…Proxy

while set(n) sets the control in the running synth xset resp. xsetn
instantiates a new synth behind the scenes which may have unwanted side-
effects. For convenience an inactive xset(n) action gets created
automatically as well.

Signed-off-by:  <st9fan@gmail.com>
  • Loading branch information
nuss committed Mar 3, 2014
1 parent 0d20a37 commit ba34c46
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions CVCenter/CVCenter.sc
Original file line number Diff line number Diff line change
Expand Up @@ -2361,17 +2361,9 @@ CVCenter {
var varNames, thisSpec;
var activate = true;
var actionName = "default";
var wms, addActionFunc, setMsg, setnMsg;
var wms, addActionFunc;

// [obj, ctrlName, environment, more].postln;
// "obj.class: %\n".postf(obj.class);
if(obj.isKindOf(NodeProxy), {
setMsg = \xset;
setnMsg = \xsetn;
}, {
setMsg = \set;
setnMsg = \setn;
});

varNames = obj.getObjectVarNames(environment);
// "varNames: %\n".postf(varNames);
Expand Down Expand Up @@ -2406,10 +2398,16 @@ CVCenter {
if(j == 0, { activate = true }, { activate = false });
switch(more.type,
\w2d, {
this.addActionAt(more.cName, actionName, "{ |cv|"+v+"!? {"+v++"."++setnMsg++"('"++ctrlName++"', ["++wms++"]) }}", slot, activate);
this.addActionAt(more.cName, actionName, "{ |cv|"+v+"!? {"+v++".setn('"++ctrlName++"', ["++wms++"]) }}", slot, activate);
if(obj.isKindOf(NodeProxy), {
this.addActionAt(more.cName, actionName+"(xsetn)", "{ |cv|"+v+"!? {"+v++".xsetn('"++ctrlName++"', ["++wms++"]) }}", slot, false);
});
},
\w2dc, {
this.addActionAt(more.cName, actionName, "{ |cv|"+v+"!? {"+v++"."++setMsg++"('"++more.controls[i]++"', cv.value) }}", slot, activate);
this.addActionAt(more.cName, actionName, "{ |cv|"+v+"!? {"+v++".set('"++more.controls[i]++"', cv.value) }}", slot, activate);
if(obj.isKindOf(NodeProxy), {
this.addActionAt(more.cName, actionName+"(xset)", "{ |cv|"+v+"!? {"+v++".xset('"++more.controls[i]++"', cv.value) }}", slot, false);
});
}
)
})
Expand All @@ -2432,7 +2430,10 @@ CVCenter {
varNames.do({ |v, j|
actionName = "default"++(j+1);
if(j == 0, { activate = true }, {activate = false });
this.addActionAt(more.cName, actionName, "{ |cv|"+v+"!? {"+v++"."++setnMsg++"('"++ctrlName++"', cv.value) }}", active: activate);
this.addActionAt(more.cName, actionName, "{ |cv|"+v+"!? {"+v++".setn('"++ctrlName++"', cv.value) }}", active: activate);
if(obj.isKindOf(NodeProxy), {
this.addActionAt(more.cName, actionName+"(xsetn)", "{ |cv|"+v+"!? {"+v++".xsetn('"++ctrlName++"', cv.value) }}", active: false);
});
})
}, {
this.addActionAt(more.cName, \default, "{ |cv| Server('"++obj.server++"').sendBundle("++obj.server.latency++", ['/n_setn', "++obj.nodeID++", '"++ctrlName++"', "++more.slots.size++", cv.value]) }");
Expand All @@ -2448,7 +2449,10 @@ CVCenter {
actionName = "default"++(j+1);
if(j == 0, { activate = true }, { activate = false });
if(more.controls.notNil and:{ more.controls.size > 1 }, {
this.addActionAt(more.cName, actionName, "{ |cv|"+v+"!? {"+v++"."++setMsg++"('"++ctrlName++"', cv.value) }}", active: activate);
this.addActionAt(more.cName, actionName, "{ |cv|"+v+"!? {"+v++".set('"++ctrlName++"', cv.value) }}", active: activate);
if(obj.isKindOf(NodeProxy), {
this.addActionAt(more.cName, actionName+"(xset)", "{ |cv|"+v+"!? {"+v++".xset('"++ctrlName++"', cv.value) }}", active: false);
});
}, {
wms = [];
more.slots.size.do({ |i|
Expand All @@ -2458,7 +2462,10 @@ CVCenter {
wms = wms.add("CVCenter.at('"++more.cName.asString++(i+1)++"').value")
})
});
this.addActionAt(more.cName.asString++(j+1), actionName, "{ |cv|"+v+"!? {"+v++"."++setnMsg++"('"++ctrlName++"', ["++(wms.join(", "))++"]) }}", active: activate);
this.addActionAt(more.cName.asString++(j+1), actionName, "{ |cv|"+v+"!? {"+v++".setn('"++ctrlName++"', ["++(wms.join(", "))++"]) }}", active: activate);
if(obj.isKindOf(NodeProxy), {
this.addActionAt(more.cName.asString++(j+1), actionName+"(xsetn)", "{ |cv|"+v+"!? {"+v++".xsetn('"++ctrlName++"', ["++(wms.join(", "))++"]) }}", active: false);
});
})
}, {
this.addActionAt(more.cName, \default, "{ |cv| Server('"++obj.server++"').sendBundle("++obj.server.latency++", ['/n_setn', "++obj.nodeID++", '"++ctrlName++"', 1, cv.value]) }");
Expand All @@ -2472,10 +2479,13 @@ CVCenter {
if(varNames.size > 0, {
varNames.do({ |v, j|
if(j == 0, { activate = true }, { activate = false });
this.addActionAt(more.cName, \default++(j+1), "{ |cv|"+v+"!? {"+v++"."++setMsg++"('"++ctrlName++"', cv.value) }}", active: activate);
this.addActionAt(more.cName, actionName++(j+1), "{ |cv|"+v+"!? {"+v++".set('"++ctrlName++"', cv.value) }}", active: activate);
if(obj.isKindOf(NodeProxy), {
this.addActionAt(more.cName, actionName++(j+1)+"(xset)", "{ |cv|"+v+"!? {"+v++".xset('"++ctrlName++"', cv.value) }}", active: false);
})
})
}, {
this.addActionAt(more.cName, \default, "{ |cv| Server('"++obj.server++"').sendBundle("++obj.server.latency++", ['/n_setn', "++obj.nodeID++", '"++ctrlName++"', 1, cv.value]) }");
this.addActionAt(more.cName, actionName, "{ |cv| Server('"++obj.server++"').sendBundle("++obj.server.latency++", ['/n_setn', "++obj.nodeID++", '"++ctrlName++"', 1, cv.value]) }");
})
}
{ more.slots.size == 2 } {
Expand Down

0 comments on commit ba34c46

Please sign in to comment.