# SelectXFocus semantics (or bug) for focus > 1?

I’m trying to understand what `SelectXFocus` is supposed to do for `focus` > 1, but it doesn’t seem to make much sense to me. Below I’ve extracted the formula from the pseudo-ugen.

``````a = [1, 1, 1, 1];

~sxf = {|which, focus| a.collect({ arg in, i; (1 - (absdif(which, i) * focus)).max(0) * in}) }
~sxf.(1.2, 1); // -> [ 0.0, 0.8, 0.2, 0.0 ]
~sxf.(1.2, 2); // -> [ 0.0, 0.6, 0.0, 0.0 ]
~sxf.(1.2, 3); // -> [ 0.0, 0.4, 0.0, 0.0 ]

~sxf.(1.5, 1); // -> [ 0.0, 0.5, 0.5, 0.0 ]
~sxf.(1.5, 2); // -> [ 0.0, 0.0, 0.0, 0.0 ]
``````

Basically for `focus` > 1 (on which I’m guessing it’s supposed to mix more than 2 channels/inputs, it basically does nothing but attenuate on channel… ok or maybe attenuate both nearby channels a bit

``````~sxf.(1.5, 1.1); -> [ 0.0, 0.45, 0.45, 0.0 ]
~sxf.(1.5, 0.9); -> [ 0.0, 0.55, 0.55, 0.0 ]
``````

Does it ever manage to actually mix more than 2 channels/inputs with that formula, for some suitable parameterization? Or am I misreading its intended purpose? The help says:

The output is mixed from an array of inputs, linearly interpolating from a number of adjacent channels. A focus argument allows to control how many adjacent sources are mixed.

Oh, yeah, I see `focus` needs to be <1 (and fairly close to 0 actually) to make it mix more channels/inputs

``````~sxf.(1.5, 0.5); // -> [ 0.25, 0.75, 0.75, 0.25 ]
~sxf.(1.5, 0.3); // -> [ 0.55, 0.85, 0.85, 0.55 ]
~sxf.(1.5, 0.1); // -> [ 0.85, 0.95, 0.95, 0.85 ]
``````

(But there’s no normalization of any kind…)

The documentation incorrectly states that

The “fuzziness” of the selection: the larger the focus, the more adjacent inputs are mixed in.

When it’s the other way around.

``````(1, 0.9 .. 0.1) do: { |x| (x.asString ++ " -> " ++ ~sxf.(1.2, x)).postln; }
``````

Outputs:

``````1.0 -> [ 0.0, 0.8, 0.2, 0.0 ]
0.9 -> [ 0.0, 0.82, 0.28, 0.0 ]
0.8 -> [ 0.04, 0.84, 0.36, 0.0 ]
0.7 -> [ 0.16, 0.86, 0.44, 0.0 ]
0.6 -> [ 0.28, 0.88, 0.52, 0.0 ]
0.5 -> [ 0.4, 0.9, 0.6, 0.1 ]
0.4 -> [ 0.52, 0.92, 0.68, 0.28 ]
0.3 -> [ 0.64, 0.94, 0.76, 0.46 ]
0.2 -> [ 0.76, 0.96, 0.84, 0.64 ]
0.1 -> [ 0.88, 0.98, 0.92, 0.82 ]
``````

For `focus = 0.5` you get twice the total amplitude (across the array). So it looks like it needs to scaled by `focus` for normalization purposes… but it’s probably more complicated than that at least when there’s “clipping” at array edges:

``````(1, 0.9 .. 0.1) do: { |x| (x.asString ++ " -> " ++ ((~sxf.(1.2, x) * x).sum)).postln; }
``````
``````1.0 -> 1.0
0.9 -> 0.99
0.8 -> 0.992
0.7 -> 1.022
0.6 -> 1.008
0.5 -> 1.0
0.4 -> 0.96
0.3 -> 0.84
0.2 -> 0.64
0.1 -> 0.36
``````

On the other hand, with a big enough array

``````a = 1!11
~sxf.(5, 0.2); // -> [ 0.0, 0.2, 0.4, 0.6, 0.8, 1.0, 0.8, 0.6, 0.4, 0.2, 0.0 ]
(0.2 * ~sxf.(5, 0.2)).sum; // -> 1.0
``````