Upcoming SlideShare
×

# Ssaw08 0624

1,745 views

Published on

1 Like
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total views
1,745
On SlideShare
0
From Embeds
0
Number of Embeds
472
Actions
Shares
0
45
0
Likes
1
Embeds 0
No embeds

No notes for slide

### Ssaw08 0624

1. 1. // Hello World quot;Hello World!quot;.postln; enter (return ) // ( ) ( quot;Hello World!quot;.postln; quot;Hello SuperColliderquot;.postln; )
2. 2. // quot;Hello Worldquot;.postln; // f = { 1 + 1 }; f.value; // f = { arg a, b; a + b; }; f.value(2, 3); // x = [1, 2, 3]; x.postln; // { SinOsc.ar( 440, 660], 0, 0.2) }.play;
3. 3. // f = { 1 + 1 }; f.value; // f = { arg a, b; a + b; }; f.value(2, 3); // f={ arg a, b; var firstResult, finalResult; firstResult = a + b; finalResult = firstResult * 2; finalResult; }; f.value(2, 3); // (2 + 3) * 2 = 10
4. 4. // 440HZ 0.2 { SinOsc.ar(440, 0, 0.2) }.play; // ( { // SinOsc.ar( // (.ar) 440, // 440HZ 0, // 0 0.2) // 0.2 } // .play; // 'play' )
5. 5. // f = { SinOsc.ar(440, 0, 0.2) }; f.play; // x = {arg freq=440; SinOsc.ar(freq, 0, 0.2)}.play; x.set(freq, 880); x.free; // ( 2ch) { SinOsc.ar([440, 660], 0, 0.2) }.play; x = {arg freq=440; SinOsc.ar([freq, freq+5], 0, 0.2)}.play; x.set(freq, 880); x.set(freq, 80); x.free;
6. 6. // { SinOsc.ar(440, 0, 0.2) }.play; //SynthDef SynthDef.new(quot;SinOsc_testquot;, { Out.ar(0, SinOsc.ar(440, 0, 0.2)) }).play; // +2ch ( SynthDef.new(quot;SinOsc-stereoquot;, { var outArray; outArray = [SinOsc.ar(440, 0, 0.2), SinOsc.ar(442, 0, 0.2)]; Out.ar(0, outArray) }).play; )
7. 7. // Server.default = Server.internal; s = Server.default; s.boot; ( SynthDef.new(quot;SinOsc-stereo-argsquot;, { arg freq=440, mul=0.2; var outArray; outArray = [SinOsc.ar(freq, 0, mul), SinOsc.ar(freq+2, 0, mul)]; Out.ar(0, outArray) }).send(s); ) x = Synth.new(quot;SinOsc-stereo-argsquot;); x.set(quot;freqquot;, 660); x.set(quot;mulquot;, 0.2); x.set(quot;freqquot;, 100, quot;mulquot;, 0.5); x.free;
8. 8. // quot;myServerquot; IP:127.0.0.1 port:12000 s = Server(quot;myServerquot;, NetAddr(quot;127.0.0.1quot;, 12000)); s.boot; //OSC s.dumpOSC(1); //SynthDef ( SynthDef.new(quot;sine-stereoquot;, { arg freq=440, mul=0.2; var outArray; outArray = [SinOsc.ar(freq, 0, mul), SinOsc.ar(freq+2, 0, mul)]; Out.ar(0, outArray) }).send(s); ) //OSC quot;sine-stereoquot; SyhtDef s.sendMsg(quot;s_newquot;, quot;sine-stereoquot;, s.nextNodeID, 0, 1); // s.sendMsg(quot;/n_freequot;, n); // s.quit;
9. 9. //SC Sin sine-stereo // quot;myServerquot; IP:127.0.0.1 port:12000 s = Server(quot;myServerquot;, NetAddr(quot;127.0.0.1quot;, 12000)); s.boot; //OSC s.dumpOSC(1); //SynthDef ( SynthDef.new(quot;sine-stereoquot;, { arg freq=440, mul=0.2; var outArray; outArray = [SinOsc.ar(freq, 0, mul), SinOsc.ar(freq+2, 0, mul)]; Out.ar(0, outArray) }).send(s); )
10. 10. // quot;myServerquot; IP:127.0.0.1 port:12000 s = Server(quot;myServerquot;, NetAddr(quot;127.0.0.1quot;, 12000)); s.boot; //OSC s.dumpOSC(1); //SynthDef ( SynthDef(quot; quot;, { arg note = 36, fc = 1000, rq = 25, bal=0, amp= -20, gate = 1; var x; x = Mix.fill(4, { LFSaw.ar((note + {0.1.rand2}.dup).midicps, 0, 0.02) }); x = RLPF.ar(x, fc, rq/100).softclip; x = RLPF.ar(x, fc, rq/100, amp.dbamp).softclip; x = Balance2.ar(x[0], x[1], bal); x = x * EnvGen.kr(Env.cutoff, gate, doneAction: 2); Out.ar(0, x); } ).load(s); )
11. 11. import oscP5.*; import netP5.*; OscP5 oscP5; NetAddress myRemoteLocation; Ring[] rings; int numRings = 50; int currentRing = 0; int synthId = 1; void setup() { size(400, 400); colorMode(HSB, 360, 100, 100, 100); frameRate(30); oscP5 = new OscP5(this,12000); myRemoteLocation = new NetAddress(quot;127.0.0.1quot;,12000); colorMode(HSB, 360, 100, 100, 100); smooth(); rings = new Ring[numRings]; for(int i = 0; i < numRings; i++){ rings[i] = new Ring(); } }
12. 12. void draw(){ background(0); for(int i = 0; i < numRings; i++){ rings[i].grow(); rings[i].display(); } } void mousePressed(){ //OSC OscMessage myMessage = new OscMessage(quot;/s_newquot;); myMessage.add(quot;env-sinequot;); myMessage.add(synthId); myMessage.add(1); myMessage.add(0); myMessage.add(quot;freqquot;); myMessage.add((height - mouseY) * 10); myMessage.add(quot;detunequot;); myMessage.add(((width/2) - mouseX)/30); oscP5.send(myMessage, myRemoteLocation); synthId++; rings[currentRing].start(mouseX, mouseY); currentRing++; if(currentRing >= numRings){ currentRing = 0; } }
13. 13. class Ring { float x, y; float diameter; boolean on = false; color col; void start(float _x, float _y){ x = _x; y = _y; on = true; diameter = 1; col = color(random(360), 50, 100, 50); } void grow() { if(on) { diameter++; if(diameter > 1000){ on = false; } } }
14. 14. void display(){ if(on){ noFill(); stroke(col); strokeWeight(4); ellipse(x, y, diameter, diameter); } } }
15. 15. // quot;myServerquot; IP:127.0.0.1 port:12000 s = Server(quot;myServerquot;, NetAddr(quot;127.0.0.1quot;, 12000)); s.boot; //OSC s.dumpOSC(1); // sin ( SynthDef(quot;env-sinequot;, { arg freq = 880, amp=0.125, detune=0; var env, x; env = EnvGen.kr(Env.perc(0.001,20,1,-4), doneAction: 2); x = env * SinOsc.ar([freq, freq+detune],0, amp); Out.ar(0, x)  }).send(s));
16. 16. import oscP5.*; import netP5.*; OscP5 oscP5; NetAddress myRemoteLocation; int numSpots = 24; Spot [] spots = new Spot[numSpots]; int synthId = 1; void setup() { size(400, 400); frameRate(30); oscP5 = new OscP5(this,12000); myRemoteLocation = new NetAddress(quot;127.0.0.1quot;,12000); smooth(); noStroke(); colorMode(HSB, 360, 100, 100, 100); for(int i = 0; i < spots.length; i++){ float x = (width / numSpots) * i + width/numSpots/2; float rate = (i+1)/4.0; color col = color(360/numSpots*i, 80, 50); spots[i] = new Spot(i, x, height/2, width/numSpots, rate, col);
17. 17. } } void draw() { background(0); for(int i = 0; i < spots.length; i++){ spots[i].move(); spots[i].display(); } } class Spot { int n; float x, y, diameter, speed; color spotColor; Spot(int _n,float _x,float _y,float _diameter,float _speed,color _spotColor) { n = _n; x = _x; y = _y; diameter = _diameter; speed = _speed; spotColor = _spotColor; }
18. 18. void move() { y += speed; if(y > height-(diameter/2) || y < diameter/2){ speed *= -1; //Send OSC Message OscMessage myMessage = new OscMessage(quot;/s_newquot;); myMessage.add(quot;env-sine-notequot;); myMessage.add(synthId); myMessage.add(1); myMessage.add(0); myMessage.add(quot;notequot;); if(y < diameter/2){ myMessage.add(n*4+36); } else { myMessage.add(n*4+12); } myMessage.add(quot;detunequot;); myMessage.add(6); oscP5.send(myMessage, myRemoteLocation); synthId++; } } void display() { fill(spotColor);
19. 19. ellipse(x, y, diameter, diameter); } }
20. 20. // quot;myServerquot; IP:127.0.0.1 port:12000 s = Server(quot;myServerquot;, NetAddr(quot;127.0.0.1quot;, 12000)); s.boot; //OSC s.dumpOSC(1); // sin ( SynthDef(quot;env-sine-notequot;, { arg note = 10, amp=0.125, detune=6; var env, x; env = EnvGen.kr(Env.perc(0.001,6,1,-4), doneAction: 2); x = env * SinOsc.ar([note.midicps, note.midicps+detune],0, amp); Out.ar(0, x)  }).send(s)); s.quit;