10. Server

Server

language나 다른 application으로부터 commands(OSC)를 받는 synthesis engine
synth server 와 its clients는 아마 같은 machine내에 있거나 network를 사이에 두고 있다.

synthesis definitions (SynthDef) 는 서버에 올려질수 있는것.
서버는 MIDI를 send/receive하는것이 아니고 client가 control messages를 서버에 보내는 것이다.

Server는 nodes (a network)의 tree를 사용하며 그 tree 들은 synths이거나 groups이다.

-Synth : a collection of Unit Generators that run together
-Group : a collection of nodes represented as a linked list
            (each node points to the next one).
      새로운 node는 시작의 head에 더해지거나 list끝에 써진다.
      
SynthDefs를 실행하기위한 명령은 중요하다. (예를들어 reverb unit에 들어가기 위한 signal이라면 반드시 reverb processing 이전에 만들어 져야 한다.). 이 명령은 nodes (head or tail)의 명령과 함께 결정된다.

Audio 또한 SynthDef로 부터 또 다른곳으로, Audio Buffers (an array of 128 channels)와 같은 Audio output device 불려질수 있다.  

Control information 또한 control buses (an array of 4096 buses)와 함께 전달된다.

{SinOsc.ar(440,mul: 0.1)}.play(s); // play and scope produce a synth definition

Synth(“temp__1966342724” : 1001)   // name and node of a synth definition (in post window)
      
이 구문은 다음의 evaluating 에 의해 응답된다.:
Synth(“temp__1966342724”)

**letters a – z 는 ‘global’ variables로 정의되서 결과를 저장시킬수 있다.

a = {SinOsc.ar(440,mul: 0.1)}.play(s);
b = {SinOsc.ar(660,mul: 0.1)}.play(s);
c = {SinOsc.ar(740,mul: 0.1)}.play(s);

a.free;
b.free;
c.free;

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

9. Filters

Filter.dumpClassSubtree

1.RLPF – resonant low pass filter
RHPF – resonant high pass filter
2.BPF – bandpass filter
3.Resonz – a two-pole resonant filter
4.Klank – a bank of resonators.
5.Formlet – FOF-like filter
6.Comb – filter

//———————————-
1. RLPF.ar(in, freq, rq, mul, add)        // q를 사용하는 대신 q의 note reciprocal를 사용한다.
                                     // rq : bandwidth/cutoffFreq
                                     // rq가 작을수록 constant freq를 가진 bw가 작아진다
{RLPF.ar(WhiteNoise.ar,550,0.1)}.scope
{RLPF.ar(WhiteNoise.ar,500,MouseX.kr(0.1,0.9))}.scope
{RLPF.ar(WhiteNoise.ar,MouseX.kr(100,1000),MouseY.kr(0.1,0.9))}.scope

//———————————-
2. 2nd order butterworth bandpass filter
     BPF.ar(in, freq, rq, mul, add)
{BPF.ar(WhiteNoise.ar,550,0.1,0.5)}.scope
{BPF.ar(WhiteNoise.ar,MouseX.kr(200,2000,0,0.5),MouseY.kr(0.001,0.5,1,0.5))}.scope

MouseX:        *kr(minval, maxval, warp, lag),
        warp = 0 : linear, 1:Exponential.
        lag        = lag factor to dezpipper cursor movement
        
//———————————-
3. Resonz – a two-pole resonant filter
        Resonz.ar(in,freq,rq, mul,add)

{Resonz.ar(WhiteNoise.ar,MouseX.kr(100,1000,0,0.05),MouseY.kr(0.001,0.5,1,0.5))}.scope
{Resonz.ar(WhiteNoise.ar(0.5),2000,0.1)}.scope
{BPF.ar(WhiteNoise.ar(0.5),2000,0.1)}.scope  // compare

{Resonz.ar(WhiteNoise.ar(0.5),2000,XLine.kr(1,0.001,8))}.play
//XLine.kr(start, end, dur, mul, add, doneAction):exponential line generator

// add three filters
(
        {Resonz.ar(WhiteNoise.ar(0.3),387,0.1)
        +
        Resonz.ar(WhiteNoise.ar(0.3),1207,0.1)
        +
        Resonz.ar(WhiteNoise.ar(0.3),2000,0.1)}.scope
)// not quite the same
(
        {Mix.ar(
                        Resonz.ar(
                                        WhiteNoise.ar(0.3),[387,1207,2007],0.1)
                                        )
                                        }.scope
)

//———————————-
4. Klank – a bank of resonators.
;어떤 object의 resonant modes를 만든다. (physical model of space or bodies)
Klank.ar(specificationsArrayRef, input, freqscale, freqoffset, decayscale)

specificationsArrayRef – a Ref to an Array of three Arrays :
        frequencies – an Array of filter frequencies.
        amplitudes – an Array of filter amplitudes, or nil. If nil, then amplitudes default to 1.0
        ring times – an Array of 60 dB decay times for the filters.
        
        if only two arrays in the array, that means that ring times (decay times) has been omitted
        
// ` 마크는 multi-channel expansion를 방지시킨다.

(
{
        Klank.ar(`[[100,200,300,400,500,600,700,800,900,1000],
                        [0.05,0.2,0.04,0.06,0.11,0.01,0.15,0.03,0.15,0.02]],
                        PinkNoise.ar(MouseX.kr(0.01,0.1)))
}.scope
)

(freqs and amps taken from Csound formant chart for alto o)
(
{
Klank.ar(
                `[[450,800,2830,3500,4950],
                        [0,-9,-16,-28,-55].dbamp],
                        PinkNoise.ar(0.01))
}.scope
)

//———————————-
5. Formlet FOF-like filter
Formlet.ar(in, freq, attacktime, decaytime, mul, add)
impulse response를 가진 resonant filter로서 exponential decay를 가진 sine wave와 유사하다.

attack과 decay times이 같으면 signal은 cancel된다.
attack > decay이면 , impulse response는 invert된다.

{Formlet.ar(PinkNoise.ar(0.1),1000,0.01,0.1)}.scope
{Formlet.ar(Impulse.ar(20,0.5),1000,0.01,0.1)}.scope// Impulse perhaps more ‘appropriate’ input
//Impulse.ar(freq, phase, mul, add)

band-limited impulse oscillator
Blip.ar(kfreq, knumharmonics,mul,add)
        (in other languages such as Csound, oftem called ‘buzz’)
{Blip.ar(100,100,0.5)}.scope
{Blip.ar(SinOsc.kr(5,0,20,300),1000,0.4)}.scope

modulating formant frequency
        with Blip as signal input
(
{
        var in;
        in = Blip.ar(SinOsc.kr(5,0,20,300), 1000, 0.1);
        Formlet.ar(in, XLine.kr(1500,700,8, doneAction: 2), 0.005, 0.04);
}.scope;
)

//———————————-
6. Comb filter
CombL.ar(in,maxdelaytime, delaytime, decaytime, mul, add);
CombL is with a linear delay
decayTime 은 60dB에 의해 decay되는 echoes시간

{CombL.ar(WhiteNoise.ar(0.1),0.01,0.01,0.2)}.scope
// modulating the delay time:
{CombL.ar(WhiteNoise.ar(0.1),0.01,XLine.kr(0.001,0.01,10,doneAction:2),0.2)}.scope

Karplus-Strong
Comb filter used for Karplus-Strong attempt:

69.midicps                                    // freq (midi to cps)
69.midicps.reciprocal                  // period

(
{
        var burstEnv, att = 0, dec=0.001;
        var delayTime, decayTime = 10;
        var midiPitch = 69;
        delayTime = midiPitch.midicps.reciprocal;//69–>440hz
        burstEnv = EnvGen.kr(Env.perc(att,dec));
        CombL.ar(WhiteNoise.ar(burstEnv), delayTime, delayTime, decayTime);
}.scope;
)

// trigger with Mouse
(
{
        var burstEnv, att = 0, dec = 0.05; //note increase of dec
        var delayTime, decayTime = 10;
        delayTime = MouseX.kr(36,74, lag: 0).midicps.reciprocal;//mouse controls pitch
        burstEnv = EnvGen.kr(Env.perc(att, dec), gate: MouseButton.kr(0,1,0));//mouse down control
        CombL.ar(WhiteNoise.ar(burstEnv), delayTime, delayTime, decayTime);
}.scope
)

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

8. Noise

8. Noise

{WhiteNoise.ar(0.5)}.scope
{PinkNoise.ar(0.4)}.scope//-3dB per octave
{BrownNoise.ar(0.5)}.scope//-6dB per octave
{GrayNoise.ar(0.4)}.scope//randomly flipping bits

{Dust.ar(MouseX.kr(10,500),mul:0.9)}.scope//마우스가 오른쪽으로 가면 펄스농도가 짙어진다.

Dust as trigger for an envelope:

    EnvGen.ar(envelope, gate, levelScale, levelBias, timeScale, doneAction)
       gate is usually a trigger for the envelope (triggers when <= 0 goes to > 0)
Env.perc(0.001,0.05).plot.test
(
{SinOsc.ar(440, mul:EnvGen.kr(Env.perc(0.001,1.0),
                                                Dust.kr(MouseX.kr(0.5,5))))
}.scope
)
//——————————————
메뉴얼 참조
Dust        : random impulses

Dust.ar(density, mul, add)
Generates random impulses from 0 to +1.
density – average number of impulses per second

MouseX: cursor ugen
superclass: UGen
        *kr(minval, maxval, warp, lag)
        
        minval, maxval        range between left and right end of screen
        warp                        mapping curve. 0 is linear, 1 is exponential (for freq or times e.g)
                                        alternative: ‘linear’, ‘exponential’
        lag                                lag factor to dezpipper cursor movement
//——————————————
http://csound.x-y.net
Ji Youn Kang,
Csound Max Community