class:: Gendy5
summary:: Dynamic stochastic synthesis generator
related:: Classes/Gendy1, Classes/Gendy2, Classes/Gendy3, Classes/Gendy4
categories:: UGens>Generators>Stochastic


Description::

This is a non-interpolating version of Nick Collins's link::Classes/Gendy1:: UGen.  My idea was to use it as a kind of sample and hold jitter UGen.  It works quite well in that context, and is not a bad sound generator in its own right.

warning::
if you have lots of CPs and you have fast frequencies, the CPU cost goes up a lot because a new CP move happens every sample!
::


classmethods::

method::ar, kr
see link::Classes/Gendy1#*ar:: for explanation of parameters.


Examples::

code::
//defaults
{Pan2.ar(Gendy5.ar)}.play

//sorry Xenakis!!!
(
var scale, buffer;
scale = FloatArray[0, 2, 4, 6, 7, 9, 11];
buffer = Buffer.alloc(s, scale.size,1, {|b| b.setnMsg(0, scale) });

play({
	var mix;
	mix =
	SinOsc.ar(
		(
			DegreeToKey.kr(
				buffer.bufnum,
				Gendy5.kr(minfreq:1, maxfreq:8, ampscale:0.1, durscale:0.1, initCPs:3, mul:7.5, add:7.5),
				12,
				1,
				60
			)
			+ LFNoise1.kr([3,3], 0.04)
		).midicps,
		0).cubed * 0.1
	+ RLPFD.ar(LFPulse.ar([48,55].midicps, 0.15),
		Gendy4.kr(2, 2, 1, 1, 0.1, 0.2, 0.1, 0.1, 2, mul:10, add:72).midicps, 0.6, 0.2);
	CombN.ar(mix, 0.31, 0.31, 2, 0.2, mix)
})
)

//wandering bass/ powerline
{Pan2.ar(Gendy5.ar(1,1,1.0,1.0,30,100,0.3,0.05,5))}.play

//play me
{Pan2.ar(RLPF.ar(Gendy5.ar(2,3,minfreq:20, maxfreq:MouseX.kr(100,1000), durscale:0.0, initCPs:40), 500,0.3, 0.2), 0.0)}.play

//scream! - careful with your ears for this one!
(
{
var mx, my;

mx= MouseX.kr(220,440);
my= MouseY.kr(0.0,1.0);

Pan2.ar(Gendy5.ar(2,3,1,1,minfreq:mx, maxfreq:8*mx, ampscale:my, durscale:my, initCPs:7, mul:0.3), 0.0)}.play
)


//1 CP = random noise effect
{Pan2.ar(Gendy5.ar(initCPs:1))}.play

//2 CPs = suudenly an oscillator (though a fast modulating one here)
{Pan2.ar(Gendy5.ar(initCPs:2))}.play


//used as an LFO
(
{Pan2.ar(SinOsc.ar(Gendy5.kr(2,4,SinOsc.kr(0.1,0,0.49,0.51),SinOsc.kr(0.13,0,0.49,0.51), 3.4,3.5, SinOsc.kr(0.17,0,0.49,0.51), SinOsc.kr(0.19,0,0.49,0.51),10,10,50, 350), 0, 0.3), 0.0)}.play
)

DegreeToKey

//wasp
{Pan2.ar(Gendy5.ar(0, 0, SinOsc.kr(0.1, 0, 0.1, 0.9),1.0, 50,1000, 1,0.005, 12, 12, 0.2), 0.0)}.play


//modulate distributions
//change of pitch as distributions change the duration structure and spectrum
{Pan2.ar(Gendy5.ar(MouseX.kr(0,7),MouseY.kr(0,7),mul:0.2), 0.0)}.play


//modulate num of CPs
{Pan2.ar(Gendy5.ar(knum:MouseX.kr(1,13),mul:0.2), 0.0)}.play


//Gendy into Gendy...with cartoon side effects
{Pan2.ar(Gendy5.ar(maxfreq:Gendy5.kr(5,4,0.3, 0.7, 0.1, MouseY.kr(0.1,10), 1.0, 1.0, 5,5, 500, 600), knum:MouseX.kr(1,13),mul:0.2), 0.0)}.play


//use SINUS to track any oscillator and take CP positions from it, use adparam and ddparam as the inputs to sample
{Pan2.ar(Gendy5.ar(6,6,LFPulse.kr(100, 0, 0.4, 1.0), SinOsc.kr(30, 0, 0.5),mul:0.2), 0.0)}.play


//try out near the corners especially
{Pan2.ar(Gendy5.ar(6,6,LFPulse.kr(MouseX.kr(0,200), 0, 0.4, 1.0), SinOsc.kr(MouseY.kr(0,200), 0, 0.5),mul:0.2), 0.0)}.play


//texture
(
{
Mix.fill(10,{
var freq;

freq= rrand(130,160.3);
Pan2.ar(SinOsc.ar(Gendy5.ar(6.rand,6.rand,SinOsc.kr(0.1,0,0.49,0.51),SinOsc.kr(0.13,0,0.49,0.51),freq ,freq, SinOsc.kr(0.17,0,0.49,0.51), SinOsc.kr(0.19,0,0.49,0.51), 12, 12, 200, 400), 0, 0.1), 1.0.rand2)
});
}.play
)

//wahhhhhhhh- try durscale 1.0 and 0.0 too
(
{Pan2.ar(
CombN.ar(
Resonz.ar(
Gendy5.ar(2,3,minfreq:1, maxfreq:MouseX.kr(10,700), durscale:0.1, initCPs:10),
MouseY.kr(50,1000), 0.1)
,0.1,0.1,5, 0.6
)
, 0.0)}.play
)


//overkill
(
{
var n;
n=10;

Mix.fill(n,{
var freq, numcps;

freq= rrand(130,160.3);
numcps= rrand(2,20);
Pan2.ar(Gendy5.ar(6.rand,6.rand,1.0.rand,1.0.rand,freq ,freq, 1.0.rand, 1.0.rand, numcps, SinOsc.kr(exprand(0.02,0.2), 0, numcps/2, numcps/2), 0.5/(n.sqrt)), 1.0.rand2)
});
}.play
)





//another traffic moment
(
{
var n;
n=10;

Resonz.ar(
Mix.fill(n,{
var freq, numcps;

freq= rrand(50,560.3);
numcps= rrand(2,20);
Pan2.ar(Gendy5.ar(6.rand,6.rand,1.0.rand,1.0.rand,freq ,freq, 1.0.rand, 1.0.rand, numcps, SinOsc.kr(exprand(0.02,0.2), 0, numcps/2, numcps/2), 0.5/(n.sqrt)), 1.0.rand2)
})
,MouseX.kr(100,2000), MouseY.kr(0.01,1.0))
;
}.play
)




(
{
var n;
n=15;

Resonz.ar(
Mix.fill(n,{
var freq, numcps;

freq= rrand(330,460.3);
numcps= rrand(2,20);
Pan2.ar(Gendy5.ar(6.rand,6.rand,1.0.rand,1.0.rand,freq,MouseX.kr(freq,2*freq), 1.0.rand, 1.0.rand, numcps, SinOsc.kr(exprand(0.02,0.2), 0, numcps/2, numcps/2), 0.5/(n.sqrt)), 1.0.rand2)
})
,MouseX.kr(100,2000), MouseY.kr(0.01,1.0)
)

}.play;
)
::
