20. 5synthdef using filters controlled with Ugens

//5synthdef using filters controlled with Ugens
//1
(
SynthDef(“filt1”,
        {|freq,mul0,mul,out|
        var in1;
        in1 = RHPF.ar(LFNoise2.ar(SinOsc.kr([10,50],0,mul0,(mul0+mul0)),0.5),freq.rand+100,XLine.kr(0.01,2,10,doneAction:2),mul);
        Out.ar(out,Pan2.ar(in1))
        }
        ).send(s)
)
a=Synth(“filt1”,[freq,5000,mul0,300,mul,0.8,out,0])
.a.free

//2
AbstractFunction
(
SynthDef(“filt2”,
        {|mul,out|
                var in1;
                in1 = BRF.ar(WhiteNoise.ar(0.5),LFTri.kr(2,0,1000,2500),LFTri.kr(2,0,0.9,1),mul);
                Out.ar(out,Pan2.ar(in1))
        }
                  ).send(s)
)
a=Synth(“filt2”,[mul,0.9,out,0])
a.free
//3
(
SynthDef(“filt3”,
                {|freq,mul,rq,out |
                var in1;
                in1 = Resonz.ar(Mix.fill(5,
                                                        {Dust.ar(freq+freq.rand,mul)}*1/5),LFTri.kr(1.0.rand,0,300,650),rq,mul);
//*** rrand(0.1,1.0).round(0.01)
                //in2 = Ringz.ar(Impulse.ar(Dust.kr(freq+freq.rand,mul),0,0.5),LFTri.kr(1.0.rand,0,300,650),rq,mul);
                Out.ar(out,Pan2.ar(in1))
                }
                ).send(s)
)

a=Synth(“filt3”,[freq,1000,mul,0.9,rq,2.0.rand,out,0])
a.free

//4
(
SynthDef(“filt4”,
                {|den,freq,mul,add,min,max|
                var in1,in2;
                in1=Mix.fill(8,
                                {RLPF.ar(Saw.ar(200+2000.rand,0.2),XLine.kr(mul,add,8),0.5)}*(0.4)/8);
                in2=Array.fill(8,
                                {Resonz.ar(Dust.ar(500,den),SinOsc.kr(freq.rand,0,mul,add),exprand(min,max),0.5)}*(0.4)/8);
                Out.ar(0,Pan2.ar(in1+in2))
                }
                ).send(s)
)
//****RLPF.ar(Mix)
a=Synth(“filt4”,[den,0.4.rand,freq,exprand(0.1,1.0),mul,1000,add,2500,min,1.0,max,2.0])
a.free

//5
(
SynthDef(“filt5”,
        {|freq,mul,freq2,q|
                var in1, in2;
                in1=Array.fill(8,
                                {RHPF.ar(Crackle.ar(XLine.kr(1,2,5),mul),freq2.rand,q,0.5)}*0.5/8);
                in2=RHPF.ar(Mix.fill(8,{Saw.ar(freq+freq.rand,0.8)}*0.5/8),SinOsc.kr(2.0.rand,0,freq2,((freq2*2)+100)),LFTri.kr(0.1,0,0.3,0.6,1.3),0.9) ;
                Out.ar(0,Pan2.ar(in1,in2))
                }
                ).send(s)
)
a=Synth(“filt5”,[freq, 1500, mul, 1, freq2,exprand(1500,4000),q,exprand(0.1,2.0)])
a.free

//6

(
SynthDef(“filt6”,
        { |freq1,freq2,q,den,start,end,dur |
        var in1, in2;
        in1=Array.fill(10,
                                                {RLPF.ar(Saw.ar(Dust.kr(50,freq1,freq2),0.5),XLine.kr(start,end,dur,doneAction:2),q,0.8)}*0.5/10) ;
        in2=Array.fill(10,
                                                {Resonz.ar(WhiteNoise.ar(den),XLine.kr(start,end,dur,doneAction:2),q,0.9)}*0.8/10) ;
        Out.ar(0,Pan2.ar(in1,in2))
        }
        ).send(s)
)

a=Synth(“filt6”,[freq1,300.rand+100,freq2,500.rand+600,q,exprand(0.01,2),den,exprand(0.1,0.8),start,500,end,1000,dur,5])
a.free

//7

(
SynthDef(“filt7”,
        { |freq1,freq2,q,den,start,end,dur |
        var in1, in2;
        in1=Array.fill(10,
                        {RLPF.ar(Saw.ar(Dust.kr(50,freq1,freq2),0.5),XLine.kr(start,end,dur,doneAction:2),q,0.8)}*0.1/10) ;
        in2=Mix.fill(10,
                        {Resonz.ar(SinOsc.ar(LFNoise0.kr([20,35],400,800),0,0.5),XLine.kr(start,end,dur,doneAction:2),q,0.9)}*0.1/10) ;
        Out.ar(0,Pan2.ar(in1,in2))
        }
                 ).send(s)
)

a=Synth(“filt7”,[freq1,300.rand+100,freq2,500.rand+600,q,exprand(0.01,2),den,exprand(0.1,0.8),start,500,end,1000,dur,8])

//——————————————
http://csound.x-y.net
Ji Youn Kang,
Csound Max Community

19. 5rm and 5 mix using Array or Mix.fill

//5rm and 5 mix(at least 2 using Array or Mix.fill)

(
var input1,input2,rm;
{
input1=SinOsc.ar(SinOsc.kr(0.1,0,300,1700),0,0.3);
input2=LFTri.ar(LFTri.kr(0.4,0,500,2500),0,0.3);
rm=Pan2.ar(input1 ring1: input2)}.scope
)
/*
ring2: ring3: ring4:
*/
//rm1
(
var in1, in2, rm;
{
in1=SinOsc.ar(400,0,0.3);
in2=SinOsc.ar(500,0,0.1);
rm=Pan2.ar(in1 ring1:in2)}.scope
)

//rm2
(
var in1, in2, rm;
{in1=LFNoise0.ar(400,0.3);
in2=SinOsc.ar(401,0,0.3);
rm=Pan2.ar(in1 ring1:in2)}.scope
)
//rm3
(
        (
        var in1, in2, rm;
        a={|den=0.01,mul=0.5|
                {in1 = WhiteNoise.ar(den);
                 in2 = LFTri.ar(0.5,0,mul);
                 rm = Pan2.ar(in1 ring1:in2)}
               }
         )
)
{a.value}.scope
//rm4
(
var in1, in2, rm;
a={|freq=1000,mul1=0.3,mul2=0.01|
in1=Array.fill(4,{Saw.ar(Dust.kr(freq.rand+100,1000,2000),mul1.rand+0.1)});
in2=LFNoise0.ar(50,mul2);
rm={Pan2.ar(in1 ring1:in2)}!2
        }
)
{a.value}.scope
//rm5
(
var in1, in2, rm;
{|freq1=100,mul1=0.5,freq2=101,mul2=0.5,mul3=0.5|
in1=Mix.fill(2,{SinOsc.ar(freq1.rand,1pi.rand,mul1)
                                        +
                                   LFTri.ar(freq2.rand,0,mul2)*0.5/2});
in2=WhiteNoise.ar(mul3);
rm={Pan2.ar(in1 ring1:in2)}}.scope
)

//mix1
(
var a, b, m;
        x ={|freq1 = 440, freq2=441|
                a=Mix{[SinOsc.ar(freq1,0,0.3), SinOsc.ar(freq2,0,0.3)]};
                b=Mix{[Saw.ar(330,0.3),Saw.ar(331,0.3)]};
                m={Pan2.ar(a+b)}//****
        }
)
{x.value}.scope
{x.value(freq1:390,freq2:872)}.scope                

//mix2
(
var a, b, m;
        z ={|den = 400, den2=10, min=100, max=1000|
                a=Mix.fill(5,{Dust.ar(den,0.5)+Saw.ar(exprand(min,max))}*0.1/5);
                b=Mix.fill(5,{Dust.ar(den2,0.5)+Saw.ar(31,0.3)});
                m=(Mix([a,b])*0.5)!2//**********
        }
)
{z.value}.scope

//mix3
(
var a, b, m;
        y={| size=4, size2=9, den1=0.3, den2=0.01,freq=400,freq2=50,rq=0.01,rq2=0.1|
        a=Mix.fill(size, {Resonz.ar(WhiteNoise.ar(den1.rand),freq+freq.rand,rq)});
        b=Mix.fill(size2, {Resonz.ar(WhiteNoise.ar(den2.rand),freq2+freq2.rand,rq2.rand)});
        m=(Mix([a,b])*3)!2
        }
)
{y.value}.scope

//mix4
(
var a, b, m;
        u={| size=4, size2=9, den1=0.3, den2=0.01,freq=400,rq=0.01,rq2=0.1,start=1.5,end=0.01,dur=5|
        a=Array.fill(size, {Resonz.ar(WhiteNoise.ar(den1.rand),freq+freq.rand,XLine.kr(end,start,dur))});
        b=Array.fill(size2, {Resonz.ar(WhiteNoise.ar(den2.rand),(freq*1/2)+(freq*1/2).rand,XLine.kr(start,end,dur))});
        m=(Mix([a,b])*0.5)!2
        }
)
{u.value}.scope

//mix5
(
var a,b,c,m;
                i={|start=10000,end=3,dur=5, freq=500.0,decay=1.0|
                a=Array.fill(10, {Ringz.ar(Impulse.ar(freq+freq.rand,0,0.5),freq*1/2,decay.rand,0.5)}*0.1/10);
                b=Mix.fill(10,{Ringz.ar(Dust.ar(XLine.kr(start,end,dur,0.1),0.5),freq,decay.rand,0.5)}*0.1/10);
                c=Mix.fill(10,{SinOsc.ar(freq-freq.rand,0,0.4)}*0.1/10);
                m=(Mix([a,b,c]))!2
                    }
)        
{i.value}.scope

//——————————————
http://csound.x-y.net
Ji Youn Kang,
Csound Max Community

18. 5 different example using argument with Mix and Array

//1
(
a={|freq = 1000, decaytime = 0.5, mul = 0.5|

        {Ringz.ar(WhiteNoise.ar(0.05),freq.rand,decaytime,mul)
        }!4
        }
)
{a.value}.scope
{a.value(500)}.scope
{a.value(freq:500, mul:0.5.rand)}.scope

//2
(
b={|size = 2, density=100, freq=1,decaytime = 2, mul=0.1, mul2=0.5|
                        Mix.fill(size,{Ringz.ar(Dust.ar(density,mul/size)
                                                 +
                                                SinOsc.ar(freq,0,mul2/size))
                                                }
                                        )!4
        }
)
{b.value}.scope
{b.value(density:10)}.scope                
{b.value(freq:1000.0.rand,mul2:0.005)}.scope

//3        
(
c={|size = 2, density=100, freq=1,min=100,max=4000, mul=0.05|
                        Mix.fill(size,
                                                {Saw.ar(exprand(min,max)
                                                 +
                                                SinOsc.kr(freq,0,mul)*(0.1/size))
                                                })
        }
)

(
c={|size = 2, density=100, freq=1,min=100,max=4000, mul=0.05|
                        Mix.fill(size,
                                                {Saw.ar(exprand(min,max))
                                                 +
                                                SinOsc.ar(freq,0,mul)
                                                *(0.1/size)
                                                })!8
        }
)
{c.value}.scope
{c.value(freq:5,mul:0.3)}.scope
{c.value(min:100,max:5000.0.rand,mul:0.05)}.scope

//4-correct
(
d={| size=2,den=0.005, freq=100, sinmul=1000,sinadd=1100|
                Mix.fill(size,{WhiteNoise.ar(den)
                                                +
                                                Saw.ar(
                                                Array.fill(5,{SinOsc.kr(freq.rand,0,sinmul,sinadd)
                                                })*0.1/5)                        
                                                }*0.1/size)!2
                                                }
)
//correct
(
d={| size=2,den=0.005, freq=100, sinmul=500,sinadd=1000|
                Mix.fill(size,{WhiteNoise.ar(den)
                                                +
                                        Saw.ar(Array.fill(
                                                                          5,{
                                                                        Saw.ar(freq.rand,sinmul.rand,sinadd)
                                                                                }*0.1/5
                                                                          )
                                                        )*0.1/size
                                                }
                                )!2
        }
)
(
a={Array.fill(3,{SinOsc.ar([220,440,660].choose,0,[0.1,0.3,0.2].choose)})}
)
{a.value}.scope
{d.value}.scope
{d.value(freq:20)}.scope
{d.value(den:0.001,sinmul:500.rand,sinadd:exprand(510,2000))}.scope

//5-correct
(
e={| size=2, den=10, freq=1000|
                Mix.fill(size,{Dust.ar(den,0.2)
                                                +
                                                SinOsc.ar(Array.fill(8,
                                                                                {SinOsc.kr(freq,0,100,1000)}
                                                ))}*0.1/size)!2
                                                }
)
{e.value}.scope
{e.value(den:1000.0.rand, freq:10.0.rand)}.scope
//6
(
f={|den=0.5, freq=1000, ffreq=1000,mul=0.5|
                Mix([WhiteNoise.ar(den),
                     Resonz.ar(Saw.ar(SinOsc.kr(freq,0,0.5)),
                                                ffreq,exprand(0.1,1.0),mul)
                                                ])!2
                                                }
)
{f.value}.scope
{f.value(den:0.1,ffreq:4000.0.rand)}.scope

//——————————————
http://csound.x-y.net
Ji Youn Kang,
Csound Max Community