Files
quartz-research-note/content/mimiumでのシーケンサ.md
Matsuura Tomoya(Windows) 1c439d880b
All checks were successful
Build / build (push) Successful in 6m57s
[obsidian] vault backup: 2025-06-26 02:17:45[
2025-06-26 02:17:45 +09:00

43 lines
2.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#memo #mimium
[[SuperCollider]]のPatternに相当するものを作ってみたい。
Pattern自体は基本的にはシンプルな遅延リスト。だが値の種類を、ピッチと長さとかグループ化できてジェネリックなので、静的型付け言語だとジェネリクスがいる`next`メソッドを持つ型クラスとかインターフェース的なものが欲しくなる)
重要ポイント
- あるパターンを先に構築して、それにあとから適当なシンセを当てはめることもできる
- 数値リテラルが定数(不変)パターンに自動キャストされていることで、パターンのリストの要素にさらに別のパターンを埋め込むことができる
`Pbind`は実際には遅延リストを実行してイベント(キーバリューの辞書ペア集合)のリストを得ている
[Pattern Guide 03: What Is Pbind | SuperCollider 3.14.0-dev Help](https://doc.sccode.org/Tutorials/A-Practical-Guide/PG_03_What_Is_Pbind.html)
`.play`を実行すると、`EventStreamPlayer`クラスがいろいろ頑張ってくれるらしい
`instrument`の指定なしにPbindすると、デフォのシンセが鳴る
```smalltalk
SynthDef(\default, { arg out=0, freq=440, amp=0.1, pan=0, gate=1;
var z;
z = LPF.ar(
Mix.new(VarSaw.ar(freq + [0, Rand(-0.4,0.0), Rand(0.0,0.4)], 0, 0.3)),
XLine.kr(Rand(4000,5000), Rand(2500,3200), 1)
) * Linen.kr(gate, 0.01, 0.7, 0.3, 2);
OffsetOut.ar(out, Pan2.ar(z, pan, amp));
}, [\ir]);
```
durとかdegreeみたいなのをいい感じに解釈するのはEventStreamPlayerの役割ってことか
[supercollider/SCClassLibrary/Common/Streams/Stream.sc at d4b6f8d5e6c9e419c86b3c44d899b63b4610893b · supercollider/supercollider · GitHub](https://github.com/supercollider/supercollider/blob/d4b6f8d5e6c9e419c86b3c44d899b63b4610893b/SCClassLibrary/Common/Streams/Stream.sc#L491)
ここでもなさそうだな、謎・・・。
まあでも,degreeとfreqの自動変換とかは[[単位変換のための型システム]]で解決すべき問題かも