Skip to content

Instantly share code, notes, and snippets.

@tado
Last active Dec 26, 2015
Embed
What would you like to do?
// Mix 例1
{
SinOsc.ar([440,442], 0, 0.2)
+ SinOsc.ar([660,663], 0, 0.2)
}.play;
// Mix 例2
{
a = SinOsc.ar([440,442], 0, 0.2);
b = SinOsc.ar([660,663], 0, 0.2);
a + b;
}.play;
// -----------------------------------------
// Mixクラス
{
a = SinOsc.ar([440,442], 0, 0.2);
b = SinOsc.ar([660,663], 0, 0.2);
c = SinOsc.ar([220,221], 0, 0.2);
Mix([a, b, c]);
}.play;
// -----------------------------------------
// ランダムな周波数を重ねる
(
var num = 8;
{ Mix.arFill(num, {
SinOsc.ar([50+800.rand, 50+800.rand], pi.rand, 1.0/num)
})}.play;
)
// number.rand から ExpRand(low, hi)へ
(
var num = 8;
{Mix.arFill(num,{
SinOsc.ar([ExpRand(50,800), ExpRand(50,800)], pi.rand, 1.0/num)
})}.play;
)
// -----------------------------------------
// アルゴリズミック、ハーモニー
(
var num = 8;
{Mix.arFill(num,{
var freqR, freqL;
freqL = 220 * [1.0, 3.0/2.0, 4.0/3.0].choose;
freqR = 220 * [1.0, 3.0/2.0, 4.0/3.0].choose;
SinOsc.ar([freqL, freqR], pi.rand, 1.0/num);
})}.play;
)
// アルゴリズミック、ハーモニー 2
(
var num = 8;
{ Mix.arFill(num,{
var freqR, freqL;
freqL = 220 * [1.0, 3.0/2.0, 4.0/3.0].choose
* [1.0, 3.0/2.0, 4.0/3.0].choose;
freqR = 220 * [1.0, 3.0/2.0, 4.0/3.0].choose
* [1.0, 3.0/2.0, 4.0/3.0].choose;
SinOsc.ar([freqL, freqR], pi.rand, 1.0/num);
})}.play;
)
// アルゴリズミック、ハーモニー 3
(
var num = 8;
{ Mix.arFill(num, {
var freqR, freqL;
freqL = 220 * [1.0, 3.0/2.0, 4.0/3.0].choose
* [1.0, 3.0/2.0, 4.0/3.0].choose + 10.0.rand;
freqR = 220 * [1.0, 3.0/2.0, 4.0/3.0].choose
* [1.0, 3.0/2.0, 4.0/3.0].choose + 10.0.rand;
SinOsc.ar([freqL, freqR], pi.rand, 1.0/num);
})}.play;
)
// アルゴリズミック、ハーモニー 4
(
var num = 32;
{ Mix.arFill(num,{
var freqR, freqL;
freqL = 440 * (1.5 ** rrand(1,6)) * (0.5 ** rrand(1, 8));
freqR = 442 * (1.5 ** rrand(1,6)) * (0.5 ** rrand(1, 8));
SinOsc.ar([freqL, freqR], pi.rand, 1.0/num);
})}.play;
)
// アルゴリズミック・ハーモニー、バリエーション
{Mix.arFill(24,{SinOsc.ar([440,441]*(3.0/2**rrand(1,6))*(0.5** rrand(1,8)),0,1.0/24)})}.play;
{Mix.arFill(24,{SinOsc.ar([440,441]*(4.0/3**rrand(1,6))*(0.5** rrand(1,8)),0,1.0/24)})}.play;
{Mix.arFill(24,{SinOsc.ar([440,441]*(5.0/3**rrand(1,8))*(0.5** rrand(1,8)),0,1.0/24)})}.play;
{Mix.arFill(24,{SinOsc.ar([440,441]*(9.0/8**rrand(1,20))*(0.5** rrand(1,8)),0,1.0/24)})}.play;
// -----------------------------------------
// {}.playによる出力
{SinOsc.ar}.play;
// SyntDefに変換
SynthDef("sine", {Out.ar(0, SinOsc.ar)}).play; //left
SynthDef("sine", {Out.ar(1, SinOsc.ar)}).play; //right
// -----------------------------------------
//関数による記述
{ SinOsc.ar(440, 0, 0.2) }.play;
//SynthDefをサーバーに追加
SynthDef.new("test-SinOsc", {
Out.ar(0, SinOsc.ar(440, 0, 0.2))
}).add;
//Synthを演奏
Synth("test-SinOsc");
// -----------------------------------------
//SynthDefの定義(引数あり)
SynthDef.new("test-SinOsc", {
arg freq = 440, amp = 0.2;
Out.ar(0, SinOsc.ar(freq, 0, amp))
}).add;
//Synthを演奏
a = Synth("test-SinOsc"); //440Hz
b = Synth("test-SinOsc", [freq:660]); //660Hz
c = Synth("test-SinOsc", [freq:880, amp:0.5]); //880Hz, amp:0.5
a.set("freq", 330); //440Hz -> 330Hz
b.set("freq", 220, "amp", 0.3); //660Hz -> 220Hz, amp: 0.3
//終了
a.free; b.free; c.free;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment