Skip to content

Instantly share code, notes, and snippets.

@tado
Last active December 6, 2023 05:06
Show Gist options
  • Save tado/15a770853d38affa15c51234b4f70494 to your computer and use it in GitHub Desktop.
Save tado/15a770853d38affa15c51234b4f70494 to your computer and use it in GitHub Desktop.
Super Collider Basic
// 関数の定義、値の出力
{"Hello World"}.value;
// 関数の定義、音の出力(Sin波)
{SinOsc.ar()}.play;
// Sin波の周波数の指定 (220Hz)
{SinOsc.ar(220)}.play;
// 左右2chに
{SinOsc.ar([220, 220])}.play;
// 左右の音を微妙にずらす
{SinOsc.ar([220, 222])}.play;
// 別の波形1: ノコギリ波
{Saw.ar([220, 222])}.play;
// 別の波形2: 矩形波
{Pulse.ar([220, 222])}.play;
// 別の波形3: ホワイトノイズ
{WhiteNoise.ar([1.0, 1.0])}.play;
// 別の波形3: ピンクノイズ
{PinkNoise.ar([1.0, 1.0])}.play;
// 2つの音を混ぜる1
// そのまま足して2で割る
(
{
(SinOsc.ar([220, 222]) + SinOsc.ar([330, 333])) * 0.5
}.play;
)
// 2つの音を混ぜる2
// 変数に格納
(
{
var sig1, sig2;
sig1 = SinOsc.ar([220, 222]);
sig2 = SinOsc.ar([330, 333]);
(sig1 + sig2) * 0.5;
}.play;
)
// 2つの音を混ぜる2
// 変数に格納、違う波形で
(
{
var sig1, sig2;
sig1 = SinOsc.ar([220, 222]);
sig2 = Saw.ar([330, 333]);
(sig1 + sig2) * 0.5;
}.play;
)
// 関数を作成して後から演奏
(
var func;
func = {
var sig1, sig2;
sig1 = SinOsc.ar([220, 222]);
sig2 = Saw.ar([330, 333]);
(sig1 + sig2) * 0.5;
};
func.play;
)
// エンベロープ (音量の変化)
(
{
var sig, env;
sig = Saw.ar([220, 222]);
env = EnvGen.kr(Env.perc());
sig * env;
}.play;
)
// 楽器 (Synth) にする
(
SynthDef("mySynth",
{
var sig, env;
sig = Saw.ar([220, 222]);
env = EnvGen.kr(Env.perc());
Out.ar(0, sig * env);
}).add
)
Synth("mySynth");
// 楽器 (Synth) に引数をつける
// 周波数を指定
(
SynthDef("mySynth",
{
arg freq = 440;
var sig, env;
sig = Saw.ar([freq, freq * 1.01]);
env = EnvGen.kr(Env.perc());
Out.ar(0, sig * env);
}).add
)
Synth("mySynth", ["freq", 220]);
Synth("mySynth", ["freq", 110]);
Synth("mySynth", ["freq", 55]);
// いろいろ引数として指定できるように
// 周波数(freq), 長さ(length), フィルタ周波数(lpfFreq)
(
SynthDef("mySynth",
{
arg freq = 440, length = 1.0, lpfFreq = 800, gain = 1.5;
var sig, env, out;
sig = Saw.ar([freq, freq * 1.01]);
env = EnvGen.kr(Env.perc(releaseTime: length));
out = RLPF.ar(sig * env, lpfFreq, 0.3) * gain;
Out.ar(0, out);
}).add
)
Synth("mySynth", ["freq", 220, "length", 2.0, "lpfFreq", 800]);
Synth("mySynth", ["freq", 110, "length", 4.0, "lpfFreq", 600]);
Synth("mySynth", ["freq", 55, "length", 12.0, "lpfFreq", 600]);
// SuperDirt用の楽器へ
(
SynthDef("mySynth",
{
arg out = 0, freq = 440, length = 1.0, pan = 0.5;
var sig, env;
sig = Saw.ar([freq, freq * 1.01]);
env = EnvGen.kr(Env.perc(releaseTime: length));
OffsetOut.ar(out, DirtPan.ar(sig, ~dirt.numChannels, pan, env));
}).add
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment