1. Frequency Modulation
envelope 없는 간단한 FM의 예제
(
var carrierFreq = 400, modFreq = 50, deviation = 100;
{ SinOsc.ar(carrierFreq + SinOsc.ar(modFreq, mul: deviation),
mul: 0.3);
}.scope
)
같은것을 다음과 같이 간단화 시킬수 있다.
(
var carrierFreq = 400, modFreq = 50, deviation = 100;
{ SinOsc.ar(SinOsc.ar(modFreq, mul:deviation, add: carrierFreq),
mul:0.3);
}.scope
)
2. Phase Modulation
PM은 FM과 비슷하지만, frequency 대신 Phase가 modulate된다.
PMOsc가 사용된다;
PMOsc.ar(carfreq, modfreq, index, modphase, mul, add)
index는 radian에서의 modulation index
modphase는 radians에서 modulator를 위한 modulation input.
{ PMOsc.ar(Line.kr(600, 900, 5), 600, 3, 0, 0.1)}.play// modulation carfreq
{ PMOsc.ar(300, Line.kr(600, 900, 5),3,0,0.1)}.play// modulate modfreq
{ PMOsc.ar(300, 550, Line.ar(0,20,8), 0, 0.1)}.scope// modulate index
(
var carrierFreq = 400, modFreq = 50, index = 3, decayTime = 5;
{ EnvGen.kr(Env.perc(0.001, decayTime, 0.2), 1, doneAction:2) * PMOsc.ar(carrierFreq, modFreq, index,0);
}.scope
)
calculate modFreq from cmRatio:
(
var carrierFreq = 400, modFreq, cmRatio = 1.5, index = 3, decayTime = 5;
modFreq = (carrierFreq * cmRatio.reciprocal).postln;
{ EnvGen.kr(Env.perc(0.001, decayTime, 0.2), 1, doneAction: 2) *
PMOsc.ar(carrierFreq, modFreq, index, 0);
}.scope
)
– as SynthDef
SynthDef(name, {function})
load, send, writeDef, play
SynthDef는 반드시 Output bus 에 무엇인가를 보내야 한다;
Out.ar(bus, value)
(
SynthDef(pmgrain, {
|carrierFreq = 400, cmRatio = 1.5, index = 3, decayTime = 0.01, amp = 1|
var signal, modFreq;
modFreq = (carrierFreq * cmRatio.reciprocal);
signal =
EnvGen.kr(Env.perc(0.001, decayTime, 0.2),1,amp, doneAction: 2) *
PMOsc.ar(carrierFreq, modFreq, index, 0);
Out.ar(0, signal)
}).load(s)
)
//위의 구문을 실행햐여 정의를 내린다.
//아래와 같은 방법으로 불러낸다.
//definition내의 arguments들의 값을 다음과 같이 변경시킬수 있다.
Synth(pmgrain, [decayTime, 5])
Synth(pmgrain, [decayTime, 1, carrierFreq, 200])
-with Routines
Routine({function})
//random carrierFreqs and random offset between events
//loops indefinitely
(
Routine({
{Synth(pmgrain, [carrierFreq, rrand(1000.0,5100)]);
rrand(0.001,0.1).wait;
}.loop
}).play(SystemClock)
)
//with more layers
(
a= {Routine({
{Synth(pmgrain, [carrierFreq, rrand(1000.0,5100)]);
rrand(0.5,0.8).wait;
}.loop
})
} ! 10// be careful how many layers are used
)
play the array of routines
a.do({|i| i.play(SystemClock)})
stop the array of routines:
a.do({|i| i.stop})
reset and play the array of routines
a.do({|i| i.reset.play(SystemClock)})
//——————————————
http://csound.x-y.net
Ji Youn Kang,
Csound Max Community