Generalize function to n-channels

hey, this is loosely connected to this thread. I would like to generalize the following function for n-channels. Does somebody has an idea how to go about that? thanks.

var channelMask = { |trig, numChannels, channelMask, centerMask|
	var rate = if(trig.rate == \audio, \ar, \kr);
	var channelsArray =, [

		// 2-channels
			Dser([-1], channelMask),
			Dser([1], channelMask),
			Dser([0], centerMask)

		// 3-channels
			Dser([-0.33], channelMask),
			Dser([0.33], channelMask),
			Dser([1], channelMask),
			Dser([0], centerMask)

		// 4-channels
			Dser([-0.25], channelMask),
			Dser([0.25], channelMask),
			Dser([0.75], channelMask),
			Dser([-0.75], channelMask),
			Dser([0], centerMask)

		// 8-channels
			Dser([-0.12], channelMask),
			Dser([0.12], channelMask),
			Dser([0.37], channelMask),
			Dser([0.63], channelMask),
			Dser([0.88], channelMask),
			Dser([-0.88], channelMask),
			Dser([-0.63], channelMask),
			Dser([-0.37], channelMask),
			Dser([0], centerMask)
	Demand.perform(rate, trig, 0, Dseq(channelsArray, inf)).lag(0.001);

I’m a little bit curious what is the stumbling block for you…? What I mean is – you constructed these numeric series based on some principle, so clearly you had a rule in mind.

In any case, it looks like an arithmetic series (+), where the step size is 2/n, and the initial offset is -1/n, and the values are wrapped between -1.0 and +1.0.

But, your two-channel example does not follow this rule – for some reason not known to me, for n = 2, both the step size and offset are doubled. If you followed the rule consistently, two channels would be -0.5, +0.5 (plus the special case 0 added at the end of all of your samples). Note, though, these all look like PanAz-style pan positions, rotating in a circle; if so, then -1 and +1 would be the same position, so I think your n = 2 is almost certainly a mistake (which is a problem you can run into if you’re just feeling your way through the numbers, instead of abstracting out the principles on your own).