[chuck-users] list oriented ways to make this more simple?

2g electriclightheads at gmail.com
Tue Aug 28 06:33:05 EDT 2007


thanks!

i wanted sun & moon to maintain its own world @ func
and have one's overtone behave as altered note of another
so i rewrote things in a rather primitive style than the smartest way
you told me

i couldn't get what you meant about arrays in func
so i just directly used things initiated outside of the func loops

it seems to be doing what i want it to do
but even this seems to be reaching the capacity of the cpu or the ram
of my iBookG4
7 osc for each planet seems to make the traffic too heavy
playing this sa.ck also results into some click kind of noise
even though i chose envelope oriented way to prevent those

am trying to keep the sum of gain become lower than 1.0
by birnging in the parm dick for each planet
i think this is doing okay
or am i taking something wrong?


sa.ck:

//how many thangs do we need to become a planet?
5 => int thangs;

27.5 * Math.pow(2.0,(3.0/12.0)) => float oil_sun;
27.5 * Math.pow(2.0,(5.0/12.0)) * 7.0/8.0 => float oil_moon;

//is my sun huge?
.7 => float sun_is_big;
1.0 - sun_is_big => float moon_is_small;

//how big is his main thang?
.5 => float dick_sun;
.5 => float dick_moon;

SinOsc sun_thangs[thangs];
SinOsc moon_thangs[thangs];

Pan2 sun_pans[thangs];
Pan2 moon_pans[thangs];

Envelope sun_envs[thangs];
Envelope moon_envs[thangs];

for( 0=> int n; n< thangs; n++)
{
	sun_thangs[n] => sun_envs[n] => sun_pans[n] => dac;
	moon_thangs[n] => moon_envs[n] => moon_pans[n] => dac;
}

oil_sun * Std.rand2(16,8) / 8.0 => sun_thangs[0].freq;
oil_moon * Std.rand2(16,8) / 8.0 => moon_thangs[0].freq;
sun_is_big * dick_sun => sun_pans[0].gain;
moon_is_small * dick_moon => moon_pans[0].gain;

for( 1=> int n; n< thangs; n++)
{
	sun_is_big * (1.0 - dick_sun)/(thangs-1) => sun_pans[n].gain;
	moon_is_small * (1.0 - dick_moon)/(thangs-1) => moon_pans[n].gain;
}

fun void ga()
{
	while(true)
	{
		oil_moon * Std.rand2(16,8) / 8.0 => moon_thangs[0].freq;
		oil_moon * Std.rand2(16,8) / 4.0 => moon_thangs[1].freq;
		oil_moon * Std.rand2(16,8) / 4.0 => moon_thangs[2].freq;
		sun_thangs[0].freq() * Std.rand2(16,8) / 4.0 => moon_thangs[3].freq;
		sun_thangs[0].freq() * Std.rand2(16,8) / 4.0 => moon_thangs[4].freq;
		Std.rand2f(-0.5,0.5) => moon_pans[0].pan;
		75::ms => moon_envs[0].duration;
		for( 1=> int n; n< thangs; n++)
		{
			Std.rand2f(-1.0,1.0) => moon_pans[n].pan;
			75::ms => moon_envs[n].duration;
		}
		moon_envs[0].keyOn();
		300::ms => now;
		moon_envs[0].keyOff();
		moon_envs[1].keyOn();
		moon_envs[2].keyOn();
		300::ms => now;
		moon_envs[1].keyOff();
		moon_envs[2].keyOff();
		moon_envs[3].keyOn();
		moon_envs[4].keyOn();
		300::ms => now;
		moon_envs[3].keyOff();
		moon_envs[4].keyOff();
		300::ms => now;
		moon_envs[1].keyOn();
		moon_envs[3].keyOn();
		300::ms => now;
		moon_envs[1].keyOff();
		moon_envs[3].keyOff();
		moon_envs[2].keyOn();
		moon_envs[4].keyOn();
		300::ms => now;
		moon_envs[2].keyOff();
		moon_envs[4].keyOff();
		moon_envs[0].keyOn();
		moon_envs[1].keyOn();
		moon_envs[2].keyOn();
		moon_envs[3].keyOn();
		moon_envs[4].keyOn();
		300::ms => now;
		moon_envs[0].keyOff();
		moon_envs[1].keyOff();
		moon_envs[2].keyOff();
		moon_envs[3].keyOff();
		moon_envs[4].keyOff();
	}
}

fun void ma()
{
	while(true)
	{
		7::second => now;
		Std.rand2f(45.0,75.0) => oil_sun;
		Std.rand2f(45.0,75.0) => oil_moon;
	}
}

fun void pa()
{
while(true)
	{
		oil_sun * Std.rand2(16,8) / 8.0 => sun_thangs[0].freq;
		oil_sun * Std.rand2(16,8) / 4.0 => sun_thangs[1].freq;
		oil_sun * Std.rand2(16,8) / 4.0 => sun_thangs[2].freq;
		moon_thangs[0].freq() * Std.rand2(16,8) / 4.0 => sun_thangs[3].freq;
		moon_thangs[0].freq() * Std.rand2(16,8) / 4.0 => sun_thangs[4].freq;
		Std.rand2f(-0.5,0.5) => sun_pans[0].pan;
		75::ms => sun_envs[0].duration;
		for( 1=> int n; n< thangs; n++)
		{
			Std.rand2f(-1.0,1.0) => sun_pans[n].pan;
			75::ms => sun_envs[n].duration;
		}
		sun_envs[0].keyOn();
		555::ms => now;
		sun_envs[0].keyOff();
		sun_envs[1].keyOn();
		sun_envs[2].keyOn();
		555::ms => now;
		sun_envs[1].keyOff();
		sun_envs[2].keyOff();
		sun_envs[3].keyOn();
		sun_envs[4].keyOn();
		555::ms => now;
		sun_envs[3].keyOff();
		sun_envs[4].keyOff();
		555::ms => now;
		sun_envs[0].keyOn();
		sun_envs[1].keyOn();
		sun_envs[2].keyOn();
		sun_envs[3].keyOn();
		sun_envs[4].keyOn();
		555::ms => now;
		sun_envs[0].keyOff();
		sun_envs[1].keyOff();
		sun_envs[2].keyOff();
		sun_envs[3].keyOff();
		sun_envs[4].keyOff();
	}
}

spork ~ ga();
spork ~ ma();
spork ~ pa();

while( true ) {
	3333::ms => now;
}

On 8/27/07, Kassen <signal.automatique at gmail.com> wrote:
> ========================
> 10 => int foo;
> //some oscilators
> SinOsc suns_moons[foo];
>
> //as many pans
> Pan2 pans[foo];
>
> //now we automate and from here on we save lots of lines
> for( 0=> int n; n< foo; n++)
> {
> //make connections
> suns_moons[n] => pans[n] => dac;
> //set gain
> 1 => pans[n].gain;
> }
> ===================
>
>
> From there on you could make the suns even and the moons odd numbers, that
> might work nicely, you can sort odd from even using "if(n%2)" because
> modulus n will always resolve to either 0 or 1 for a positive n. Arrays of
> Ugens are a great way of structuring your code if you do a lot of monotonous
> stuff. Another aproach might be making a class that conists of a sun-moon
> pair and making a array of those.
>
> As for the functions; you could pass those a reference to the arrays used or
> hardcode their name in (less versatile). Because of the way the namespace
> works it would be possible and a good idea to use "foo" again in the
> functions or use the .cap() method that arrays have, this would make it
> easier to create whole solar systems by increasing one number.

-- 
2g
http://micro.ispretty.com


More information about the chuck-users mailing list