Skip to content

Instantly share code, notes, and snippets.

View yotamorimoto's full-sized avatar
🖖

yota morimoto yotamorimoto

🖖
View GitHub Profile
@yotamorimoto
yotamorimoto / gist:2261233
Last active January 14, 2019 13:01
シンセ作り
ドラムのハイハットをシンセで作る
SynthDef オブジェクトでシンセサイザーをつくる
SynthDef の引数は
SynthDef(シンセの名前, 関数).add; // .add で定義をサーバに送る
シンセの名前は String オブジェクト "I am SuperCollider" など
あるいは Symbol オブジェクト \iamSuperCollider などを使って書く
Symbol は空白を使えない
() 内を選択後、実行
@yotamorimoto
yotamorimoto / gist:2264454
Last active March 30, 2017 12:04
サーバ起動
// サーバの起動
// 下の行にカーソルを置き、実行
s.boot;
/*
 「クライアント」から「サーバ」へ命令が行って
   サーバが起動し、ポストウィンドウに文字が出力される
    ここでは s がサーバで、.boot メッセージを送ることで起動する
*/
{ } カーリーブラッケットは関数
関数の中で、音の鳴り方や、計算などができる
f = {};
SC では、小文字のアルファベットは、変数(関数や値などを格納する)
デフォルトで s にはサーバが格納されている
s.boot; // サーバ起動
s.isKindOf(Server); // s はサーバですか? yes -> true, no -> false が出力
@yotamorimoto
yotamorimoto / gist:2273872
Last active March 30, 2017 12:03
コメントとnil
// はコメント
/* は複数行に
わたる
コメント */
// 1 + 1; コメントは実行すると常に Nil (無)値が返ってくる
下記を実行
1 + 2 // + 1 プログラムに影響しない
@yotamorimoto
yotamorimoto / gist:2273929
Last active March 30, 2017 11:59
SuperCollider
SC は音を鳴らす「サーバ」と、
サーバへ命令やリクエストを送る「クライアント」の二つのプログラムからなる
@yotamorimoto
yotamorimoto / hello.sc
Last active October 11, 2024 14:37
プログラム実行
キーボードによるプログラムの実行方法は OS (macOS/Windows/Linux) によって違う
macOS cmd + return
Windows & Linux ctrl + return
下の行にカーソルを置き、実行する
1 + 2;
ポストウィンドウに計算結果が出力される
@yotamorimoto
yotamorimoto / hello_sound.sc
Last active October 11, 2024 14:27
音を鳴らす/止める
// 関数で音を鳴らす
f = { SinOsc.ar * 0.1 };
// 実行 -> 音が鳴る
f.play;
音を止める
macOS cmd + ピリオド
Windows & Linux ctrl + ピリオド
@yotamorimoto
yotamorimoto / oop.sc
Last active October 11, 2024 14:41
オブジェクト指向
SC では全てがオブジェクトです。
オブジェクトとは「もの」です。
具体的にはどんな「もの」でもない、抽象的な「もの」で、
プログラムはオブジェクト同士のメッセージのやりとり、相互作用で表現されます。
オブジェクトですか?
1.5.isKindOf(Object); // true
{}.isKindOf(Object); // true
抽象的な「もの」オブジェクトから
@yotamorimoto
yotamorimoto / gist:2275601
Last active March 30, 2017 16:05
stream, pattern, and routine
Stream はオブジェクトのストリーム(流れ)で .next メッセージを受け「流れる」
Pattern はストリームの設計図
パターンオブジェクトのひとつ Pseries を使って
0から始まり、2ずつ増える、5個のストリームをつくる
p = Pseries(0, 2, 5).asStream;
p.next;
@yotamorimoto
yotamorimoto / gist:2276956
Last active September 13, 2021 07:00
event and pbind
Pbind シンセ生成と引数にわたすストリームを bind (結びつけ)
音楽のフレーズの生成を可能にする
Pbind(\instrument, シンセの名前, 引数名、値、引数名、値…).play;
先につくったハイハットのシンセ
(
SynthDef(\hat, {| amp=0.1, pan=0 |
var sig, env;
env = EnvGen.kr(Env.perc(0, 0.03), 1, amp, doneAction: 2);