Improvements to return value handling magic

nix
Owen Green 6 years ago
parent 2faa8c05ab
commit d169f70af6

@ -13,11 +13,11 @@ FluidKMeans : FluidManipulationClient {
} }
predictPoint { |buffer, action| predictPoint { |buffer, action|
this.pr_sendMsg(\predictPoint,[buffer.asUGenInput],action,[numbers(FluidMessageResponse,_,1,_)]); this.pr_sendMsg(\predictPoint,[buffer.asUGenInput],action,[number(FluidMessageResponse,_,_)]);
} }
cols { |action| cols { |action|
this.pr_sendMsg(\cols,[],action,[numbers(FluidMessageResponse,_,1,_)]); this.pr_sendMsg(\cols,[],action,[number(FluidMessageResponse,_,_)]);
} }
read{ |filename,action| read{ |filename,action|

@ -29,7 +29,7 @@ FluidLabelSet : FluidManipulationClient {
} }
cols {|action| cols {|action|
this.pr_sendMsg(\cols,[],action,[numbers(FluidMessageResponse,_,1,_)]); this.pr_sendMsg(\cols,[],action,[number(FluidMessageResponse,_,_)]);
} }
read{|filename,action| read{|filename,action|
@ -41,7 +41,7 @@ FluidLabelSet : FluidManipulationClient {
} }
size { |action| size { |action|
this.pr_sendMsg(\size,[],action,[numbers(FluidMessageResponse,_,1,_)]); this.pr_sendMsg(\size,[],action,[number(FluidMessageResponse,_,_)]);
} }
clear { |action| clear { |action|

@ -9,9 +9,11 @@ FluidMessageResponse : Object
selectors.do{ |selector| selectors.do{ |selector|
var newThings; var newThings;
# newThings,idx = selector.value(a, idx); # newThings,idx = selector.value(a, idx);
response = response.add(newThings); response = response ++ newThings;
}; };
^response
if(response.size == 1,
{^response[0]},{^response})
} }
*string{ |a, offset| *string{ |a, offset|
@ -25,6 +27,10 @@ FluidMessageResponse : Object
^[a.copyRange(offset, offset + n),offset + n] ^[a.copyRange(offset, offset + n),offset + n]
} }
*number{ |a,offset|
^[a[offset]];
}
*buffer{ |a,server,offset| *buffer{ |a,server,offset|
server = server ? Server.default ; server = server ? Server.default ;
^[Buffer.cachedBufferAt(server, a[offset]), offset + 1] ^[Buffer.cachedBufferAt(server, a[offset]), offset + 1]

@ -80,7 +80,7 @@ c = Buffer.new(s)
~kMeans.predict(~dataset,~labels, {|x| x.postln}) ~kMeans.predict(~dataset,~labels, {|x| x.postln})
~labels.getLabel(~audioBuffers[2].path,action:{|c| c.postln}) ~labels.getLabel(~audioBuffers[2].path,action:{|c| c.postln})
Routine{ Routine{
~labels.size({|x|x[0][0].do {|i| ~labels.size({|x|x.do {|i|
forkIfNeeded{ forkIfNeeded{
~audioBuffers[i].path.postln; ~audioBuffers[i].path.postln;
~labels.getLabel(~audioBuffers[i].path,action:{|c| c.postln}); ~labels.getLabel(~audioBuffers[i].path,action:{|c| c.postln});

@ -44,11 +44,11 @@ Routine{
~labels = FluidLabelSet(s,\simple1label); ~labels = FluidLabelSet(s,\simple1label);
~kmeans.predict(~ds,~labels, {|x| ("Size of each cluster" + x[0]).postln}) ~kmeans.predict(~ds,~labels, {|x| ("Size of each cluster" + x).postln})
( (
Routine{ Routine{
var n; var n;
~labels.size({|x| n = x[0][0]}); ~labels.size({|x| n = x.asInt});
n.asInt.do{|i| n.asInt.do{|i|
~labels.getLabel(i.asString,action: {|l|("Label for" + i ++ ":" + l).postln}); ~labels.getLabel(i.asString,action: {|l|("Label for" + i ++ ":" + l).postln});
} }

Loading…
Cancel
Save