Here’s is a piece of code from James Mccartney
Is there a reason why he is using an array fill in a mix.ar and not just mix.fill
I Isolated the piece of code ( varaible s ) and it’s identical when just using mix.fill.
I am aware that older supercollider version sused mix.ar and that these are now replaced with mix
`///////origal code by James McCartney
(
{
var s, z, y;
// 10 voices of a random sine percussion sound :
s = Mix.ar(Array.fill(10, { Resonz.ar(Dust.ar(0.2, 50), 200 + 3000.0.rand, 0.003)}) );
// reverb predelay time :
z = DelayN.ar(s, 0.048);
// 7 length modulated comb delays in parallel :
y = Mix.ar(Array.fill(7,{ CombL.ar(z, 0.1, LFNoise1.kr(0.1.rand, 0.04, 0.05), 15) }));
// two parallel chains of 4 allpass delays (8 total) :
4.do({ y = AllpassN.ar(y, 0.050, [0.050.rand, 0.050.rand], 1) });
// add original sound to reverb and play it :
s+(0.2*y)
}.scope
)
///////////////////// Isolated the first line variable s
(
{
Mix.ar(Array.fill(10, { Resonz.ar(Dust.ar(0.2, 50), 200 + 3000.0.rand, 0.003)}) )!2
}.play
)
/////////Removing the array fill and only using the mix.fill
(
{
Mix.fill(10,{Resonz.ar(Dust.ar(0.2, 50),200 + 3000.0.rand,0.003)})!2;
}.play
)
/////////////////
`
Here are two examples from the help file , they do exactly the same .
So why use array.fill inside mix when mix.fill can do the same ?
(
play({
Mix.new( Array.fill(8, { SinOsc.ar(500 + 500.0.rand, 0, 0.05) }) );
}))
(
play({
Mix.fill(8, { SinOsc.ar(500 + 500.0.rand, 0, 0.05) });
}))
P.S.
I should have merged this with the previous topic about mix and array,
Actually, there has been a suggestion to deprecate Mix and recommend myArray.sum
instead.
Mix could be left over from SC2 – I dabbled in SC2 for a couple of weeks before moving to SC Server, so my knowledge of SC2 is not as extensive (and a couple of decades in the rearview). Mix might have provided some optimization in SC2…? But I’ll never know b/c I won’t have time to set up an OS9 emulator just to check 
In any case, in current SC, there is no difference between Mix.fill
and Array.fill().sum
, and there’s nothing Mix does that can’t be done with more fundamental objects. (That is, Mix is a mess, and you should expect to find legacy code around it that is a bit messy.)
Part of this question seems to be based on an assumption that a different way of writing the operation reflects a functional difference between the operations. For good or ill, SuperCollider doesn’t hold to that assumption. (It’s a common complaint of new users that there are “too many ways to do things.”)
hjh
If I may, this is one of the features that make SuperColiider super interesting and creative. Mixing the sonic art with the art of coding. 
1 Like