17. 6 different resonant filters 예제

6 different resonant filters using as a trigger Dust, Impulse, and SinOsc. rq should be modulated with MouseX, XLine, and other UGens.(with doneAction:2)

{Ringz.ar(Dust.ar(5,0.3),SinOsc.kr(0.5,0,500,1000),XLine.kr(0.1,0.5,5,doneAction:2),0.5)}.scope

{Resonz.ar(Dust.ar(1000,0.5),SinOsc.kr(0.5,0,500,1000),XLine.kr(0.1,3,8,doneAction:2),0.8)}.scope

{Resonz.ar(Impulse.ar(100,0,0.8),LFTri.kr(0.5,mul:1000,add:2000),XLine.kr(0.01,5,10,doneAction:2),1)}.scope

{Resonz.ar(WhiteNoise.ar(0.5),SinOsc.kr(0.1,0,2000,5000),MouseX.kr(0.001,2,1),0.3)}.scope

{Resonz.ar(WhiteNoise.ar(0.5),MouseY.kr(1000,4000,1),MouseX.kr(0.01,2,1),0.3)}.scope

{Resonz.ar(Dust.ar(100,0.5),MouseY.kr(100,10000,1),MouseX.kr(0.01,1,1),0.8)}.scope

{Resonz.ar(WhiteNoise.ar(0.5),MouseY.kr(100,3000,1),MouseX.kr(0.01,1,1),0.8)}.scope

{Resonz.ar(WhiteNoise.ar(0.8),XLine.kr(1000,50,1.8,doneAction:2),XLine.kr(1,0.01,2,doneAction:2),0.5)}.scope

{Resonz.ar(Impulse.ar(500,0,0.8),SinOsc.kr(10,0,200,800),XLine.kr(0.01,0.8,5,doneAction:2),0.5)}.scope

{Ringz.ar(WhiteNoise.ar(0.05),SinOsc.kr(0.5,0,500,2500),XLine.kr(2,0.1,10,doneAction:2),0.1)}.scope

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

16. Oscillator예제

{SinOsc.ar(LFNoise0.kr(100, LFNoise0.kr(5,500,550),550),0,0.5)}.scope
//Freq Mod:100*5/sec, random freq range 5000, amp: 0.5

{SinOsc.ar(LFNoise0.kr(100,100,150),0,0.5)}.scope
//Freq Mod: 100/sec, random freq range 100, amp: 0.5

{SinOsc.ar(SinOsc.kr(1,0,100,300),0,0.5)}.scope
//Freq : 1/sec, 250~350  (350-250)/2+300

{LFNoise0.ar(1000.rand,0.5)}.scope

{LFTri.ar(80.midicps,0,-11.dbamp)}.scope

{LFTri.ar(LFNoise0.kr(100,500,1000), mul: 0.1)}.scope
//Freq : 1/sec, Random range 500, from 500~1500 mul:0.1
{LFTri.ar(LFNoise0.kr(MouseY.kr(100,1000,1),500,1000), mul: 0.5)}.scope

{LFTri.ar(SinOsc.kr(LFNoise0.kr(10,100,500),0,500,500),mul: 0.5)}.scope
//Freq : 10,random100/sec(?), range 250~750), mul: 0.5

{LFTri.ar(SinOsc.kr(LFNoise0.kr(10,100,1000),0,500, LFNoise0.kr(1000,500,1000),mul:0.5))}.scope

{Saw.ar(440,Dust.kr(10,0.8))}.scope

{Saw.ar(MouseY.kr(100,1000,exponential),Dust.kr(100,0.8))}.scope
//freq: 100~1000, amp:0.8, Changing Density:100/sec
{SinOsc.ar(Dust.kr(1000,1000,1000),0,0.5)}.scope
//Noise. 1000Density, 1000 pulses

{Dust.ar(SinOsc.kr(10,mul:1000,add:1000),mul:0.8)}.scope
//Density:10/sec,til 1000, mul:0.8

{Dust.ar(100,1)}.scope

{Pulse.ar(10,SinOsc.kr(1,0,0.25,0.25),0.5)}.scope
{Pulse.ar(SinOsc.kr(0.1,0,1000),0.25,0.5)}.scope
{Pulse.ar(SinOsc.kr(0.1,0,100),SinOsc.kr(1,0,0.25,0.25),0.8)}.scope

{Pulse.ar(SinOsc.kr(0.5,0,100,100),SinOsc.kr(1,0,0.25,0.5),0.5)}.scope
//freq: for 2/1/sec til 100,

{LFNoise2.ar(1000,0.1)}.scope

{SinOsc.ar(SinOsc.ar(MouseY.kr(100,1000), 0, LFNoise1.kr(MouseX.kr(100,1000), 100,340)),0.6)}.scope
{SinOsc.ar(Pulse.ar(freq: 15, mul: 200, add: 1000), mul: 0.5)}.scope

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

15.Recording in real time/Buffers

15.Recording sound files in real time/Bufffer
파일에 recording을 하는 방법으로 서버윈도우의 버튼을 이용할수 있다.

(
r = Routine({
        {Synth(noiseWindow,
                        [cf, rrand(500,2500), rq, 0.005,
                        amp,1,dur,rrand(0.5,3)]);
                rrand(0.01,0.1).yield;
                }.loop
})
)
                        
//서버 윈도우의 다음 버튼을 누른다.
  
   prepare rec
   record
   stop

//텍스트를 이용하여 레코딩을 컨트롤한다.
r.play
r.stop
r.reset.play

//레코딩 포멧 설정하기
(
s.recSampleFormat=”int24″;//”int8″, “int16”, “int24”, “int32”, “float”, “double”, “mulaw”, “alaw”
s.recHeaderFormat=”aidd”;//”aiff”, “next”, “wav”, “ircam””, “raw”
s.recHannels = 1;//mono

//파일이름 설정하기
s.prepareForRecord(“recordings/test1.aif”)
)

//레코딩과 플레이를 동시에

(
s.record;
r.reset.play;   // )

// 멈추기
r.stop;  // 레코딩을 멈추기 전에 플레잉이 끝날때 까지 기다려야 한다.
s.stopRecording;

//——————————————
Buffers

Buffers는 32-bit의 floating point values를 가진 array이다.
Buffers는 서버에 있기 때문에 synths에 의해 사용된다. are on the server so that they can be used by synths.

Buffers는 allocated되거나 filled되거나 freed되어야 한다.
Buffers가 allocated, loaded, freed됨과 동시에 synthesis를 실행시킬수 있다.
Buffers는 wave tables, sample buffers, delay lines등으로 사용될수 있다.
서버한의 buffer의 수는 boot time에 설정된다.

        Server.internal.options.numBuffers

Buffers는 0으로 시작한다.

buffer messages

[Server-Command-Reference] 참고        

다음은 몇개의 buffer command들:

/b_alloc //buffer space를 allocate
   buffer number
   number of frames
   number of channels (optional, default = 1)
   optional OSC message to execute on conclusion
  
/b_allocRead  //buffer space할당하고 sound file를 읽음
   buffer number
   path name of a sound file (as a string)
   starting frame (optional, default = 0)
   number of frames to read (optional, default = 0)
   optional OSC message upon completion
  
/b_free
   buffer number
   optional OSC message upon completion
  
/b_close
   buffer number (to close a soundfile)
  
s.sendMsg(“/b_allocRead”,0,”sounds/a11wlk01-44_1.aiff”)
s.sendMsg(“/b_close”,0)
s.sendMsg(“/b_free”,0)

//——————————————
PlayBuf

PlayBuf : a sample (buffer) playback oscillator
  (numChannels, bufnum, rate, trigger, startPos, loop)
  
  rate = 1 is no change, 2 is one octave up, …
  loop = 1 is true, 0 is false

s.sendMsg(“/b_allocRead”,0,”sounds/a11wlk01-44_1.aiff”) // allocate and read buffer 0

{ PlayBuf.ar(1,0,1,loop: 1) }.scope

s.sendMsg(“/b_allocRead”,0,”sounds/sax1.aiff”) // allocate buffer again and read in a different file (if available)

s.sendMsg(“/b_free”,0)  // free buffer when finished with it
//——————————————

Buffer class

Buffers 는 또한 Buffer class와 함께 접근될수있다. (메세지 스타일보다 편하게 사용될수 있음)

Buffer.read  buffer space할당하고 sound file를 읽음

         b = Buffer.read(s, “sounds/a11wlk01-44_1.aiff”);

        { PlayBuf.ar(1, b.bufnum, 1, loop: 1) }.scope
        
        // Mouse control of rate (transposition)

        { PlayBuf.ar(1, b.bufnum, MouseX.kr(0.5,2), loop: 1) }.scope  
                              
b.bufnum   // returns buffer number
b.numChannels   // returns the number of channels in the buffer

b.free  // return the memory and free buffer ID, IMPORTANT

(Memory 사용량은 Terminal application에서 체크 (using top))
//——————————————

BufRateScale

buffer로 읽혀지고 있는 파일이 SC에서 사용되는 셈플과 다른 rate을 가질때에
BufRateScale.kr(bufnum)는 soundfile의 재생에 맞게 ratio를 바꾸어 준다.

        b = Buffer.read(s, “sounds/a11wlk01.wav”);  // sample rate of this file is 11025
        
to scale the playback:
        { PlayBuf.ar(1, b.bufnum, BufRateScale.kr(b.bufnum), loop: 1) }.scope

     b.free
//——————————————
BufFrames
    
BufFrames.kr(bufnum)는 현재 할당된 frames의 수로 돌아간다.
이것은 버퍼의 중간부분에서 시작하는 설정등을 할때에 유용하다.

        b = Buffer.read(s, “sounds/a11wlk01-44_1.aiff”);
(        
        var start = 1/2;
        { PlayBuf.ar(1, b.bufnum, BufRateScale.kr(b.bufnum),
                startPos: BufFrames.kr(b.bufnum) * start, loop: 1)
     }.scope
)

위의 예제에서의 시작부분으로 돌아가도록 loop

a trigger (<= 0 to > 0) causes the playback to start from startPos

//  using a trigger without looping
Impulse.kr 는 특정 freqyency에서 trigger를 만든다.

(        
        var start = 1/2;
        { PlayBuf.ar(1, b.bufnum, BufRateScale.kr(b.bufnum),
                Impulse.kr(1/3),
                startPos: BufFrames.kr(b.bufnum) * start, loop: 0)
     }.scope
)

// using a trigger with looping:

trigger는 다음 frequency에서 발생:
  (serverSampleRate / numberOfFrames) * rateScale
    
s.sampleRate  // the server’s sample rate

    
(        
        var start = 1/2;
        { PlayBuf.ar(1, b.bufnum, BufRateScale.kr(b.bufnum),
                     Impulse.kr(s.sampleRate / (BufFrames.kr(b.bufnum) * start) *
                            BufRateScale.kr(b.bufnum)),
                startPos: BufFrames.kr(b.bufnum) * start, loop: 1)
     }.scope
)    
    
      b.free
//——————————————
http://csound.x-y.net
Ji Youn Kang,
Csound Max Community