Mix.fill does not accept declared argument as size

As topic says , a declared argument value12 called partials is not accepted by the mix.fill first argument (array size )

//////
(
{
   arg  partial=12;

   Mix.fill(partial,{SinOsc.ar(800+100.rand,mul:1/partial)})!2;
   
}.play
)
///

Because the server cannot dynamically change the SynthDef structure.

Everybody thinks they can find an exception to this rule, but there isn’t one.

hjh

O.k. , it’s even clear in simple examples , if you replace the var.overtone ( which is just a number to fill an array) with argument partial ( same number )

//////////////////////
(
{
	arg  partial=12;
	var overtone=12;
	SinOsc.ar(800/(1..overtone),mul:1/(1..overtone))*1/12!2;
	
}.play
)
///

This brings me or less to the next question
Creating a saw or square from SineOsc is easy by multiplying the fundamental ,dividing the overtones amplitues with the (all,odd) harmonic series .
SO we can e.g. multiply the sine’s fundamental with(shortcut) array (1…10) like this

//////
(
{
	var  overtones;
	overtones =(1..10);
	SinOsc.ar(200*overtones,mul:1/overtones)*1/10!2;

}.play
)
///

but what if I want this to happen in a mix.or array fill which automatically created arrays , the result would be an array (define size Array first argument ) of arrays (fundamental freq multi by (1…10) and I get an exceeded number of interconnect buffers

//////
(
{
	var  overtones;
	overtones =(1..10);
	Array.fill(10,{SinOsc.ar(100*overtones,mul:1/overtones)})*1/10!2
}.play
)
///

Hello!

If what you did is reconstructed solely in sclang without server, it would be as follows:

(Post <<<
{
	var  overtones = (1..10);
	(Array.fill(10, {100 * overtones } ) * 1 / 10) !2
}.()
)

It returns:

[ [ [ 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0 ], [ 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0 ], [ 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0 ], [ 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0 ], [ 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0 ], [ 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0 ], [ 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0 ], [ 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0 ], [ 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0 ], [ 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0 ] ], [ [ 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0 ], [ 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0 ], [ 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0 ], [ 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0 ], [ 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0 ], [ 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0 ], [ 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0 ], [ 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0 ], [ 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0 ], [ 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0 ] ] ]-> Post

I think that the following is what you want to do:

{ Array.fill(10, { |i| i = i + 1; SinOsc.ar(100 * i, mul: 1 / i) } )!2 * 1/10 }.play

{ h = (1..10); SinOsc.ar(100 * h, mul: 1 / h / h.size).sum!2}.play // .sum could be got rid of.

{ h = (1..10); SinOsc.ar(100 * h, mul: 1 / h / h.size)!2}.play

Look at please the following code comparisons:

(1..10) ! 2 == ( Array.fill(10, { |i| i + 1 }) ! 2)

(1..10) ! 2 == (Array.series(10, 1, 1)!2)

To demonstrate the changing amplitudes of individual partials in a mixed sound:

{ n = 10; Array.fill(n, { |i| i = i + 1; SinOsc.ar(100 * i, mul: 1 / i * SinOsc.kr(1/30, 2pi / 10 * i).range(0, 1)) } )!2 * 1 / n }.play

{ h = (1..10); SinOsc.ar(100 * h, mul: 1 / h / h.size * SinOsc.kr(1/30, 2pi / 10 * h).range(0, 1))!2 }.play
1 Like