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

Leave a Comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.