« Return to Thread: [approve, 3.3] Node:map backward compat fix

[approve, 3.3] Node:map backward compat fix

by James Harkins-2 :: Rate this Message:

Reply to Author | View in Thread

in Node.sc, right?
yes it appears to work..
thank you~

OK to check in then?

Sorry I didn't catch this earlier - if I realized compatibility would be broken on a basic feature, I would have spoken up before RC. I feel rather strongly we should not let 3.3 go out losing backward compat on what was, in 3.2, normal and expected usage (especially since the fix is simple and wouldn't break anything else).

Corner case: no arguments supplied. Should it fail with error on "bundle[0].isString" or fail silently?

aSynth.map; // die, or no-op?

Actually better -- bus = bus.asBus -- to allow polymorphic substitution. Then we wouldn't need the scalar branch, I think. (I just realized, in current svn, the usage "aSynth.map(\anArg, aGenericGlobalControl)" got broken [GenericGlobalControl is in my lib], where it would have worked in 3.3 betas. GenericGlobalControl can masquerade as a Bus using asBus, so this would fix that case.)

map { arg ... args;
var bundle = this.mapMsg(*args);
if(bundle[0].isString) {
server.sendBundle(nil, bundle);
} {
server.sendBundle(nil, *bundle);
};
}
mapMsg { arg ... args;
var krVals, arVals, result;
krVals = List.new;
arVals = List.new;
result = Array.new(2);
args.pairsDo({ arg control, bus;
bus = bus.asBus;
switch(bus.rate)
{ \control } {
krVals.addAll([control.asControlInput, bus.index, bus.numChannels])
}
// maybe we don't need this anymore
// { \scalar } {
// if(bus.isNumber) { krVals.addAll([control.asControlInput, bus, 1]) };
// }
{ \audio } {
arVals.addAll([control.asControlInput, bus.index, bus.numChannels]);
};
// no default case, ignore others
});
if(krVals.size > 0, { result = result.add(["/n_mapn", nodeID] ++ krVals) });
if(arVals.size > 0, { result = result.add(["/n_mapan",nodeID] ++ arVals) });
if(result.size < 2, { result = result.flatten; });
^result;
}

hjh


: H. James Harkins
.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:

"Come said the Muse,
Sing me a song no poet has yet chanted,
Sing me the universal."  -- Whitman

 « Return to Thread: [approve, 3.3] Node:map backward compat fix