Created
February 26, 2026 08:41
-
-
Save tado/bf447984ec8590c0b0464121c573a030 to your computer and use it in GitHub Desktop.
SuperCollider code built with Claude
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 倍音成分が時間と共に変化するFM楽器 | |
| ( | |
| SynthDef( | |
| \myFM, { | |
| // 引数: 出力バス, キャリア周波数, 音量, 周波数比, 最大モジュレーションインデックス | |
| // ADSR各パラメータ, ゲート(発音/消音の制御) | |
| |out=0, freq=440, amp=0.5, | |
| modRatio=1.5, modIndex=10, | |
| attack=0.01, decay=1.0, sustain=0.3, release=1.5, | |
| gate=1| | |
| // 振幅エンベロープ(ADSR): 音量を時間変化させる | |
| // gate=0 になるとリリースフェーズへ移行し、完了後にシンセを自動解放 | |
| var ampEnv = EnvGen.kr( | |
| Env.adsr(attack, decay, sustain, release), | |
| gate, | |
| doneAction: Done.freeSelf | |
| ); | |
| // モジュレーションインデックスのエンベロープ: 倍音量を時間変化させる | |
| // アタック時は最大値 → ディケイで急速に減衰 → 元の5%まで下がる | |
| // 結果: 立ち上がりは倍音豊かな金属的音色、時間とともに柔らかいサイン波に近づく | |
| var modEnv = EnvGen.kr( | |
| Env([modIndex, modIndex, modIndex * 0.05], [attack, decay * 2], \exp) | |
| ); | |
| // モジュレータ周波数 = キャリア周波数 × 比率 | |
| // 整数比(1, 2, 3...)→ 調和的な倍音、非整数比 → 非調和的な金属音 | |
| var modulator = SinOsc.ar(freq * modRatio) * modEnv; | |
| // キャリア: 変化するモジュレータで周波数変調し、振幅エンベロープを適用 | |
| var carrier = SinOsc.ar(freq + modulator) * amp * ampEnv; | |
| // ステレオで出力バスに送る | |
| Out.ar(out, carrier.dup); | |
| } | |
| ).add; // SynthDefをサーバーに登録 | |
| ) | |
| // リバーブのセットアップ(SynthDefより後、Pbindより前に一度だけ評価する) | |
| ( | |
| // FMシンセの出力を受け取るステレオバスを確保 | |
| ~reverbBus = Bus.audio(s, 2); | |
| // リバーブSynthDef: FreeVerb2でステレオリバーブを処理し最終出力へ送る | |
| SynthDef(\reverb, { |in, out=0, mix=0.25, room=0.97, damp=0.55, amp=0.9| | |
| var dry = In.ar(in, 2); | |
| // FreeVerb2: L/Rを独立処理するステレオリバーブ | |
| // mix=ウェット比率, room=部屋サイズ(大きいほど長い残響), damp=高域減衰 | |
| var wet = FreeVerb2.ar(dry[0], dry[1], mix, room, damp) * amp; | |
| Out.ar(out, wet); | |
| }).add; | |
| // リバーブシンセをサーバーのノードツリー末尾に常駐させる | |
| // (FMシンセより後に処理されるよう \addToTail を指定) | |
| ~reverb = Synth.tail(s, \reverb, [\in, ~reverbBus]); | |
| ) | |
| // Pbindでシーケンスを再生する(~pに格納することで後から止められる) | |
| ( | |
| ~p = Pbind( | |
| \instrument, \myFM, | |
| \out, ~reverbBus, // リバーブバスへ出力(リバーブSynthDefが処理して最終出力へ) | |
| // 音度: マイナースケールからランダムに選択(広い音域で跳躍感を出す) | |
| \scale, Scale.minor, | |
| \degree, Prand([0, 2, 3, 4, 5, 7, 9, 10, -2, -4, 12, 14], inf), | |
| \octave, Prand([4, 5, 5, 5, 6, 6], inf), // オクターブもランダムに飛ぶ | |
| // モジュレータ周波数比: Pbrown でゆっくりと彷徨い続ける | |
| // 0.5〜7.0 の範囲を最大ステップ0.8で酔歩 → 常に非整数領域を漂う金属的な揺らぎ | |
| \modRatio, Pbrown(0.5, 1.0, 1.8, inf), | |
| // モジュレーションインデックス: 極端に広い範囲でランダムに変動 | |
| // 低値(1〜5)→ 倍音わずか, 高値(20〜50)→ 激しくざらついた音色 | |
| \modIndex, Pwhite(100.0, 1000.0), | |
| // 音量: 強弱の差を大きくつける | |
| \amp, Pwhite(0.1, 0.3), | |
| // エンベロープ: アタックもランダム化して打楽器的〜弦楽器的に変化 | |
| \attack, Pwhite(0.001, 0.08), | |
| \decay, Pwhite(0.01, 1.0), | |
| \sustain, Pwhite(0.02, 0.25), | |
| \release, Pwhite(0.3, 4.0), // 長いリリースで音が重なり合う | |
| // リズム: 16分音符〜付点4分音符をランダムに選択して不規則なグルーヴを作る | |
| \dur, Prand([0.125, 0.25, 0.25, 0.5, 0.5, 0.75, 1.0], inf), | |
| // レガート: 短いスタッカートから長いオーバーラップまでランダムに | |
| \legato, Pwhite(0.2, 1.4), | |
| ).play; | |
| ) | |
| // シーケンスを止める場合 | |
| ~p.stop; | |
| // 補完シーケンス: 低音域でゆっくりと揺らぐ倍音テクスチャー | |
| // ~p と同時に再生すると2レイヤーのテクスチャーになる | |
| ( | |
| ~p2 = Pbind( | |
| \instrument, \myFM, | |
| \out, ~reverbBus, // 同じリバーブバスへ出力 | |
| // 低〜中音域に絞り、動きを抑えてドローン的な厚みを作る | |
| \scale, Scale.minor, | |
| \degree, Prand([-4, -2, 0, 0, 2, 3, 5], inf), | |
| \octave, Prand([3, 3, 4], inf), | |
| // modRatioをPwhiteで急激にジャンプさせる | |
| // Pbrown(~p)と対照的に、非連続的な倍音変質の感覚を強調する | |
| \modRatio, Pwhite(0.3, 9.0), | |
| // modIndexをPbrownで大きく彷徨わせる(~pのPwhiteと対照的) | |
| // 倍音量が徐々に膨らんだり引いたりする波のような変化 | |
| \modIndex, Pbrown(5.0, 60.0, 12.0, inf), | |
| // 音量は抑えめにして~pの上に乗る土台として機能させる | |
| \amp, Pwhite(0.08, 0.2), | |
| // アタックをやや長くして音が滑らかに立ち上がり重なり合う | |
| \attack, Pwhite(0.05, 0.4), | |
| \decay, Pwhite(0.5, 2.5), | |
| \sustain, Pwhite(0.15, 0.5), | |
| \release, Pwhite(1.5, 6.0), // 長いリリースで音が溶け合いテクスチャーを作る | |
| // ~pより長い音符でゆったりとしたリズム感 | |
| \dur, Prand([0.5, 0.75, 1.0, 1.0, 1.5, 2.0], inf), | |
| \legato, Pwhite(0.5, 1.5), | |
| ).play; | |
| ) | |
| ~p2.stop; | |
| // ===================================================================== | |
| // Autechre風: ユークリッドリズム × 非整数FM倍音によるパーカッシブシーケンス | |
| // ~p3 と ~p4 を同時に評価して同時再生する | |
| // ===================================================================== | |
| ( | |
| // テンポをグローバルに設定(~p / ~p2 も同じクロックに乗る) | |
| TempoClock.default.tempo = 132 / 60; // 132 BPM | |
| ~p3 = Pbind( | |
| \instrument, \myFM, | |
| \out, ~reverbBus, | |
| // --- リズム --- | |
| // E(9,16) ユークリッドリズムを Pseq で手動展開 | |
| // 16ステップ(= 4拍)に9打を最大間隔で均等配置した拍間隔のリスト | |
| // [3,2,1,2,2,1,2,2,1] ステップ × 0.25 = 16分音符単位の duration 値 | |
| // 合計 = (3+2+1+2+2+1+2+2+1)×0.25 = 4拍 でちょうど1サイクル | |
| \dur, Pseq([0.75, 0.5, 0.25, 0.5, 0.5, 0.25, 0.5, 0.5, 0.25], inf), | |
| // --- ピッチ --- | |
| // Pstutter で同じ音を不規則に繰り返してグリッチ感を演出 | |
| // 外側のPrand: 何回繰り返すか(1〜4回) | |
| // 内側のPrand: 繰り返す音度 | |
| \scale, Scale.chromatic, | |
| \degree, Pstutter( | |
| Prand([1, 1, 1, 2, 3, 4], inf), | |
| Prand([0, 2, 3, 5, 7, -2, -5, -7], inf) | |
| ), | |
| \octave, Prand([4, 4, 4, 5, 3], inf), | |
| // --- FM倍音 --- | |
| // modRatioに数学的無理数・超越数に近い値を意図的に使用 | |
| // (√2≈1.41, √3≈1.73, √5≈2.23, π≈3.14) | |
| // 自然倍音列から外れた無機質・工業的な響きを作る | |
| \modRatio, Prand([0.5, 1.41, 1.73, 2.23, 3.14, 4.67, 7.39], inf), | |
| // modIndexをPbrownで緩やかに変動させ、金属感の濃淡を波のように推移 | |
| \modIndex, Pbrown(10.0, 70.0, 15.0, inf), | |
| // --- 音量 --- | |
| // Pseqのアクセントパターン(強・弱・中・弱...)にランダムな揺らぎを掛ける | |
| \amp, Pseq([0.5, 0.2, 0.4, 0.15, 0.5, 0.25, 0.35, 0.15], inf) | |
| * Pwhite(0.7, 1.3), | |
| // --- エンベロープ --- | |
| // 注意: \sustain はイベントシステムが「ゲート開放時間 = dur * legato」に使う予約キー | |
| // ここでは指定しない。パーカッシブな発音は短い \decay と \legato で実現する | |
| \attack, 0.001, | |
| \decay, Prand([0.04, 0.08, 0.15, 0.3, 0.5], inf), | |
| \release, Prand([0.03, 0.06, 0.1, 0.2], inf), | |
| // legato を短く設定してスタッカート感を強調(ゲート開放時間 = dur × legato) | |
| \legato, Prand([0.1, 0.15, 0.3, 0.5, 0.8], inf), | |
| ).play; | |
| // ===================================================================== | |
| // ~p4: ~p2の鋭い中高域FM音色を継承しつつ、徐々に激しくなるリズムパート | |
| // Pseg でリズム密度と倍音密度を時間とともに指数的に増大させる | |
| // 132 BPM: 序盤30拍(≈14秒)静止 → 270拍(≈123秒)かけて最大強度へ | |
| // ===================================================================== | |
| ~p4 = Pbind( | |
| \instrument, \myFM, | |
| \out, ~reverbBus, | |
| // --- リズム --- | |
| // E(7,12): 12ステップに7打のユークリッドリズム(3拍サイクル、固定) | |
| \dur, Pseq([0.5, 0.25, 0.5, 0.5, 0.25, 0.5, 0.5], inf), | |
| // --- ピッチ --- | |
| \scale, Scale.minor, | |
| \degree, Prand([0, 2, 3, 5, 7, 9, 12, -2], inf), | |
| \octave, Prand([5, 5, 5, 6, 4], inf), | |
| // --- FM倍音(modIndex のみ徐々に激しく) --- | |
| // modRatioをPwhiteで急激にジャンプ → ~p2と同様の非連続的な倍音変質感 | |
| \modRatio, Pwhite(0.3, 9.0), | |
| // modIndex: 8拍周期で calm(500)↔ intense(8000)を繰り返す | |
| // Pseg の 3レベルを [calm, intense, calm] に設定し inf で無限ループ | |
| // 前半4拍で上昇(\sin カーブ)、後半4拍で下降(\sin カーブ) | |
| // 上に Pwhite(0.3, 13.0) を乗せて各ノートに瞬間的な揺らぎを加える | |
| \modIndex, Pseg([500.0, 8000.0, 500.0], [4, 4], \sin, inf) | |
| * Pwhite(0.3, 13.0), | |
| // --- 音量 --- | |
| \amp, Pseq([0.4, 0.3, 0.15, 0.4, 0.2, 0.35, 0.1], inf) | |
| * Pwhite(0.7, 1.0), | |
| // --- エンベロープ --- | |
| \attack, Pwhite(0.002, 0.02), | |
| \decay, Prand([0.1, 0.2, 0.3, 0.5, 0.8], inf), | |
| \release, Prand([0.1, 0.2, 0.4, 0.6], inf), | |
| \legato, Prand([0.2, 0.3, 0.5, 0.7], inf), | |
| ).play; | |
| ) | |
| ~p3.stop; ~p4.stop; // 両方止める場合はこの行を選択して評価 | |
| // テンポを元に戻す場合: | |
| // TempoClock.default.tempo = 1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment