Created
April 28, 2013 04:32
-
-
Save umbrellaprocess/5475886 to your computer and use it in GitHub Desktop.
2005年のコードを、Kyoto SuperCollider Meetingの間に修正…したかったけど途中で断念。TabletViewがエラーで動かない。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
////////// SynthDef setup for "ANTARES" ////////// | |
( | |
// Pad1 | |
SynthDef("up-piano-24", { | |
arg freq=440, amp=1, outBus=0; | |
var x, e, mod, lfo; | |
e = Env.perc(0.01,1.2,1,-3); | |
x = SinOsc.ar(freq + SinOsc.ar(freq*3, 0, 200), 0, 1) * amp; | |
x = EnvGen.kr(e,1.0,doneAction: 2) * x; | |
Out.ar(outBus, Pan2.ar(x, LFNoise1.ar(2,1))); | |
}).store; | |
// Pad2 | |
SynthDef("up-piano-29", { | |
arg freq=440, gate=1.0, amp=1, pan=0, outBus=0; | |
var x, e, e2, mod1, mod2; | |
e = Env.asr(0.05,0.5,0.3,1,-3); | |
mod1 = SinOsc.ar(freq,0,700); | |
mod2 = Saw.ar(freq/2, pi*0.9); | |
x = SinOsc.ar(freq + mod1, mod2, 1) * amp; | |
x = EnvGen.kr(e,gate,doneAction: 2) * x; | |
Out.ar(outBus, Pan2.ar(x, pan)); | |
}).store; | |
// melody | |
SynthDef("antares-melody", { | |
arg note=1, gate=1, amp=1, rq=0.3, pan=0, outBus=0; | |
var x, e, freq, scale, buffer; | |
e = Env.asr(0.1,1,0.2,1,-3); | |
scale = FloatArray[0, 2, 3, 5, 7, 9, 10]; // d dur | |
buffer = Buffer.alloc(s, scale.size,1, {|b| b.setnMsg(0, scale) }); | |
freq = DegreeToKey.kr( | |
buffer.bufnum, | |
note, // input | |
12, // 12 notes per octave | |
1, // mul = 1 | |
53 // offset by 53 notes | |
).midicps; | |
x = BPF.ar(Saw.ar(freq), freq, rq) * amp; | |
x = EnvGen.kr(e,gate) * x; | |
Out.ar(outBus, Pan2.ar(x, pan)); | |
}).store; | |
// drums | |
SynthDef("up-snare-1", { | |
arg gate=1.0, amp=1, pan=0, outBus=0; | |
var x, e; | |
e = Env.perc(0.01,0.03,1,-3); | |
x = WhiteNoise.ar(amp); | |
x = EnvGen.kr(e,gate,doneAction: 2) * x; | |
Out.ar(outBus, Pan2.ar(x, pan)); | |
}).store; | |
SynthDef("up-kick-2", { arg outBus=0, amp=0.1, pan=0; | |
var env1, env2, env3, mod1, mod2, x; | |
env1 = Env.new([0.001,1,0.7,0.6,0], [0.001,0.003,0.1,0.1], -3); | |
env2 = Env.perc(0, 0.01, 1, -3); | |
env3 = Env.perc(0, 0.001, 1, -3); | |
mod1 = EnvGen.ar(env2) * 500; | |
mod2 = EnvGen.ar(env3) * 10; | |
x = SinOsc.ar(60 + mod1, 0, 1, mod2) * amp; | |
x = EnvGen.kr(env1, 1.0, doneAction:2) * x; | |
Out.ar(outBus, Pan2.ar(x, pan)); | |
}).store; | |
//effects | |
SynthDef("up-simpleDelay", { | |
arg inBus=0, outBus=1, delaytime=2, mul=0.5; | |
var x; | |
x = DelayN.ar( | |
In.ar(inBus, 2), | |
delaytime, delaytime, mul | |
); | |
Out.ar(outBus, x); | |
}).store; | |
SynthDef("up-simpleLPF", { | |
arg inBus=0, outBus=0, freq=440, mul=1; | |
var x; | |
x = LPF.ar(In.ar(inBus, 2), freq) * mul; | |
ReplaceOut.ar(outBus, x); | |
}, [0,0,3,3]).store; | |
SynthDef("reverb", | |
{ arg inBus=10, outBus=0; | |
var a,z,y,x; | |
a=InFeedback.ar(inBus,2); | |
z=DelayN.ar(a,0.048); | |
y=Mix.ar(Array.fill(7,{CombL.ar(z,0.1,LFNoise1.kr([0.1.rand,0.1.rand], 0.01,0.1),10)})); | |
x=AllpassN.ar(y,0.050,[0.050.rand,0.050.rand],1); | |
Out.ar(outBus,x); | |
} | |
).store; | |
// mixer | |
SynthDef("up-16chMixer", { | |
arg inBus=16,outBus=0,fxoutBus=32,fxinBus=34, | |
fx1=0,fx2=0,fx3=0,fx4=0,fx5=0,fx6=0,fx7=0,fx8=0, | |
mul1=0,mul2=0,mul3=0,mul4=0,mul5=0,mul6=0,mul7=0,mul8=0,mulFx=0; | |
var ch1,ch2,ch3,ch4,ch5,ch6,ch7,ch8,chFx,x; | |
ch1=In.ar(inBus+0,2); | |
ch2=In.ar(inBus+2,2); | |
ch3=In.ar(inBus+4,2); | |
ch4=In.ar(inBus+6,2); | |
ch5=In.ar(inBus+8,2); | |
ch6=In.ar(inBus+10,2); | |
ch7=In.ar(inBus+12,2); | |
ch8=In.ar(inBus+14,2); | |
Out.ar(fxoutBus, | |
(ch1*fx1)+(ch2*fx2)+(ch3*fx3)+(ch4*fx4)+ | |
(ch5*fx5)+(ch6*fx6)+(ch7*fx7)+(ch8*fx8) | |
); | |
chFx=In.ar(fxinBus,2); | |
x=(ch1*mul1)+(ch2*mul2)+(ch3*mul3)+(ch4*mul4)+ | |
(ch5*mul5)+(ch6*mul6)+(ch7*mul7)+(ch8*mul8)+(chFx*mulFx); | |
Out.ar(outBus, Limiter.ar(x,0.98)); | |
}).store; | |
) | |
///////////////// ANTARES ///////////////// | |
//////// 2005 by Takuro Hishikawa ///////// | |
( | |
var bpm,key,keys,scale,chordtype,looplist,progress,dur; | |
var currentloop,pad1,pad2,padamp,padamp2; | |
var snare,kick,noise,weight=0; | |
var w,slider1,slider2,button1,button2,tablet; | |
var spec1,spec2,spec3,spec4,spec5,spec6,spec7; | |
// define groups | |
~source = Group.head(s); | |
~effects = Group.tail(s); | |
~mixer = Group.tail(s); | |
bpm=100; // set tempo | |
key=60; // set base key | |
keys = Array.newClear(128); | |
scale=[ // set scale (c min) | |
0, 0, 2, 3, 3, 5, 5, 7, 8, 8,10,10, | |
12,12,14,15,15,17,17,19,20,20,22,22, | |
24,24,26,27,27,29,29,31,32,32,34,34]; | |
// 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 | |
// c,c#, d,d#, e, f,#f, g,#g, a,#a, h | |
chordtype=[ // define chords | |
[8,12,19], [10,14,17], // AbM7, Bb, | |
[12,15,22], [10,14,20], // Cm7, Bb7, | |
[12,15,19], [10,14,19] // Cm, Gm/Bb | |
]; | |
looplist=[ // group chords into several loops | |
[0,1],[2,3],[4,5] | |
]; | |
progress=Pxrand([0,1,2],inf).asStream; // choose loop | |
dur=Pseq([4],inf).asStream; | |
m=Synth.tail(~source, "antares-melody", [\gate, 0.0, \outBus, 16]); | |
Synth.head(~effects, "up-simpleDelay", [\delaytime, 45/bpm, \inBus, 16, \outBus, 26]); | |
Synth.tail(~effects, "up-simpleDelay", [\delaytime, 45/bpm, \inBus, 18, \outBus, 18]); | |
z=Synth.tail(~effects, "up-simpleLPF", [\inBus, 20, \outBus, 20, \mul, 0]); | |
Synth.tail(~effects, "reverb", [\inBus, 32, \outBus, 34]); | |
Synth.head(~mixer, "up-16chMixer", [ // mixer | |
\inBus, 16, \outBus, 0, \fxoutBus, 32, \fxinBus, 34, | |
\mul1, 0.7, \mul2, 0.6, \mul3, 0.9, \mul4, 0.3, \mul5, 0.3, \mul6, 0.35, | |
\fx2, 0.4, \fx3, 0.1, \fx4, 0.01, \fx5, 0.01, \fx6, 0.1, \mulFx, 0.1 | |
// 1->melody 2->pad1 3->pad2 4->snare 5->kick 6->melody-delay | |
]); | |
// gui setting | |
GUI.qt; | |
w = GUI.window.new("ANTARES", Rect(0, 0, 800, 600)); | |
slider1 = Slider(w, Rect(365, 150, 40, 200)); | |
slider1.canFocus = false; | |
slider2 = Slider2D(w, Rect(25, 50, 300, 300)); | |
slider2.canFocus = false; | |
button1 = Button(w, Rect(350, 100, 70, 30)); | |
button1.states = [["change", Color.black]]; | |
button1.canFocus = false; | |
button2 = Button(w, Rect(24, 500, 70, 40)); | |
button2.states = [["quit", Color.black]]; | |
button2.canFocus = false; | |
//tablet = TabletView(w,Rect(450, 50, 300, 300)); | |
tablet = Slider2D(w,Rect(450, 50, 300, 300)); | |
//tablet.background = Gradient(Color.blue, Color.white,\h); | |
tablet.canFocus = false; | |
spec1=ControlSpec(0.0, 0.2, \amp, 0, 0); | |
spec2=ControlSpec(200, 20000, \exponential, 0, 0); | |
spec3=ControlSpec(0.0, 7.0, \linear, default:0); | |
spec4=ControlSpec(1, 15, \linear, 1); | |
spec5=ControlSpec(1.0, 0.1, \amp, 0, 0); | |
spec6=ControlSpec(0.1, 1.0, \exp, 0.01, 0); | |
spec7=ControlSpec(0, 10, \linear, 0, 0); | |
slider1.action = { | |
weight=spec3.map(slider1.value); | |
}; | |
slider2.action = {arg slider; | |
padamp=spec1.map(slider2.x); | |
z.set(\mul, spec1.map(slider.y)); | |
z.set(\freq, spec2.map(slider.y)); | |
}; | |
button1.action = {|view| | |
var x,y,d; | |
x=1.0.rand; | |
y=1.0.rand; | |
d=1.0.rand; | |
padamp=spec1.map(x); | |
z.set(\mul, spec1.map(y)); | |
z.set(\freq, spec2.map(y)); | |
weight=spec3.map(d); | |
slider2.x_(x); | |
slider2.y_(y); | |
slider1.value_(d); | |
}; | |
tablet.action = {arg slider; | |
m.set(\note, spec4.map( slider.x/300 ) ); | |
m.set(\rq, spec5.map( slider.y/300 ) ); | |
}; | |
/* | |
tablet.action = { arg view,x,y,pressure,tiltx,tilty,deviceID, buttonNumber,clickCount,absoluteZ,rotation; | |
var note, rq; | |
note = x / 300; | |
rq = y / 300; | |
m.set(\note, spec4.map( note ) ); | |
m.set(\amp, spec6.map( pressure ) ); | |
m.set(\rq, spec5.map( rq ) ); | |
}; | |
*/ | |
/* | |
tablet.mouseDownAction = { arg view,x,y,pressure,tiltx,tilty,deviceID, buttonNumber,clickCount,absoluteZ,rotation; | |
m.set(\note, spec4.map( x / 300 ) ); | |
m.set(\amp, spec6.map( pressure ) ); | |
m.set(\gate, 1.0 ); | |
m.set(\rq, spec5.map( y / 300 ) ); | |
}; | |
tablet.mouseUpAction = { arg view,x,y,pressure,tiltx,tilty,deviceID, buttonNumber,clickCount,absoluteZ,rotation; | |
m.set(\note, spec4.map( x / 300 ) ); | |
m.set(\amp, spec6.map( pressure.min(0.6) ) ); | |
m.set(\gate, 0.0 ); | |
m.set(\rq, spec5.map( y / 300 ) ); | |
}; | |
*/ | |
slider1.value = spec1.unmap(spec1.default); | |
slider2.x = spec1.unmap(0.0); | |
slider2.y = spec1.unmap(0.0); | |
z.set(\mul, 0.0); | |
button2.action = {|view| | |
w.close; | |
pad1.stop; | |
pad2.stop; | |
snare.stop; | |
kick.stop; | |
SystemClock.clear; | |
s.sendMsg("g_freeAll", 1); | |
s.quit; | |
}; | |
// sound scheduling | |
pad1=Task({ | |
var note, loop, currentchord; | |
loop({ | |
currentchord=Pseq(currentloop,inf).asStream; | |
2.do({ | |
loop=chordtype.at(currentchord.next); | |
note=Pxrand(loop,inf).asStream; | |
16.do({ arg i; | |
Synth.tail(~source, "up-piano-24", [ | |
\freq,(scale.at(note.next)+key+[0,12,-12].choose).midicps, | |
\amp, padamp, | |
\outBus,18 | |
]); | |
(1/2).wait; | |
}); | |
}); | |
}); | |
},TempoClock(bpm/60)); | |
pad2=Task({ | |
var node, num, loop, currentchord; | |
loop({ | |
currentchord=Pseq(currentloop,inf).asStream; | |
2.do({ | |
loop=chordtype.at(currentchord.next); | |
3.do({ arg i; | |
num=scale.at(loop.at(i))+key; | |
node=Synth.tail(~source, "up-piano-29",[ | |
\freq,(num-12).midicps, | |
\amp,1, | |
\outBus, 20 | |
]); | |
keys.put(num,node); | |
}); | |
8.wait; | |
3.do({ arg i; | |
num=scale.at(loop.at(i))+key; | |
node=keys.at(num); | |
s.sendMsg("/n_set",node.nodeID,\gate,0.0); | |
keys.put(num,nil); | |
}); | |
}); | |
}); | |
},TempoClock(bpm/60)); | |
snare=Task({ | |
var pat, t; | |
pat = Pseq([0,1, 1,1, 9,1, 1,5, 1,4, 0,1, 9,4, 2,5], inf).asStream; | |
loop({ | |
t = pat.next; | |
if( weight > 1, { | |
if( (t + weight) > 8, { | |
if((t*0.1).coin, { | |
Synth.tail(~source, "up-snare-1",[ | |
\amp,1, | |
\outBus, 22 | |
]); | |
}); | |
}); | |
}); | |
(1/4).wait; | |
}); | |
},TempoClock(bpm/60)); | |
kick=Task({ | |
var pat, t; | |
pat = Pseq([9,2, 2,2, 0,2, 5,2, 4,2, 7,3, 0,4, 2,4], inf).asStream; | |
loop({ | |
t = pat.next; | |
if( weight > 0, { | |
if( (t + weight) > 8, { | |
if((t*0.1).coin, { | |
Synth.tail(~source, "up-kick-2",[ | |
\amp, 1, | |
\outBus, 24 | |
]); | |
}); | |
}); | |
}); | |
(1/4).wait; | |
}); | |
},TempoClock(bpm/60)); | |
SystemClock.sched(0,{currentloop=looplist.at(progress.next).postln; dur.next*120*rrand(2,8)/bpm;}); | |
SystemClock.sched(0,{snare.start}); | |
SystemClock.sched(0,{kick.start}); | |
SystemClock.sched(0,{pad1.start}); | |
SystemClock.sched(0,{pad2.start}); | |
w.front; | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment