Interactive Music II
ProcessingとSuperColliderの連携2
東京藝術大学芸術情報センター (AMC)
2014年1月16日
田所 淳
最終課題
‣ 課題 :
‣ SuperCollider、またはSuperColliderとProcessingを連携して
表現する
‣ 音、または音と連動した映像
‣ テーマは自由
‣ 時間: 30分以内であれば、自由
!

‣ 次週(1月23日)の授業で発表してください
先週の復習
SuperCollider client for Processing
‣ ProcessingとSuperColliderの連携には、SuperCollider client
for Processingが便利
‣ OSCp5よりも簡単に、SuperColliderとProcessingの連携が可
能となる
SuperCollider client for Processing
‣ SuperCollider側: 「test_inst」を定義
SynthDef("test_inst",{
arg freq=440, length=1.0, amp=0.5;
var env, out;
env = Env.perc(0.01, length);
out = SinOsc.ar([freq,freq*1.001])
* EnvGen.kr(env, doneAction:2) * amp;
Out.ar(0, out);
}).store;
SuperCollider client for Processing
‣ Processing側: クリックで音が鳴るように
import supercollider.*;
import oscP5.*;

!

Synth synth;

!

void setup () {
size(600, 400);
}

!

void draw() {
background(0);
}

!

//マウスクリックに反応
void mouseReleased() {
//新規に楽器を定義(まだ生成はされず)
synth = new Synth("test_inst");
//引数を設定
synth.set("amp", 0.5);
synth.set("freq", map(mouseY, height, 0, 20, 8000));
//楽器を生成
synth.create();
}
SuperCollider client for Processing
‣ たとえば、ここに円が拡がるアニメーションをつけてみる
SuperCollider client for Processing
‣ Processing側:
import supercollider.*;
import oscP5.*;

!

Synth synth;
int NUM = 100;
float[] radius = new float[NUM];
PVector[] pos = new PVector[NUM];
int counter = 0;

!

void setup () {
size(800, 600);
frameRate(60);
noFill();
stroke(31, 127, 255);
strokeWeight(3);
for (int i = 0; i < NUM; i++) {
radius[i] = 0;
pos[i] = new PVector(width*2, width*2);
}
}
SuperCollider client for Processing
‣ Processing側:
void draw() {
background(0);
for (int i = 0; i < NUM; i++) {
ellipse(pos[i].x, pos[i].y, radius[i], radius[i]);
radius[i] += 1;
if(radius[i] > width*1.5){
radius[i] = 0;
pos[i].x = width*2;
pos[i].y = width*2;
}
}
}

!

void mouseReleased() {
synth = new Synth("test_inst");
synth.set("amp", 0.5);
synth.set("freq", map(mouseY, height, 0, 20, 8000));
synth.create();
int n = counter % NUM;
radius[n] = 0;
pos[n].x = mouseX;
pos[n].y = mouseY;
counter++;
}
SuperCollider client for Processing
‣ 完成!!
SuperCollider client for Processing
‣ SuperColliderの楽器はそのままで、さらに別の例
SuperCollider client for Processing
‣ Processing側:
import supercollider.*;
import oscP5.*;

!

int NUM = 400; //配列の数
//位置のベクトルの配列
PVector[] location = new PVector[NUM];
//速度のベクトルの配列
PVector[] velocity = new PVector[NUM];
//塗りの色の配列
color[] col = new color[NUM];
//円の大きさ(直径)の配列
float[] diameter = new float[NUM];

!

void setup() {
size(640, 480); //640x480pixelの画面を生成
frameRate(60); //フレームレート
noStroke();
for (int i = 0; i < NUM; i++) { //配列の数だけ繰り返し
//位置のベクトルの初期設定
location[i] = new PVector(random(width), random(height));
//速度のベクトルの初期設定
velocity[i] = new PVector(random(-4, 4), random(-4, 4));
//色の初期設定
col[i] = color(random(255), random(255), random(255), 127);
//大きさの初期設定

}

}

diameter[i] = random(3, 40);
SuperCollider client for Processing
‣ Processing側:
void draw() {
background(15); //背景を描画
//配列の数だけ繰り返し
for (int i = 0; i < NUM; i++) {
fill(col[i]); //色を指定
//指定した位置に円を描画
ellipse(location[i].x, location[i].y, diameter[i], diameter[i]);
//位置のベクトルに速度のベクトルを加算、次の位置になる
location[i].add(velocity[i]);
//もし画面の左端、または右端に到達したら
if ((location[i].x > width) || (location[i].x < 0)) {
velocity[i].x *= -1; //X方向のスピドを反転
playSynth(location[i].x, location[i].y);

}
//もし画面の下端、または上端に到達したら

if ((location[i].y > height) || (location[i].y < 0)) {
velocity[i].y *= -1; //Y方向のスピードを反転

}

}

}

playSynth(location[i].x, location[i].y);

!

void playSynth(float x, float y) {
//新規に楽器を定義(まだ生成はされず)
Synth synth = new Synth("test_inst");
//引数を設定
synth.set("amp", 0.1);
synth.set("freq", map(x, height, 0, 20, 8000));
//楽器を生成
SuperCollider client for Processing
‣ Processing側:
!

void playSynth(float x, float y) {
//新規に楽器を定義(まだ生成はされず)
Synth synth = new Synth("test_inst");
//引数を設定
synth.set("amp", 0.1);
synth.set("freq", map(x, height, 0, 20, 8000));
//楽器を生成
}

synth.create();
SuperCollider client for Processing
‣ ボールのバウンドに反応
SuperCollider client for Processing
‣ Processing側:
import supercollider.*;
import oscP5.*;

!

Synth synth;
int NUM = 100;
float[] radius = new float[NUM];
PVector[] pos = new PVector[NUM];
int counter = 0;

!

void setup () {
size(800, 600);
frameRate(60);
noFill();
stroke(31, 127, 255);
strokeWeight(3);
for (int i = 0; i < NUM; i++) {
radius[i] = 0;
pos[i] = new PVector(width*2, width*2);
}
}
いろいろサンプル
SuperCollider client for Processing
‣ 拡がる四角形と、FM
SuperCollider client for Processing
‣ 拡がる四角形と、FM - Processing側:
import supercollider.*;
import oscP5.*;

!

int NUM = 100;
int count = 0;

!

PVector pos[] = new PVector[NUM];
float size[] = new float[NUM];
Synth fm[] = new Synth[NUM];

!

void setup() {
size(640, 480);
frameRate(60);
for (int i = 0; i < NUM; i++) {
pos[i] = new PVector(width*2, height*2);
size[i] = 0;
}
rectMode(CENTER);
}
SuperCollider client for Processing
‣ 拡がる四角形と、FM - Processing側:
void draw() {
background(0);
stroke(255, 127);
noFill();
strokeWeight(3);
for (int i = 0; i < NUM; i++) {
rect(pos[i].x, pos[i].y, size[i], size[i]);
if (size[i] > 0) {
size[i] += 1;
fm[i].set("index", size[i]);
}
if (size[i] > width/4) {
size[i] = 1;
}
}
}
SuperCollider client for Processing
‣ 拡がる四角形と、FM - Processing側:
void mouseReleased() {
int n = count % NUM;
pos[n].x = mouseX;
pos[n].y = mouseY;
size[n] = 1;
count++;
fm[n] = new Synth("fm1");
fm[n].set("amp", 0.2);
fm[n].set("freq", map(mouseY, height, 0, 40, 800));
fm[n].set("pan", map(mouseX, 0, width, -1.0, 1.0));
fm[n].set("modPartial", map(mouseY, 0, height, 1.0, 20.0));
fm[n].set("index", 0.0);
fm[n].create();
}
SuperCollider client for Processing
‣ 拡がる四角形と、FM - SuperCollider側:
//FM
SynthDef("fm1", { arg freq = 440, detune = 2, carPartial = 1, modPartial = 1, index = 3,
mul = 0.2, pan=0.0, amp=0.5;
var mod, car;
mod = SinOsc.ar(
[freq, freq+detune] * modPartial,
0,
freq * index * LFNoise1.kr(10.reciprocal).abs
);
car = Pan2.ar(SinOsc.ar((freq * carPartial) + mod, 0, mul), pan, amp);
Out.ar(0, car);
}).add;
SuperCollider client for Processing
‣ 左右に動く帯と、持続音
SuperCollider client for Processing
‣ 左右に動く帯と、持続音 - Processing側:
import supercollider.*;
import oscP5.*;

!

int BAR_NUM = 100;
int count = 0;

!

float[]
float[]
float[]
color[]

!

x = new float[BAR_NUM];
xSpeed = new float[BAR_NUM];
bWidth = new float[BAR_NUM];
bColor = new color[BAR_NUM];

void setup() {
size(640, 480);
frameRate(30);
colorMode(HSB, 360, 100, 100, 100);
noStroke();
for (int i=0; i<BAR_NUM; i++) {
x[i] = width * 2;
xSpeed[i] = random(-4, 4);
bWidth[i] = 0;
bColor[i] = color(random(360), random(90, 100), random(50, 100), 20);
}
//FX
Synth synth = new Synth("fx");
synth.create();
}
SuperCollider client for Processing
‣ 左右に動く帯と、持続音 - Processing側:
void draw() {
background(0);
for (int i=0; i<BAR_NUM; i++) {
fill(bColor[i]);
rect(x[i], 0, bWidth[i], height);
x[i] += xSpeed[i];
if (x[i] > width || x[i] < -bWidth[i]) {
xSpeed[i] *= -1;
}
}
}

!

void mouseReleased() {
int n = int(random(1, 12));
x[count] = mouseX;
bWidth[count] = n * 40;
count++;
Synth synth = new Synth("mySaw");
synth.set("n", n);
synth.set("gate", 1);
synth.create();
}
SuperCollider client for Processing
‣ 左右に動く帯と、持続音 - SuperCollider側:
!

SynthDef("mySaw", {
arg fadeTime = 10, n = 0, rq = 0.3, detune = 0.001, base = 20, ratio = 1.5, harm = 1.5,
amp = 0.2, gate=0;
var lfo, env, out;
env = EnvGen.kr(Env.new([0,1], [fadeTime], 'sine'));
lfo = SinOsc.ar(rrand(0.03, 0.05), 0, 100, 600);
out = Saw.ar([base+detune.rand, base+detune.rand] * (ratio ** n)) * amp
+ Saw.ar([base*harm+detune.rand, base*harm+detune.rand] * (ratio ** n)) * amp;
out = out * env;
out = RLPF.ar(out, lfo * (1.5 ** n), rq).clip2 * 0.5;
out = out * EnvGen.kr(Env.adsr(releaseTime:20), gate, doneAction: 2);
Out.ar(0, out);
}).store;

!

//エフェクト
SynthDef("fx", {
arg lpf=440, rq=0.5, amp=0.8;
var in, out;
in = In.ar(0, 2);
12.do({ in = AllpassL.ar(in, 0.1, LFNoise2.kr([rrand(0.0, 0.1),rrand(0.0, 0.1)],
0.01,0.06), 4.0) });
out = CompanderD.ar(in) * amp;
ReplaceOut.ar(0, out);
}).store;
SuperCollider client for Processing
‣ 課題の方向性
‣ シンプルなアニメーションと、簡単な楽器
‣ 組合せて、足しあわせることで、面白い結果を
!

‣ 残り時間は、質問受付にします!

More Related Content

PDF
Interactive Music II ProcessingとSuperColliderの連携1
PDF
Interactive Music II SuperCollider入門 4 - 楽器を定義、変調合成(RM, AM, FM)
PDF
Interactive Music II SuperCollider入門 5 時間構造をつくる
PDF
Interactive Music II SuperCollider入門 2 - 関数とUGen
PDF
Interactive Music II SuperCollider応用 - SuperColliderと OSC (Open Sound Control)
PDF
Interactive Music II - SuperCollider入門
PDF
Interactive Music II SuperCollider入門 3 - 音を混ぜる(Mix)、楽器を定義(SynthDef)
PDF
Exercices avec les solutions d'analyse complexe
Interactive Music II ProcessingとSuperColliderの連携1
Interactive Music II SuperCollider入門 4 - 楽器を定義、変調合成(RM, AM, FM)
Interactive Music II SuperCollider入門 5 時間構造をつくる
Interactive Music II SuperCollider入門 2 - 関数とUGen
Interactive Music II SuperCollider応用 - SuperColliderと OSC (Open Sound Control)
Interactive Music II - SuperCollider入門
Interactive Music II SuperCollider入門 3 - 音を混ぜる(Mix)、楽器を定義(SynthDef)
Exercices avec les solutions d'analyse complexe

What's hot (20)

PDF
Securing your AngularJS Application
PPTX
Steelcon 2014 - Process Injection with Python
PDF
Ts cours derivation_formulaire 6
PPTX
Part-1 : Mastering microcontroller with embedded driver development
PDF
STLの型の使い分け(ダイジェスト版) @ Sapporo.cpp 第7回勉強会 (2014.10.18)
PDF
unique_ptrにポインタ以外のものを持たせるとき
PDF
2 codage source
PDF
Vivado hls勉強会2(レジスタの挿入とpipelineディレクティブ)
PDF
コンピュータシステムの理論と実装2
 
PDF
Boost.SIMD
PDF
Arduinoをこれから始める人のためのArduino紹介スライドβ版
PDF
C++ マルチスレッド 入門
PPT
VGA VHDL RTL design tutorial
PDF
Tableaux derivees
DOC
Architecture et programmation des circuits CPLD et des FPGA
PDF
Mathématiques - Formule du crible
PDF
Klee and angr
PPTX
SIMDで整数除算
PDF
Rust と Wasmの現実
PDF
Instruction Combine in LLVM
Securing your AngularJS Application
Steelcon 2014 - Process Injection with Python
Ts cours derivation_formulaire 6
Part-1 : Mastering microcontroller with embedded driver development
STLの型の使い分け(ダイジェスト版) @ Sapporo.cpp 第7回勉強会 (2014.10.18)
unique_ptrにポインタ以外のものを持たせるとき
2 codage source
Vivado hls勉強会2(レジスタの挿入とpipelineディレクティブ)
コンピュータシステムの理論と実装2
 
Boost.SIMD
Arduinoをこれから始める人のためのArduino紹介スライドβ版
C++ マルチスレッド 入門
VGA VHDL RTL design tutorial
Tableaux derivees
Architecture et programmation des circuits CPLD et des FPGA
Mathématiques - Formule du crible
Klee and angr
SIMDで整数除算
Rust と Wasmの現実
Instruction Combine in LLVM
Ad

Viewers also liked (8)

PDF
「クリエイティブ・ミュージック・コーディング」- オーディオ・ビジュアル作品のための、オープンソースなソフトウエア・フレームワークの現状と展望
PDF
coma Creators session vol.2
PDF
プログラム初級講座 - メディア芸術をはじめよう
PDF
Interactive Music II Processing基本
PDF
Media Art II openFrameworks アプリ間の通信とタンジブルなインターフェイス
PDF
Interactive Music II SuperCollider応用 2 - SuperColliderとPure Dataの連携
PDF
Interactive Music II Processingによるアニメーション
PDF
メディア・アート II 第1回: ガイダンス openFrameworks入門
「クリエイティブ・ミュージック・コーディング」- オーディオ・ビジュアル作品のための、オープンソースなソフトウエア・フレームワークの現状と展望
coma Creators session vol.2
プログラム初級講座 - メディア芸術をはじめよう
Interactive Music II Processing基本
Media Art II openFrameworks アプリ間の通信とタンジブルなインターフェイス
Interactive Music II SuperCollider応用 2 - SuperColliderとPure Dataの連携
Interactive Music II Processingによるアニメーション
メディア・アート II 第1回: ガイダンス openFrameworks入門
Ad

More from Atsushi Tadokoro (18)

PDF
iTamabi 13 ARTSAT API 実践 5 - 衛星の軌道を描く
PDF
メディア芸術基礎 II 第11回:HTML5実践 表現のための様々なJavaScriptライブラリ
PDF
芸術情報演習デザイン(Web) 第8回: CSSフレームワークを使う
PDF
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 2
PDF
iTamabi 13 第9回:ARTSAT API 実践 3 ジオコーディングで衛星の位置を取得
PDF
Tamabi media131118
PDF
Webデザイン 第10回:HTML5実践 Three.jsで3Dプログラミング
PDF
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 1
PDF
iTamabi 13 第8回:ARTSAT API 実践 2 衛星アプリを企画する
PDF
Media Art II openFrameworks 複数のシーンの管理・切替え
PDF
Interactive Music II SuperCollider実習 オリジナルの楽器を作ろう!
PDF
Geidai music131107
PDF
iTamabi 13 第7回:ARTSAT API 実践 2 衛星の情報で表現する
PDF
Media Art II 2013 第7回 : openFrameworks 3Dグラフィクス、OpenGL
PDF
メディア芸術基礎 II Canvas + Javascriptで図形を描く
PDF
iTamabi 13  第6回:ARTSAT API 実践 1 Web APIから情報を取得する
PDF
Media Art II 2013 第6回:openFrameworks Addonを使う 2 - ofxOpenCV と ofxCv
PDF
iTamabi 13 第5回:ARTSAT API 導入
iTamabi 13 ARTSAT API 実践 5 - 衛星の軌道を描く
メディア芸術基礎 II 第11回:HTML5実践 表現のための様々なJavaScriptライブラリ
芸術情報演習デザイン(Web) 第8回: CSSフレームワークを使う
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 2
iTamabi 13 第9回:ARTSAT API 実践 3 ジオコーディングで衛星の位置を取得
Tamabi media131118
Webデザイン 第10回:HTML5実践 Three.jsで3Dプログラミング
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 1
iTamabi 13 第8回:ARTSAT API 実践 2 衛星アプリを企画する
Media Art II openFrameworks 複数のシーンの管理・切替え
Interactive Music II SuperCollider実習 オリジナルの楽器を作ろう!
Geidai music131107
iTamabi 13 第7回:ARTSAT API 実践 2 衛星の情報で表現する
Media Art II 2013 第7回 : openFrameworks 3Dグラフィクス、OpenGL
メディア芸術基礎 II Canvas + Javascriptで図形を描く
iTamabi 13  第6回:ARTSAT API 実践 1 Web APIから情報を取得する
Media Art II 2013 第6回:openFrameworks Addonを使う 2 - ofxOpenCV と ofxCv
iTamabi 13 第5回:ARTSAT API 導入

Recently uploaded (20)

PDF
Satish NS: Fostering Innovation and Sustainability: Haier India’s Customer-Ce...
PPTX
BUSINESS CYCLE_INFLATION AND UNEMPLOYMENT.pptx
PDF
Kishore Vora - Best CFO in India to watch in 2025.pdf
PPT
Retail Management and Retail Markets and Concepts
PDF
533158074-Saudi-Arabia-Companies-List-Contact.pdf
DOCX
Center Enamel Powering Innovation and Resilience in the Italian Chemical Indu...
PDF
Immigration Law and Communication: Challenges and Solutions {www.kiu.ac.ug)
PPTX
TRAINNING, DEVELOPMENT AND APPRAISAL.pptx
DOCX
Hand book of Entrepreneurship 4 Chapters.docx
PDF
#1 Safe and Secure Verified Cash App Accounts for Purchase.pdf
PPTX
IITM - FINAL Option - 01 - 12.08.25.pptx
DOCX
Handbook of Entrepreneurship- Chapter 5: Identifying business opportunity.docx
PPTX
interschool scomp.pptxzdkjhdjvdjvdjdhjhieij
PDF
Cross-Cultural Leadership Practices in Education (www.kiu.ac.ug)
PDF
Stacey L Stevens - Canada's Most Influential Women Lawyers Revolutionizing Th...
PPTX
Chapter 2 strategic Presentation (6).pptx
PDF
Chapter 2 - AI chatbots and prompt engineering.pdf
PDF
Consumer Behavior in the Digital Age (www.kiu.ac.ug)
PPTX
Market and Demand Analysis.pptx for Management students
PDF
Comments on Clouds that Assimilate Parts I&II.pdf
Satish NS: Fostering Innovation and Sustainability: Haier India’s Customer-Ce...
BUSINESS CYCLE_INFLATION AND UNEMPLOYMENT.pptx
Kishore Vora - Best CFO in India to watch in 2025.pdf
Retail Management and Retail Markets and Concepts
533158074-Saudi-Arabia-Companies-List-Contact.pdf
Center Enamel Powering Innovation and Resilience in the Italian Chemical Indu...
Immigration Law and Communication: Challenges and Solutions {www.kiu.ac.ug)
TRAINNING, DEVELOPMENT AND APPRAISAL.pptx
Hand book of Entrepreneurship 4 Chapters.docx
#1 Safe and Secure Verified Cash App Accounts for Purchase.pdf
IITM - FINAL Option - 01 - 12.08.25.pptx
Handbook of Entrepreneurship- Chapter 5: Identifying business opportunity.docx
interschool scomp.pptxzdkjhdjvdjvdjdhjhieij
Cross-Cultural Leadership Practices in Education (www.kiu.ac.ug)
Stacey L Stevens - Canada's Most Influential Women Lawyers Revolutionizing Th...
Chapter 2 strategic Presentation (6).pptx
Chapter 2 - AI chatbots and prompt engineering.pdf
Consumer Behavior in the Digital Age (www.kiu.ac.ug)
Market and Demand Analysis.pptx for Management students
Comments on Clouds that Assimilate Parts I&II.pdf

Interactive Music II ProcessingとSuperColliderの連携 -2

  • 2. 最終課題 ‣ 課題 : ‣ SuperCollider、またはSuperColliderとProcessingを連携して 表現する ‣ 音、または音と連動した映像 ‣ テーマは自由 ‣ 時間: 30分以内であれば、自由 ! ‣ 次週(1月23日)の授業で発表してください
  • 4. SuperCollider client for Processing ‣ ProcessingとSuperColliderの連携には、SuperCollider client for Processingが便利 ‣ OSCp5よりも簡単に、SuperColliderとProcessingの連携が可 能となる
  • 5. SuperCollider client for Processing ‣ SuperCollider側: 「test_inst」を定義 SynthDef("test_inst",{ arg freq=440, length=1.0, amp=0.5; var env, out; env = Env.perc(0.01, length); out = SinOsc.ar([freq,freq*1.001]) * EnvGen.kr(env, doneAction:2) * amp; Out.ar(0, out); }).store;
  • 6. SuperCollider client for Processing ‣ Processing側: クリックで音が鳴るように import supercollider.*; import oscP5.*; ! Synth synth; ! void setup () { size(600, 400); } ! void draw() { background(0); } ! //マウスクリックに反応 void mouseReleased() { //新規に楽器を定義(まだ生成はされず) synth = new Synth("test_inst"); //引数を設定 synth.set("amp", 0.5); synth.set("freq", map(mouseY, height, 0, 20, 8000)); //楽器を生成 synth.create(); }
  • 7. SuperCollider client for Processing ‣ たとえば、ここに円が拡がるアニメーションをつけてみる
  • 8. SuperCollider client for Processing ‣ Processing側: import supercollider.*; import oscP5.*; ! Synth synth; int NUM = 100; float[] radius = new float[NUM]; PVector[] pos = new PVector[NUM]; int counter = 0; ! void setup () { size(800, 600); frameRate(60); noFill(); stroke(31, 127, 255); strokeWeight(3); for (int i = 0; i < NUM; i++) { radius[i] = 0; pos[i] = new PVector(width*2, width*2); } }
  • 9. SuperCollider client for Processing ‣ Processing側: void draw() { background(0); for (int i = 0; i < NUM; i++) { ellipse(pos[i].x, pos[i].y, radius[i], radius[i]); radius[i] += 1; if(radius[i] > width*1.5){ radius[i] = 0; pos[i].x = width*2; pos[i].y = width*2; } } } ! void mouseReleased() { synth = new Synth("test_inst"); synth.set("amp", 0.5); synth.set("freq", map(mouseY, height, 0, 20, 8000)); synth.create(); int n = counter % NUM; radius[n] = 0; pos[n].x = mouseX; pos[n].y = mouseY; counter++; }
  • 10. SuperCollider client for Processing ‣ 完成!!
  • 11. SuperCollider client for Processing ‣ SuperColliderの楽器はそのままで、さらに別の例
  • 12. SuperCollider client for Processing ‣ Processing側: import supercollider.*; import oscP5.*; ! int NUM = 400; //配列の数 //位置のベクトルの配列 PVector[] location = new PVector[NUM]; //速度のベクトルの配列 PVector[] velocity = new PVector[NUM]; //塗りの色の配列 color[] col = new color[NUM]; //円の大きさ(直径)の配列 float[] diameter = new float[NUM]; ! void setup() { size(640, 480); //640x480pixelの画面を生成 frameRate(60); //フレームレート noStroke(); for (int i = 0; i < NUM; i++) { //配列の数だけ繰り返し //位置のベクトルの初期設定 location[i] = new PVector(random(width), random(height)); //速度のベクトルの初期設定 velocity[i] = new PVector(random(-4, 4), random(-4, 4)); //色の初期設定 col[i] = color(random(255), random(255), random(255), 127); //大きさの初期設定 } } diameter[i] = random(3, 40);
  • 13. SuperCollider client for Processing ‣ Processing側: void draw() { background(15); //背景を描画 //配列の数だけ繰り返し for (int i = 0; i < NUM; i++) { fill(col[i]); //色を指定 //指定した位置に円を描画 ellipse(location[i].x, location[i].y, diameter[i], diameter[i]); //位置のベクトルに速度のベクトルを加算、次の位置になる location[i].add(velocity[i]); //もし画面の左端、または右端に到達したら if ((location[i].x > width) || (location[i].x < 0)) { velocity[i].x *= -1; //X方向のスピドを反転 playSynth(location[i].x, location[i].y); } //もし画面の下端、または上端に到達したら if ((location[i].y > height) || (location[i].y < 0)) { velocity[i].y *= -1; //Y方向のスピードを反転 } } } playSynth(location[i].x, location[i].y); ! void playSynth(float x, float y) { //新規に楽器を定義(まだ生成はされず) Synth synth = new Synth("test_inst"); //引数を設定 synth.set("amp", 0.1); synth.set("freq", map(x, height, 0, 20, 8000)); //楽器を生成
  • 14. SuperCollider client for Processing ‣ Processing側: ! void playSynth(float x, float y) { //新規に楽器を定義(まだ生成はされず) Synth synth = new Synth("test_inst"); //引数を設定 synth.set("amp", 0.1); synth.set("freq", map(x, height, 0, 20, 8000)); //楽器を生成 } synth.create();
  • 15. SuperCollider client for Processing ‣ ボールのバウンドに反応
  • 16. SuperCollider client for Processing ‣ Processing側: import supercollider.*; import oscP5.*; ! Synth synth; int NUM = 100; float[] radius = new float[NUM]; PVector[] pos = new PVector[NUM]; int counter = 0; ! void setup () { size(800, 600); frameRate(60); noFill(); stroke(31, 127, 255); strokeWeight(3); for (int i = 0; i < NUM; i++) { radius[i] = 0; pos[i] = new PVector(width*2, width*2); } }
  • 18. SuperCollider client for Processing ‣ 拡がる四角形と、FM
  • 19. SuperCollider client for Processing ‣ 拡がる四角形と、FM - Processing側: import supercollider.*; import oscP5.*; ! int NUM = 100; int count = 0; ! PVector pos[] = new PVector[NUM]; float size[] = new float[NUM]; Synth fm[] = new Synth[NUM]; ! void setup() { size(640, 480); frameRate(60); for (int i = 0; i < NUM; i++) { pos[i] = new PVector(width*2, height*2); size[i] = 0; } rectMode(CENTER); }
  • 20. SuperCollider client for Processing ‣ 拡がる四角形と、FM - Processing側: void draw() { background(0); stroke(255, 127); noFill(); strokeWeight(3); for (int i = 0; i < NUM; i++) { rect(pos[i].x, pos[i].y, size[i], size[i]); if (size[i] > 0) { size[i] += 1; fm[i].set("index", size[i]); } if (size[i] > width/4) { size[i] = 1; } } }
  • 21. SuperCollider client for Processing ‣ 拡がる四角形と、FM - Processing側: void mouseReleased() { int n = count % NUM; pos[n].x = mouseX; pos[n].y = mouseY; size[n] = 1; count++; fm[n] = new Synth("fm1"); fm[n].set("amp", 0.2); fm[n].set("freq", map(mouseY, height, 0, 40, 800)); fm[n].set("pan", map(mouseX, 0, width, -1.0, 1.0)); fm[n].set("modPartial", map(mouseY, 0, height, 1.0, 20.0)); fm[n].set("index", 0.0); fm[n].create(); }
  • 22. SuperCollider client for Processing ‣ 拡がる四角形と、FM - SuperCollider側: //FM SynthDef("fm1", { arg freq = 440, detune = 2, carPartial = 1, modPartial = 1, index = 3, mul = 0.2, pan=0.0, amp=0.5; var mod, car; mod = SinOsc.ar( [freq, freq+detune] * modPartial, 0, freq * index * LFNoise1.kr(10.reciprocal).abs ); car = Pan2.ar(SinOsc.ar((freq * carPartial) + mod, 0, mul), pan, amp); Out.ar(0, car); }).add;
  • 23. SuperCollider client for Processing ‣ 左右に動く帯と、持続音
  • 24. SuperCollider client for Processing ‣ 左右に動く帯と、持続音 - Processing側: import supercollider.*; import oscP5.*; ! int BAR_NUM = 100; int count = 0; ! float[] float[] float[] color[] ! x = new float[BAR_NUM]; xSpeed = new float[BAR_NUM]; bWidth = new float[BAR_NUM]; bColor = new color[BAR_NUM]; void setup() { size(640, 480); frameRate(30); colorMode(HSB, 360, 100, 100, 100); noStroke(); for (int i=0; i<BAR_NUM; i++) { x[i] = width * 2; xSpeed[i] = random(-4, 4); bWidth[i] = 0; bColor[i] = color(random(360), random(90, 100), random(50, 100), 20); } //FX Synth synth = new Synth("fx"); synth.create(); }
  • 25. SuperCollider client for Processing ‣ 左右に動く帯と、持続音 - Processing側: void draw() { background(0); for (int i=0; i<BAR_NUM; i++) { fill(bColor[i]); rect(x[i], 0, bWidth[i], height); x[i] += xSpeed[i]; if (x[i] > width || x[i] < -bWidth[i]) { xSpeed[i] *= -1; } } } ! void mouseReleased() { int n = int(random(1, 12)); x[count] = mouseX; bWidth[count] = n * 40; count++; Synth synth = new Synth("mySaw"); synth.set("n", n); synth.set("gate", 1); synth.create(); }
  • 26. SuperCollider client for Processing ‣ 左右に動く帯と、持続音 - SuperCollider側: ! SynthDef("mySaw", { arg fadeTime = 10, n = 0, rq = 0.3, detune = 0.001, base = 20, ratio = 1.5, harm = 1.5, amp = 0.2, gate=0; var lfo, env, out; env = EnvGen.kr(Env.new([0,1], [fadeTime], 'sine')); lfo = SinOsc.ar(rrand(0.03, 0.05), 0, 100, 600); out = Saw.ar([base+detune.rand, base+detune.rand] * (ratio ** n)) * amp + Saw.ar([base*harm+detune.rand, base*harm+detune.rand] * (ratio ** n)) * amp; out = out * env; out = RLPF.ar(out, lfo * (1.5 ** n), rq).clip2 * 0.5; out = out * EnvGen.kr(Env.adsr(releaseTime:20), gate, doneAction: 2); Out.ar(0, out); }).store; ! //エフェクト SynthDef("fx", { arg lpf=440, rq=0.5, amp=0.8; var in, out; in = In.ar(0, 2); 12.do({ in = AllpassL.ar(in, 0.1, LFNoise2.kr([rrand(0.0, 0.1),rrand(0.0, 0.1)], 0.01,0.06), 4.0) }); out = CompanderD.ar(in) * amp; ReplaceOut.ar(0, out); }).store;
  • 27. SuperCollider client for Processing ‣ 課題の方向性 ‣ シンプルなアニメーションと、簡単な楽器 ‣ 組合せて、足しあわせることで、面白い結果を ! ‣ 残り時間は、質問受付にします!