Skip to content

Instantly share code, notes, and snippets.

@tado
Last active July 1, 2025 06:23
Show Gist options
  • Save tado/75122c12bf320a2fe17e92053b275c25 to your computer and use it in GitHub Desktop.
Save tado/75122c12bf320a2fe17e92053b275c25 to your computer and use it in GitHub Desktop.
JITLib live coding study
s.boot;// サーバーの起動
p = ProxySpace.push(s);// ProxySpaceの初期化
(
// 楽器 "mySaw" を定義し追加
SynthDef("mySaw", {
arg out = 0, freq = 440, sustain = 1.0,
cutoff = 2000, rq = 0.3, pan = 0.0, amp = 1.0;
var sig;
sig = LFSaw.ar(
freq, mul: EnvGen.kr(
Env.perc(), levelScale: amp, timeScale: sustain, doneAction: 2)
);
sig = RLPF.ar(sig,LFNoise1.kr(1, cutoff / 2, cutoff).abs, rq);
sig = Pan2.ar(sig, pan);
4.do({ sig = AllpassN.ar(sig, 0.05, [0.05.rand, 0.05.rand], 4) });
Out.ar(out, sig);
}).add;
)
~out.play(vol:2.0); // 再生の準備 (音量2.0)
~out.fadeTime = 8.0; // フェードタイムを8秒に
~out.quant = 4; // 再生タイミングのクオンタイズ (4拍待って変更)
// 最初のフレーズ
~out = Pbind(\instrument, \mySaw, \freq, 110)
// 少しずつパラメーターを追加していく
(// シーケンス 0
~out = Pbind(
\instrument, \mySaw,
\freq, Pseq([55, 110, 220], inf))
)
(// シーケンス 1
~out = Pbind(
\instrument, \mySaw,
\freq,
Pseq([55, 110, 220], inf)
* Prand([[1, 1],[0.5, 1],[1, 1.5],[1, 1.5*1.5]],inf)
* Prand([0.5, 1, 2],inf))
)
(// シーケンス 2
~out = Pbind(
\instrument, \mySaw,
\freq,
Pseq([55, 110, 220], inf)
* Prand([[1, 1],[0.5, 1],[1, 1.5],[1, 1.5*1.5]],inf)
* Prand([0.5, 1, 2],inf),
\dur, Prand([1/8, 1/4, 1/2], inf),
\legato, Pexprand(1.0, 3.0, inf))
)
(// シーケンス 3
~out = Pbind(
\instrument, \mySaw,
\dur, PstepNadd(
Pseq([1, 0, 0, 1], 2),
Pshuf([1, 1, 2, 1], 2)
).loop * (1/8),
\scale, Scale.ritusen,
\degree, Prand([0, 1, 2, 3, 4, 5, 6, 7], inf),
\root, Prand([[0, 0], [0, 7], [-5, 0], [0, 12]], inf) + 6,
\octave, Prand([2, 3, 4], inf),
\legato, Pexprand(1.0, 3.0, inf)
))
(// シーケンス 4
~out = Pbind(
\instrument, \mySaw,
\dur, PstepNadd(
Pseq([1, 0, 0, 1], 2),
Pshuf([1, 1, 2, 1], 2)
).loop * (1/8),
\scale, Scale.ritusen,
\degree, Prand(
[0, 1, 2, 3, 4, 5, 6, 7], inf),
\root, Prand([[0, 7], [-5, 0], [0, 12]], inf) + 6,
\octave, Prand([2, 3, 4], inf),
\cutoff, Pexprand(200, 15000, inf),
\resonance, Prand([0.5, 0.3, 0.2, 0.1], inf),
\legato, Pexprand(1.0, 3.0, inf),
))
(// シーケンス 5
~out = Pbind(
\instrument, \mySaw,
\dur, PstepNadd(
Pseq([1, 0, 0, 1], 2),
Pshuf([1, 1, 2, 1], 2)
).loop * (1/8),
\pan, Prand([-0.6, -0.2, 0, 0.2, 0.6], inf),
\scale,
Pdup(32,
Prand(
[
Scale.ritusen,
Scale.hirajoshi,
Scale.iwato,
Scale.minorPentatonic
], inf)
),
\degree,
Pdup(4,
Prand(
[0, 1, 2, 3, 4, 5, 6, 7], inf)
),
\root, Prand([[0, 5, 12],[0, 7, 12],[0, 12],[-5, 0, 12]], inf) + 6,
\octave, Prand([2, 3, 4], inf),
\cutoff, Pexprand(1000, 18000, inf),
\resonance, Prand([0.5, 0.3, 0.2, 0.1], inf),
\legato, Pexprand(1.0, 4.0, inf),
))
(
// 新たな楽器 "myFm" を定義
SynthDef("myFm",
{
arg out = 0, gate = 1, freq = 440, ratio = 1.0, index = 3,
attk = 0.01, rel = 1.0, idxNoiseRate = 0.2,
sustain = 1.0, pan = 0, amp = 0.3;
var modFreq, modDepth, indexNoiseMod, mod, car, sig, env;
modFreq = freq * ratio;
indexNoiseMod = LFNoise1.kr(idxNoiseRate).abs;
modDepth = modFreq * index * indexNoiseMod;
mod = SinOsc.ar(modFreq, 0.0, modDepth);
car = SinOsc.ar(freq + mod, 0);
env = Env.asr(attk, 1.0, rel);
env = EnvGen.kr(env, gate, amp * 0.5, 0.0, sustain, doneAction:2);
sig = Pan2.ar((car * env), pan);
6.do({ sig = AllpassN.ar(sig, 0.05, [0.05.rand, 0.05.rand], 4) });
Out.ar(out, sig);
}
).add;
)
// 楽器を切り替え
~out.set(\instrument, \myFm);
// indexを変化させ音色を変化
~out.set(\index, 10);
~out.set(\ratio, (2/3));
~out.set(\index, 50);
~out.set(\ratio, (7/6));
~out.set(\index, 200);
~out.set(\ratio, (3/2));
~out.set(\index, 20);
// シーケンス 6
(
~out = Pbind(
\instrument, \myFm,
\dur, Prand([1/2, 1, 2], inf),
\scale, Scale.hexMajor6,
\degree, Prand([0, 1, 2, 3, 4, 5, 6, 7], inf),
\root, Prand([[0, 7], [-5, 0], [0, 12]], inf) + 6,
\octave, Prand([2, 3, 4, 5], inf),
\index, Prand([0, 1, 10, 40, 200], inf),
\ratio, Prand([1.0, 1.5, 0.333, 2.0], inf),
\legato, 1.5
))
// 楽器を元に戻す
~out.set(\instrument, \mySaw);
// 最初のフレーズに
~out = Pbind(\instrument, \mySaw);
// 停止
~out.free;
// Proxyをクリア
~out.clear;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment