Env을 사용하여 Envelope을 만든다.
-linear envelope (attackTime, sustainTime, releaseTime, level)
Env.linen (1,2,1,0.6).plot//plot:graph를 보여줌
Env.linen (1,2,1,0.6).test
-Env.new([levels],[times],curve)
Env.new([0.001,1,0.3,0.001],[1,0.5,2],’exponential’).plot
Env.new([0.001,1,0.3,0.001],[1,0.5,2],’exponential’).test.plot
Env.new([0.001,1,0.3,0.001],[1,0.5,2],’sine’).test.plot
Env.new([0.001,1,0.3,0.001],[1,0.5,2], ‘welch’).test.plot
Env.new([0.001,1,0.3,0.001],[1,0.5,2], 4).test.plot
Env.new([0.001,1,0.3,0.001],[1,0.5,2], -4).test.plot
-Env.triangle (duration,level)
Env.triangle(1,1).test.plot
-Env.sine(duration, level) // has Hanning window shape
Env.sine (1,1).test.plot
-Env.perc(attackTime, releaseTime,peakLevel, curve)//percutive shape
Env.perc(0.05,1,1,-4).test.plot
-cutoff(releaseTime, level, curve) // has no attack
Env.cutoff(1,1,’sine’).test.plot
-Envelope 을 만들기 위해서 UGen을 사용할 수 있다:
EnvGen (envelope, gate, levelScale, levelBias, timeScale, doneAction)
envelope – an instance of Env
gate – control signal that holds the EnvGen open (except Env.linen)
{EnvGen.kr(Env.linen(1,2,1,0.6),doneAction: 2)*SinOsc.ar}.scope
(
{EnvGen.kr(Env.new([0.001,1,0.3,0.001],[1,0.5,2],’exponential’),
doneAction:2)
* SinOsc.ar}.scope
)
-Envelope for frequency
(
{SinOsc.ar(EnvGen.kr(Env.new([1000,500,400,800],[5,2,3],’sine’),doneAction:2),mul:0.1)
}.scope
)
//——————————————
2. Variables.
-Variables는 변수설정으로서 algorithm을 코드의 라인을 분리시켜 표현된다. (세미콜론 사용)
(
var envelope, freq = 200; //envelope가 변수. 뒤에 값이 없으면 아래에 정의된다. freq는 변수 선언후 바로 값을 준 경우.
envelope = Env.new([0.001,1,0.3,0.001],[1,0.5,2],’exponential’);
{EnvGen.ar(envelope,1,doneAction:2)*SinOsc.ar(freq,0,0.5)}.scope;
)
또는 다음과 같이(세미콜론과 구문 확인)
(
{ var envelope, freq = 200;
envelope = Env.new([0.001,1,0.3,0.001],[1,0.5,2],’exponential’);
EnvGen.ar(envelope,1,doneAction:2 ) * SinOsc.ar(freq,0,0.4)
}.scope
)
// statements end with ; unless there is only one line being evaluated
// in the above example, the difference concerned the beginning of the function
//——————————————
3. Randon Sinewaves.
-random frequencies를 만들기 위해서 Array사용
-Array를 채운다.
Array.fill(10,1.0)//1이 10개인 값
Array.fill(10,1.0.rand)//Array를 같은 값으로 채움.10개의 수를 1,0안쪽의 랜덤숫자로.
Array.fill(10,{1.0.rand})//Array를 다른값으로 채움
-또다른 방법
{1.0.rand}.dup(10) // dup produces an array by applying a function
{1.00.rand}!10 //! is dup operator (see SymbolicNotations)
thisThread.randSeed = 5;//to seed the random distribution
-값을 normalize하기
[1,0.5,0.3].normalizeSum
(
{
var harmArray, ampArray, fund,n;
//첫번 array: 1~20.0, 두번째:0~1.0, 두번째 array를 normalize, 1.0까지exceed
fund = 100;
n = 20;
harmArray = {rrand(1.0,20)} ! n;//array of n values
ampArray = {1.0.rand}.dup(n).normalizeSum;
Mix.ar(SinOsc.ar(harmArray * fund, 0, ampArray));
}.scope
)
-envelope을 더해보기
(
{
var harmArray,ampArray,fund,n,env;
fund = 100;
n = 20;
harmArray = {rrand(1,20.0)} ! n;
ampArray = {1.0.rand}.dup(n).normalizeSum;
env = Env.linen(1,10,3,0.6);
Mix.ar(SinOsc.ar(harmArray * fund,0,ampArray) * EnvGen.kr(env,1,doneAction:2));
}.scope
)
-additive with a different envelope for each freq
(
// postln writes in post window
{
var harmArray, ampArray, fund,n,env; fund = 100;
n = 20;
harmArray ={rrand(1.0,20)}! n;
ampArray = {1.0.rand}.dup(n).normalizeSum;
env = {EnvGen.kr(Env.linen(rrand(1,10.0).postln,10,3,0.6))} ! n;
Mix.ar(SinOsc.ar(harmArray * fund, 0, ampArray) * env);
}.scope;
)
// yet another way, this time with an array of SinOsc * EnvGens
// sustain time is also random
// ! is the dup operator, returns an array with n object
(
{
var harmArray, ampArray, fund,n; fund = 100;
n = 20;
Mix.ar({SinOsc.ar(rrand(1,20.0) * fund, 0, 0.3.rand) *
EnvGen.kr(Env.linen(rrand(1.0,10),rrand(5.0,10),3,0.2))} ! n);
}.scope;
)
//——————————————
http://csound.x-y.net
Ji Youn Kang,
Csound Max Community