Last active
December 5, 2017 19:40
-
-
Save furenku/eea43c9d00a83344cee774d3c4a76190 to your computer and use it in GitHub Desktop.
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
( | |
( | |
Server.default.options.memSize= 512000*20; | |
Server.default.options.numWireBufs= 512; | |
s = Server.local; | |
s.boot; | |
); | |
~path = thisProcess.nowExecutingPath.dirname; | |
s.waitForBoot({ | |
(~path ++"/data_definitiva.scd").load; | |
v = SoundFile.collectIntoBuffers(~path++"/wavetable/*",s); | |
~amplitudPianola= 0; | |
~part = 6; | |
( | |
/*microtonal piano Synth*/ | |
SynthDef(\pianola, | |
{ |fund=30, freq=1.0, decayTime=0.5, amp=0.95, temp=100, out=100, done=2, pan=0, att=0.001, sus=0.1, rel=0.1, object=0.005, which=0, id, value| | |
var sig, env, strike, envAttack, noise, delayTime, deTune; | |
strike= Trig.ar(Impulse.ar((freq.asFloat.midicps)/temp),0.0001); | |
envAttack= Decay2.ar(strike, 0.008, 0.03); | |
noise= Mix(LFNoise2.ar([375,750,1500,3000], envAttack)); | |
sig= Mix(Array.fill(4,{|i| | |
deTune= #[-0.05,0.01,0.04,-0.01].at(i); | |
delayTime= 1/((freq.asFloat.midicps)+deTune); | |
CombL.ar( | |
noise, delayTime, delayTime, decayTime | |
) | |
})); | |
sig= sig + (GVerb.ar(sig, 20,1, mul:0.1)); | |
sig= SelectX.ar(which,[sig, CombC.ar(sig, 1, object, 0.3, 1)]); | |
env= EnvGen.kr(Env([0,1,1,0],[att,sus,rel]),doneAction: done); | |
SendTrig.ar(EnvGen.ar(Env.perc(0.00001,0.001)), id, value); | |
Out.ar(out, Limiter.ar(Pan2.ar(Mix(sig),pan)*amp,0.1)*env) | |
}; | |
).add; | |
); | |
( | |
// Synths filters and instruments ; | |
~amps_Synths= [1,0, 0.5,0.2,0.8]; | |
( | |
SynthDef(\dxkBd1, {|t_trig = 1, basefreq = 45, overdrive = 2, len=0.5, att = 0.002, fgprop =0.3, fgdprop = 0.9, noisiness=0.2, lop = 1250, amp = 1, pan = 0, out = 0| | |
//fgprop = frequency glide in proportion to freq | |
//fgdprop = freq glide duration in proportion to dur | |
//freq = fundamental | |
var freqenv, noise, main, fgdur, fgact, env; | |
fgdur = Clip.ir(len * fgdprop, 0, len); //real value of fgdprop | |
fgact = fgprop*basefreq; //actual hz to glide over | |
freqenv = EnvGen.ar(Env.perc(att, fgdur, fgact, -4),t_trig); | |
freqenv = (freqenv + basefreq) + PinkNoise.ar(noisiness); | |
main = SinOsc.ar(freqenv); | |
main = LPF.ar(main, lop); | |
env = EnvGen.ar(Env.perc(att, len, amp, -4), t_trig, doneAction: 2); | |
main = main * env; | |
main = (main * overdrive).tanh; | |
main = Pan2.ar(main, pan); | |
Out.ar(out, main); | |
}).add; | |
//adapted from joe sullivan's synthesizing hihats http://joesul.li/van/synthesizing-hi-hats/ | |
SynthDef(\dxkHh1, {|t_trig = 1, basefreq = 40, att = 0.001, len = 0.1, rq = 0.1, hpfreq = 7000, lopfreq = 10000, out = 0, pan = 0, amp = 1| | |
var freqarr, output, env; | |
freqarr = basefreq * [2,3,4.16, 5.43, 6.79,8.21]; | |
output = Mix.ar(Pulse.ar(freqarr, mul:1/freqarr.size)); | |
output = BPF.ar(output, 10000, rq); | |
output = RHPF.ar(output, 7000, rq); | |
env = EnvGen.ar(Env.perc(att, len, amp), t_trig, doneAction: 2); | |
output = output *env; | |
output = Pan2.ar(output, pan); | |
Out.ar(out, output); | |
}).add; | |
SynthDef(\dxkHh2, {|t_trig = 1, len = 0.125, att = 0.001, rq = 0.35, lp = 10000, bplow = 5000, bphigh = 8000, amp = 1, pan = 0, out = 0| | |
var bpenv, main, env,glide; | |
env = EnvGen.ar(Env.perc(att, len, 1 -8), doneAction:2); | |
glide = (bphigh-bplow).abs; | |
main = WhiteNoise.ar() *env; | |
bpenv = EnvGen.ar(Env.perc(att, len, glide, -8)); | |
bpenv = (glide-bpenv)+bplow.min(bphigh); | |
main = BPF.ar(main, bpenv, rq); | |
main = LPF.ar(main, lp); | |
main = main * amp; | |
main = Pan2.ar(main, pan); | |
Out.ar(out, main); | |
}).add; | |
SynthDef(\dxkSd1, {|t_trig = 1, basefreq = 300, len = 0.125, fgprop = 0.5, fgdprop = 0.75, rq = 0.1, lop = 5000, att = 0.002, amp = 1, pan = 0, out = 0| | |
//penv = pitch envelope | |
//fgprop = frequency glide in proportion to freq | |
//fgdprop = freq glide duration in proportion to dur | |
//freqbase = fundamental | |
var output, ampenv, penv, gaincomp = 9; | |
output = WhiteNoise.ar()*gaincomp; | |
penv = EnvGen.ar(Env.perc(att, len*fgdprop, basefreq*fgprop), t_trig); | |
penv = penv + basefreq; | |
output = BPF.ar(output,penv, rq); | |
output = LPF.ar(output, lop, amp); | |
ampenv = EnvGen.ar(Env.perc(att, len), t_trig, doneAction: 2); | |
output = output * ampenv; | |
output = Pan2.ar(output, pan); | |
Out.ar(out, output); | |
}).add; | |
//adapted+modified from snare1.pd pure data patch by user ichabod of pdpatchrepo | |
SynthDef(\dxkSd2, {|t_trig = 1, basefreq = 180, freq1amp = 0.75, freq2amp = 1, lopfreq = 1000, hipfreq = 950, lopamp = 0.5, hipamp = 1, att = 0.001, len = 0.1, amp = 1, pan = 0, out = 0| | |
var oscs, oenv1, oenv2, noise, lonoise, loenv, hinoise, hienv, output; | |
oscs = SinOsc.ar([basefreq, basefreq*1.83], 0, [0.75, 1]); | |
oenv1 = EnvGen.ar(Env.perc(att, len*0.53), t_trig); | |
oenv2 = EnvGen.ar(Env.perc(att, len), t_trig, doneAction: 2); | |
oscs = Mix.new(oscs * [oenv1, oenv2]); | |
noise = WhiteNoise.ar(); | |
lonoise = LPF.ar(noise, lopfreq); | |
loenv = EnvGen.ar(Env.perc(att, len*0.6, lopamp), t_trig); | |
lonoise = lonoise * loenv; | |
hinoise = HPF.ar(noise, hipfreq); | |
hienv = EnvGen.ar(Env.perc(att, len*0.46,hipamp), t_trig); | |
hinoise = hinoise*hienv; | |
output = oscs + lonoise + hinoise; | |
output = Pan2.ar(output, pan)*amp; | |
Out.ar(out, output); | |
}).add; | |
//adapted+modified from snare2.pd pure data patch by user ichabod of pdpatchrepo | |
SynthDef(\dxkSd3, {|t_trig = 1, basefreq = 150, att = 0.001, len = 0.3, lopfreq = 1200, rq = 0.3, tone = 0.7, snare = 0.5, amp = 1, pan = 0, out = 0| | |
var freqs, rqs, bpmuls, fenv, drumhead, snares, noise, nmul, lonoise, hinoise, output, nenv, rand, lofreq, hifreq, loenv, hienv, lomul; | |
//random number | |
rand = TIRand.kr(0,101, t_trig); | |
freqs = basefreq * [1, 2.03, 3.26, 4.6]; | |
rqs = rq * [1/2, 1, 1/2, 1/2]; | |
bpmuls = 3 * [8.333, 10, 5, 1]; | |
fenv = EnvGen.ar(Env.perc(att, len), t_trig, doneAction: 2); | |
noise = WhiteNoise.ar(1.4)+1.4; | |
noise = Select.ar(noise, [DC.ar(-1), DC.ar(0), DC.ar(1)]); | |
nmul = rand/800.0 + 0.875; | |
nenv = EnvGen.ar(Env.perc(att, len*0.46, nmul), t_trig); | |
noise = noise * nenv; | |
//drum head formants | |
drumhead = Resonz.ar(LPF.ar(noise, lopfreq), freqs, rqs, bpmuls); | |
drumhead = drumhead * tone; | |
//snares | |
lofreq = rand + 900; | |
hifreq = lofreq* 0.95; | |
lonoise = LPF.ar(noise, lofreq); | |
lomul = (rand/500.0) + 0.4; | |
loenv = EnvGen.ar(Env.perc(att, len*0.66,lomul), t_trig); | |
lonoise = lonoise * loenv; | |
hinoise = HPF.ar(noise, hifreq); | |
hienv = EnvGen.ar(Env.perc(att, len*0.466), t_trig); | |
hinoise = hinoise * hienv; | |
snares = lonoise + hinoise; | |
snares = snares * snare; | |
output = drumhead + snares; | |
output = Pan2.ar(output, pan); | |
Out.ar(out, output); | |
}).add; | |
//adapted from the ryan brown synthdef \cymbal808_ryan from the supercollider-quarks | |
//synthdefpool | |
SynthDef(\dxkCymb808_1, {|t_trig = 1, basefreq = 205.35, len = 0.25, sustain = 0.5, att = 0.001, out = 0, pan = 0, amp = 1| | |
var freqArray, sig1, sig2,env, sig1env, output; | |
freqArray = basefreq * [ 1, 1.4823959094229, 1.800048697346, 2.545458972486, 2.6322863403944, 3.9552471390309 ]; | |
sig2 = Pulse.ar(freqArray, 0.55, 0.9); | |
sig2 = Mix.ar(sig2); | |
sig1 = Pulse.ar(freqArray, 0.5); | |
sig1 = Mix.ar(sig1); | |
sig1 = ( BinaryOpUGen('==', sig1, 6) * 0.6) + ( BinaryOpUGen('==', sig1, 2)*0.2)+( BinaryOpUGen('==', sig1, 1)*0.9); | |
sig1env = EnvGen.ar(Env([1.0, 1.0, 0.6], [att, len], -4)); | |
env = EnvGen.ar(Env([1.0, 0.4, 0], [att, len, 0.05], -4)); | |
output = sig1 + sig2; | |
output = SOS.ar(output, 0.175812, 0.351623, 0.175812, 0.834059, -0.537305); | |
output = SOS.ar(output, 0.669886, -1.33977, 0.669886, 0.968752, -0.710791); | |
output = SOS.ar(output, 0.669886, -1.33977, 0.669886, 0.968752, -0.710791 ); | |
output = output * env; | |
output = DelayN.ar(output, 0.005, 0.005); | |
output = FreeVerb.ar(output, sustain); | |
DetectSilence.ar(output, doneAction:2); | |
output = Pan2.ar(output*amp, pan); | |
Out.ar(out, output); | |
}).add; | |
SynthDef(\dxkUWoodBank, {|t_trig = 1, freq = 100, pitchy = 0.75, amp = 1, pan = 0, out = 0| | |
var freqs = freq * [1, 2.572, 4.644, 6.984, 9.823, 12]; | |
var amps = [1, 1, 0.75, 0.75, 0.5, 0.1, 0.1] * freqs.size.reciprocal; | |
var rings = [0.1, 0.01, 0.01, 0.05, 0.01, 0.01]*pitchy; | |
var exciter = Trig.ar(t_trig, 64/SampleRate.ir); | |
var output = Klank.ar(`[freqs, amps, rings], exciter); | |
output = Pan2.ar(output, pan); | |
DetectSilence.ar(output, doneAction: 2); | |
Out.ar(out, output); | |
}).add; | |
//doesn't sound good at low freqs | |
SynthDef(\dxkWineBank, {|t_trig = 1, freq = 1000, pitchy = 1, amp = 1, pan = 0, out = 0| | |
var freqs = freq * [1, 2.32, 4.25, 6.63, 9.38]; | |
var amps = [1, 0.6, 0.4, 0.2, 0.1] * freqs.size.reciprocal; | |
var rings = [1, 0.8, 0.6, 0.4, 0.4]*pitchy; | |
var exciter = Trig.ar(t_trig, 64/SampleRate.ir); | |
var output = Klank.ar(`[freqs, amps, rings], exciter); | |
output = Pan2.ar(output, pan); | |
DetectSilence.ar(output, doneAction: 2); | |
Out.ar(out, output); | |
}).add; | |
); | |
( | |
SynthDef(\mainOut, {|out=0, in=30, amp=1, gate=1| | |
var sig, env; | |
sig= Compander.ar(In.ar(in,2),WhiteNoise.ar(0.7)).distort; | |
env= EnvGen.kr(Env.asr(0.01,1),gate, doneAction:2); | |
Out.ar(out, sig*env*amp) | |
}).add; | |
); | |
( | |
SynthDef(\kps, {|freq=60, in=10, dur=0.1, amp=1, pan=0, att=0.0001, dec=0.1, out=30, gate=1| | |
var sig, env; | |
sig= In.ar(in, 2); | |
sig= CombC.ar(sig, freq.midicps.reciprocal, freq.midicps.reciprocal, dur*1.2, amp); | |
sig= Pan2.ar(sig, pan); | |
env= EnvGen.kr(Env.asr(0.001,1),gate, doneAction:2); | |
Out.ar(out, sig*env) | |
}).add; | |
); | |
( | |
SynthDef(\kps_2, {|freq=60, in=12, dur=0.1, amp=1, pan=0, att=0.0001, dec=0.1, out=30, gate=1| | |
var sig, env; | |
sig= In.ar(in, 2); | |
sig= CombC.ar(sig, freq.midicps.reciprocal, freq.midicps.reciprocal, dur*1.2, amp).fold(-0.8,0.1); | |
sig= Pan2.ar(sig, pan); | |
env= EnvGen.kr(Env.asr(0.001,1),gate, doneAction:2); | |
Out.ar(out, sig*env) | |
}).add; | |
); | |
( | |
SynthDef(\reverb, {|in=14, amp=1, pan=0, att=0.0001, dec=0.1, out=30, gate=1| | |
var sig, env, in1, in2; | |
in1= In.ar(in,1); | |
in2= In.ar(in+1,1); | |
sig= FreeVerb2.ar(in1,in2, 0.4, 0.4, 0.4,amp); | |
env= EnvGen.kr(Env.asr(0.001,1),gate, doneAction:2); | |
Out.ar(out, sig*env) | |
}).add; | |
); | |
( | |
SynthDef(\bass, {|freq= 60, in=16, dur=0.1, amp=1, pan=0, out=30, gate=1| | |
var trig, sig, env; | |
trig= Trig.ar(In.ar(in), 0.0000000001); | |
sig= Decay2.ar(trig*0.1, 0.001, 0.5, SinOsc.ar(freq.midicps*0.5, 0, amp*0.8)); | |
sig= Pan2.ar(sig,pan); | |
env= EnvGen.kr(Env.asr(0.001,1),gate, doneAction:2); | |
Out.ar(out, sig*env) | |
}).add; | |
); | |
( | |
SynthDef(\lead, { | |
arg gate=1, out=30, ibuf= v[0].bufnum, offset=0.65, | |
amp1=0.25, amp2=0.25, amp3=0.5, | |
dt1=0.05, dt2= -0.05, dt3= 0, | |
att=0.01, dec= 0.1, rel= 20, decLevel= 0.05, | |
attF= 0.03, decF=1.2, susFLv= 0.07, relF= 1, | |
coH= 20000, coL= 50, rq= 0.1, | |
lfo1Freq=35, lfo1Width= 3, lfo2Freq= 0.2, lfo3Freq= 0.06, glide= 0.5; | |
var osc1, osc2, osc3; | |
var lfo1, lfo2, lfo3; | |
var sig, sig2, env, env_filt, freq1, freq2, freq3, cutOff; | |
var amp, pitch; | |
pitch = \pitch.kr(60, glide); | |
amp = \amp.kr(1, 0.3); | |
env = EnvGen.ar(Env([0,1,decLevel,0],[att, dec, rel]),gate, doneAction:2); | |
env_filt = EnvGen.ar(Env.adsr(attF, decF, susFLv, relF, 1, -2),gate); | |
cutOff = env_filt; | |
lfo1 = SinOsc.kr(lfo1Freq*cutOff)*lfo1Width; | |
lfo2 = SinOsc.kr(lfo2Freq); | |
lfo3 = SinOsc.kr(lfo3Freq); | |
freq1 = (pitch+(dt1*lfo2)).midicps; | |
freq2 = (pitch+(dt2*lfo2)).midicps; | |
freq3 = (pitch+(dt3*lfo3)).midicps; | |
osc1 = Saw.ar(freq1)*amp1; | |
osc2 = Saw.ar(freq2)*amp2; | |
osc3 = VOsc3.ar(ibuf+offset, freq3+[0,1],freq3+[0.37,1.1],freq3+[0.43, -0.29], 0.333333)*amp3; | |
sig = Mix([osc1, osc2, osc3]); | |
sig = RLPF.ar(sig, (((cutOff*coH)+coL).cpsmidi+lfo1).midicps, rq); | |
sig2 = DelayC.ar(sig, 0.2, 0.03); | |
Out.ar(out, [sig, sig2].distort*env*amp); | |
}).add; | |
); | |
); | |
~outSynth= Synth(\mainOut); | |
~kps= Synth(\kps); | |
~kps_2= Synth(\kps_2); | |
~reverb= Synth(\reverb); | |
~bass= Synth(\bass); | |
//net Address | |
~ip= ["127.0.0.1", "169.254.202.190", "169.254.202.190"]; | |
~netAddr = NetAddr(~ip[0], 57120); | |
~netAddr_0 = NetAddr(~ip[0], 57120); | |
// ~netAddr.sendMsg("quibo") | |
OSCdef(\ping, { |msg, time, addr, port| [msg, time, addr, port].postln; | |
{~bot_2.value = 1;}.defer; | |
~todo = ~ptpar.play; | |
~task.play; | |
~taskScore.play | |
}, "/on_off", recvPort:57120 ); | |
( //compile all this to assign the values to the variables; | |
//tempo | |
~tempo= 5; | |
// number of cP for the sound object; | |
//~cPs= (0!56).pyramid.size; | |
~cPs= ~rhythm_CPs_data_25_08_2017_0.size; | |
// the rhythmic pattern, amount of convergence points (array size) in the object, and rhythmic figures for each); | |
// data here for the timespan between CPs | |
~object= Array.fill(~cPs+1, {|i| if(i==0, {3}, { ~rhythm_CPs_data_25_08_2017_0[i-1].linlin(~rhythm_CPs_data_25_08_2017_0.minItem,~rhythm_CPs_data_25_08_2017_0.maxItem, ~rhythm_CPs_data_25_08_2017_0.minItem*1,~rhythm_CPs_data_25_08_2017_0.maxItem*1.5) }) }); | |
//~object= [~object[0]] ++ ~object[1]; | |
// algorithm to establish the onset time for each cp, the chronometric coordinates of every convergence point; | |
~distances= Array.newClear(~object.size); | |
~object.size.do{|i| | |
if(i==0, { ~object[0]; ~distances.put(0, ~object[0]) }, | |
{ ~object[i]+~distances[i-1]; ~distances.put(i, ~object[i]+~distances[i-1]) }) }; | |
// number of timePoints for each trajectory; in this code, the number of time points assign to each line is the same, in a new iteration of the code an algorithm to assign a different number of time points to each line will be created | |
// data here!!! | |
~tp= Array.fill(~cPs, {|i| ~timePoints_25_08_17_0[i].linlin(1,13,2,10) }); | |
~tp= ~tp.asInteger; | |
// lines that traverse the object, it is the same as the convergence points of the isorythm | |
~line= Array.newClear(~cPs); | |
// triplet values assign to all the lines. For a more interesting outcome I will use different rhythmic values for each line; | |
~cPs.do{|i| ~line.put(i , Array.fill(~tp[i],{ (1/6) }) )}; | |
// rhythmic values in one array | |
~r_vals = Array.fill(~cPs, {|i| ~rhythm_TPs_25_08_17_0[i].linlin(~rhythm_TPs_25_08_17_0.minItem, ~rhythm_TPs_25_08_17_0.maxItem, 5, 18).reciprocal }); | |
// data here!! | |
//~r_values = [10,13,17,12,16,18,11,9,20,10, 19,10,8,7,13,5,23,17,11,9, 10,13,17,21,36,8,13,19,30,24, 7,10,9,7,12,15,13,17,12,4, 3,10,19,17,25,15,13,17,12,6, 17,16,15,14,13,8].reciprocal.pyramid; | |
~cPs.do{|i| ~line[ i].put((0..(~tp[ i]-1)), ~r_vals[i]) }; | |
// the convergence point for each trajectory, index of the timepoint in which the lines will converge; | |
// data here | |
~cp= Array.fill(~cPs, {|i| ~convergencePoints_25_08_17_0[i].linlin(1,13,2,10) }); | |
~cp= ~cp.asInteger; | |
// the segment of all patterns before the convergence point | |
~bcp= Array.newClear(~cPs); | |
(~cPs).do{|i| ~bcp.put(i, Array.fill(~tp[i]-(~tp[i]-~cp[i]), {|j| ~line[i][j] }) ) }; | |
~bcp.insert(0, [0]); | |
// melodic patterns for the sound object; | |
~melody= Array.fill(~cPs+1, { [71, 72, 80, 79, 76, 77, 84, 75, 70, 73, 72, 69, 65, 78, 77, 80, 82, 83, 88, 76, 81, 86, 85, 83, 82, 78, 81, 74, 77, 76, 67, 75, 70, 92, 90, 89, 92, 91, 84, 85, 82, 83, 80, 76, 81, 69, 70, 73, 78, 77, 87, 86, 84, 72].wrapExtend(~cPs+1) }); | |
~melody= ~melody[0]; | |
~mel= Array.newClear(~cPs+1); | |
(~cPs+1).do{|i| | |
~mel.put(i, Array.series(~bcp[i].size, ~melody[i]-2, ~melody[i]-(~melody[i]-2)/(~bcp[i].size) )) | |
}; | |
// ID ; | |
~ids_X = Array.newClear(~cPs); | |
~cPs.do{|i| ~ids_X.put(i , Array.fill(~tp[i],{ ((i)%7)+1 }) ) }; | |
// patterns !!! | |
( | |
// object pattern; | |
~objectPatt= Pbind(\instrument, \pianola, \pan, 0, \dur, Pseq(~object*~tempo,1), \freq, Pseq(~melody-12,inf), \amp, Pseq([0]++(1!~cPs),inf)*~amplitudPianola, | |
\event, Pfunc({|event| if( ~part==event[\id], {~netAddr_0.sendMsg('/event', event[\freq], event[\dur], event[\id])}; | |
) })); | |
// iterate the patterns | |
d = Dictionary.new(); | |
d.put(\pat, Dictionary.new); | |
~cPs.do{|i| | |
d[\pat].put(i.asSymbol, | |
Pbind(\instrument, \pianola, \pan, 0, \dur, Pseq(~line[i]*~tempo,1), \freq, Pseq(~mel[i+1]++~melody[i+1]++~mel[i+1].reverse,inf), \amp, 1*~amplitudPianola, \id, Pseq(~ids_X[i], inf), \value, Pkey(\dur), | |
\evento, Pfunc({|event| if( ~part==event[\id], {~netAddr_0.sendMsg('/event', event[\freq], event[\dur], event[\id])}; | |
) })); | |
) | |
} | |
); | |
// second layer of trajectories ; | |
~tp2= Array.fill(~cPs, {|i| ~timePoints_25_08_17_0[i].linlin(1,13,2,10) }); | |
~tp2= ~tp2.asInteger; | |
// lines that traverse the object, it is the same as the convergence points of the isorythm | |
~line2= Array.newClear(~cPs); | |
// triplet values assign to all the lines. For a more interesting outcome I will use different rhythmic values for each line (this line is inoperative for this code); | |
~cPs.do{|i| ~line2.put(i , Array.fill(~tp2[i],{ (1/6) }) )}; | |
// Assign rhythmic values | |
( | |
~r_vals2 = Array.fill(~cPs, {|i| ~rhythm_TPs_25_08_17_0[i].linlin(~rhythm_TPs_25_08_17_0.minItem, ~rhythm_TPs_25_08_17_0.maxItem, 9, 27).reciprocal }); | |
//~r_values2 = ~r_values.reverse; | |
~cPs.do{|i| ~line2[i].put((0..(~tp2[i]-1)), ~r_vals2[i]) }; | |
); | |
// the convergence point for each trajectory, index of the timepoint in which the lines will converge; | |
~cp2= Array.fill(~cPs, {|i| ~convergencePoints_25_08_17_0[i].linlin(1,13,2,10) }); | |
~cp2= ~cp2.asInteger; | |
// the segment of all patterns before the convergence point | |
~bcp2= Array.newClear(~cPs); | |
(~cPs).do{|i| ~bcp2.put(i, Array.fill(~tp2[i]-(~tp2[i]-~cp2[i]), {|j| ~line2[i][j] }) ) }; | |
~bcp2.insert(0, [0]); | |
// melodic patterns for the sound object; | |
~melody2= Array.fill(~cPs+1, { [57.5,58,62.5,63,60,67.5,68,65].pyramid.wrapExtend(~cPs+1) }); | |
~melody2= ~melody2[0]; | |
~mel2= Array.newClear(~cPs+1); | |
( | |
(~cPs+1).do{|i| | |
var interval= [5,7,8,9,10].choose; | |
~mel2.put(i, Array.series(~bcp2[i].size, ~melody2[i]-interval, ~melody2[i]-(~melody2[i]-interval)/(~bcp2[i].size) )+12) | |
}); | |
// ID ; | |
~ids_Y = Array.newClear(~cPs); | |
~cPs.do{|i| ~ids_Y.put(i , Array.fill(~tp[i],{ (i%7)+8 }) ) }; | |
( | |
// iterate the patterns | |
f = Dictionary.new(); | |
f.put(\pat, Dictionary.new); | |
~cPs.do{|i| | |
f[\pat].put(i.asSymbol, | |
Pbind(\instrument, \pianola, \pan, 0, \dur, Pseq(~line2[i]*~tempo,1), \freq, Pseq(~mel2[i+1]++(~melody2[i+1]+12)++~mel2[i+1].reverse,inf), \amp, 1*~amplitudPianola, \id, Pseq(~ids_Y[i], inf), \value, Pkey(\dur), | |
\event, Pfunc({|event| if( ~part==event[\id], {~netAddr_0.sendMsg('/event', event[\freq], event[\dur], event[\id])}; | |
) })) | |
)} | |
); | |
//------------------ putting everything together-------------------; | |
// layer 1 | |
( | |
// arranging entry time for each trajectory and its pattern | |
~patArr = Array.fill(~cPs, {|i| | |
(~distances[i]-~bcp[i+1].sum).abs*~tempo; | |
} ); | |
~patArr2 = Array.fill(~cPs, {|i| | |
d[\pat][i.asSymbol]; | |
} ); | |
~patArrs = [~patArr, ~patArr2].flop.flatten; | |
x = [0, ~objectPatt]++~patArrs; | |
); | |
// layer 2 | |
( | |
~patArr_2 = Array.fill(~cPs, {|i| | |
(~distances[i]-~bcp2[i+1].sum).abs*~tempo; | |
} ); | |
~patArr2_2 = Array.fill(~cPs, {|i| | |
f[\pat][i.asSymbol]; | |
} ); | |
~patArrs2 = [~patArr_2, ~patArr2_2].flop.flatten; | |
y = ~patArrs2; | |
); | |
~ptpar= Ptpar(x++y, 1); | |
); | |
( | |
// Parts for Score ; | |
// generating coordinates for the audio-score | |
( | |
// score ICLC 2017 | |
( | |
~arr= Array.newClear(~cPs/7); | |
( | |
~oldNumber= 0; | |
~arr.size.do{|i| | |
~arr.put(i,~oldNumber); | |
~number= ~oldNumber + 7; | |
~oldNumber = ~number; | |
}; | |
); | |
( | |
~arr1= ~arr; | |
~arr2= ~arr1+1; | |
~arr3= ~arr2+1; | |
~arr4= ~arr3+1; | |
~arr5= ~arr4+1; | |
~arr6= ~arr5+1; | |
~arr7= ~arr6+1; | |
~arrs= [~arr1,~arr2,~arr3,~arr4,~arr5,~arr6,~arr7] | |
); | |
~arrs[(~part-1)%7]; | |
); | |
// geneating coodinates for audioscores; | |
~arrs = ~arrs[(~part-1)%7]; | |
if(~part<8, {~cbcp= ~bcp; ~ctp= ~tp; ~cline= ~line}, {~cbcp= ~bcp2; ~ctp= ~tp2; ~cline= ~line2}); | |
~prec = Array.fill(~arrs.size, {|i| if(~cbcp[~arrs[i]+1].size < 5, {~cbcp[~arrs[i]+1].size}, {~cbcp[~arrs[i]+1].size - [2,3,4].choose}) }); | |
~numDeRayitas_BCP= Array.fill(~arrs.size, {|i| (~cbcp[~arrs[i]+1].size - ~prec[i]) }); | |
~numDeRayitas_ACP= Array.fill(~arrs.size, {|i| (~ctp[~arrs[i]]- ~cbcp[~arrs[i]+1].size) -1 }); | |
~rayasBCP= Array.fill(~arrs.size, {|i| var r= ["|", "-", "~"].wchoose([0.7,0.2,0.1].normalizeSum); Array.fill(~numDeRayitas_BCP[i], {|i| r })}); | |
~rayasACP= Array.fill(~arrs.size, {|i| var r= ["|", "-", "~"].wchoose([0.7,0.2,0.2].normalizeSum); Array.fill(~numDeRayitas_ACP[i], {|i| r })}); | |
( | |
~nota_CP= ["Si","Do","La_b","Sol","Mi", "Fa", "Do", "Mi_b", "Si_b", "Re_b", "Do", "La", "Fa", "Sol_b", "Fa", "Sol_#", "La_#", "Si", "Mi", "Mi", "La", "Re", "Do_#", "Si", "Si_b", "Sol_b", "La", "Re", "Fa", "Mi", "Sol", "Mi_b", "Si_b", "La_b", "Sol_b", "Fa", "La_b", "Sol", "Do", "Do_#", "La", "Si", "Sol_#", "Mi", "La", "La", "Si_b", "Re_b", "Sol_b", "Fa", "Mi_b", "Re", "Do", "Do"]; | |
~nota_CP= Array.fill(~cPs, {|i| ~nota_CP[i%54] }); | |
~nota_CP= ~nota_CP[~arrs]; | |
); | |
~fileData= Array.fill(~arrs.size, {|i| | |
if(i==0, {" "}, {""})++ | |
((~distances[~arrs[i]]-~cbcp[~arrs[i]+1].sum)*~tempo).asTimeString.copyRange(0,7) ++ | |
" "++ ~prec[i].asString++ | |
":"++ ~rayasBCP[i].asString++ | |
~nota_CP[i]++ | |
" "++ ~rayasACP[i].asString++ | |
" "++ "\n" }).replace("[", " ").replace("]", " ").replace(","," ").replace("\""," "); | |
); | |
( | |
// register to receive a trigger message | |
/* | |
OSCresponder(~netAddr,'/event',{ arg time,responder,msg; | |
// Post << msg <<nl; | |
if(msg[3]==~part, {msg[3].postln; | |
msg[1].postln; | |
~kps.set(\freq, msg[1]); | |
~kps_2.set(\freq, msg[1]); | |
~bass.set(\freq, msg[1]); | |
Synth(\dxkSd1, [\amp, ~amps_Synths.wchoose([0.3,0.4, 0.1,0.2,0]), \out, [30,10,12,14,16,18].wchoose([0.2,0.2,0.2,0.2,0.05,0.15].normalizeSum)]); | |
Synth(\dxkSd2, [\amp, ~amps_Synths.wchoose([0.2,0.2, 0.2, 0.2,0.2]), \out, [30,10,12,14,16,18].wchoose([0.2,0.2,0.2,0.2,0.05,0.15].normalizeSum)]); | |
Synth(\dxkSd3, [\amp, ~amps_Synths.wchoose([0,0.4, 0.2,0.2, 0.2]), \out, [30,10,12,14,16,18].wchoose([0.2,0.2,0.2,0.2,0.05,0.15].normalizeSum)]); | |
Synth(\dxkHh1, [\amp, ~amps_Synths.wchoose([0.5,0.5, 0, 0, 0]), \out, [30,10,12,14,16,18].wchoose([0.2,0.2,0.2,0.2,0.05,0.15].normalizeSum)]); | |
Synth(\dxkHh2, [\amp, ~amps_Synths.wchoose([0.4,0.2, 0.2, 0.1, 0.1]), \out, [30,10,12,14,16,18].wchoose([0.2,0.2,0.2,0.2,0.05,0.15].normalizeSum)]); | |
Synth(\dxkBd1, [\amp, ~amps_Synths.wchoose([0.5,0.5, 0, 0, 0]), \out, [30,10,12,14,16,18].wchoose([0.2,0.2,0.2,0.2,0.05,0.15].normalizeSum)]); | |
Synth(\dxkCymb808_1, [\amp, ~amps_Synths.wchoose([0.2,0.6, 0.1,0,0.1]), \out, [30,10,12,14,16,18].wchoose([0.2,0.2,0.2,0.2,0.05,0.15].normalizeSum)]); | |
Synth(\dxkUWoodBank, [\amp, ~amps_Synths.wchoose([0,0.5, 0.2, 0.2, 0.1]), \out, [30,10,12,14,16,18].wchoose([0.2,0.2,0.2,0.2,0.05,0.15].normalizeSum)]); | |
}); | |
if(msg[3]==~part, {msg[3].postln; | |
~lead= Synth(\lead, [\att, 0.01, \dec,0.1, \decLevel, [0.03,0.07,0.09,0.07,0.03,0.04].choose, \pitch, ~rhythm_TPs_25_08_17_0.choose+[0,12,24,36,31,19,7].wchoose([0.2,0.5,0.7,0.4,0.3,0.2,0.2].normalizeSum), \ibuf, rand(v[0].bufnum,v[v.size-1].bufnum), \attF, [0.1,0.001, 0.03, 0.5, 1, 2, 5].choose, \coH, rand(1000, 22000), \coL, [50,1000].choose, \rq, rrand(0.1, 0.5), \lfo1Freq, rrand(20,200), \lfo1Width, rrand(1,10), \lfo2Freq, rand(0.1,20), \lfo3Freq, rrand(0.02, 0.3)]); | |
}); | |
}).add;*/ | |
// | |
// // turn on the clock | |
// OSCresponder(~netAddr,'/clock',{ arg time,responder,msg; | |
// | |
// Post << msg <<nl; | |
// | |
// if(msg[1]==1, {~task.play}, {~task.reset; ~task.stop}); | |
// | |
// }).add; | |
// | |
// // turn on the visual score | |
// OSCresponder(~netAddr,'/score',{ arg time,responder,msg; | |
// | |
// Post << msg <<nl; | |
// | |
// if(msg[1]==1, {~taskScore.play}, {~taskScore.reset; ~taskScore.stop}); | |
// | |
// }).add; | |
// | |
// // turn on the visual score | |
// OSCresponder(~netAddr,'/on_off',{ arg time,responder,msg; | |
// | |
// Post << msg <<nl; | |
// | |
// if(msg[1]==1, {~par=~ptpar.play}, {~par.stop;}); | |
// | |
// }).add; | |
); | |
( | |
~task = Task({ | |
1.do({ | |
inf.do({ |i| | |
var min, secs; | |
min = (i / 60).asInteger; | |
secs = ((i) % 60); | |
if (secs < 10, {secs = (0.asSymbol ++ secs.asSymbol)}); | |
a.string = (min.asSymbol ++ ":" ++ secs.asSymbol); | |
1.wait; | |
}) | |
}) | |
}, AppClock) | |
); | |
( | |
~taskScore= Task({ | |
1.do{ | |
inf.do{|i| | |
b.string = ~fileData[i].asCompileString.replace("[", " ").replace("]", " ").replace(","," ").replace("\""," "); | |
c.string = ~fileData[i+1].asCompileString.replace("[", " ").replace("]", " ").replace(","," ").replace("\""," "); | |
if( i==0, {((~distances[~arrs[0]]-~cbcp[~arrs[0]+1].sum+~cline[~arrs[0]].sum).abs*~tempo)},{(((~distances[~arrs[i]] - ~cbcp[~arrs[i]+1].sum + ~cline[~arrs[i]].sum).abs - (~distances[~arrs[i-1]] - ~cbcp[~arrs[i-1] +1].sum + ~cline[~arrs[i-1]].sum).abs)* ~tempo)}).postln; | |
if( i==0, {((~distances[~arrs[0]]-~cbcp[~arrs[0]+1].sum+~cline[~arrs[0]].sum).abs*~tempo)}, {(((~distances[~arrs[i]] - ~cbcp[~arrs[i]+1].sum + ~cline[~arrs[i]].sum).abs - (~distances[~arrs[i-1]] - ~cbcp[~arrs[i-1] +1].sum + ~cline[~arrs[i-1]].sum).abs)* ~tempo)}).wait | |
}; | |
} | |
}, AppClock) | |
); | |
( | |
w = Window.new("Parte - Iterar las Ausencias", Rect(500,500,700,650)); | |
~bot_2 = Button.new(w, Rect(500, 10, 70, 50)); | |
~bot_2.states = ([["Start",Color.black, Color.green],["Stop",Color.black, Color.red]]); | |
~bot_2.action = ( {|b| if (b.value == 1) | |
{\prende.postln; ~netAddr_0.sendMsg('/on_off', 1);~netAddr_0.sendMsg('/clock', 1); ~netAddr_0.sendMsg('/score', 1)} | |
{\apaga.postln; ~task.stop; ~taskScore.stop; ~todo.stop} | |
} ); | |
/* | |
( | |
~txt_2 = StaticText(w, Rect(15, 5, 130, 30)); | |
~txt_2.string = "Input a score part to monitor (1-14)"; | |
); | |
( | |
~nBx_2 = NumberBox(w, Rect(15, 40, 100, 20)); | |
~nBx_2.value = 0; | |
~nBx_2.action = {arg numb; numb.value.postln; ~part = numb.value }; | |
); | |
*/ | |
( | |
a = StaticText(w, Rect(5, 130, 690, 200)); | |
a.background=Color.black; | |
a.align = \center; | |
a.font = Font("Arial", 205); | |
a.stringColor = Color.white; | |
a.string = "0:00"; | |
); | |
( | |
b = StaticText(w, Rect(5, 430, 690, 100)); | |
b.background=Color.black; | |
b.align = \center; | |
b.font = Font("Arial", 40); | |
b.stringColor = Color.white; | |
b.string = ~fileData[0].asCompileString.replace("[", " ").replace("]", " ").replace(","," ").replace("\""," "); | |
); | |
( | |
c = StaticText(w, Rect(5, 530, 690, 100)); | |
c.background=Color.black; | |
c.align = \center; | |
c.font = Font("Arial", 30); | |
c.stringColor = Color.red; | |
c.string = ~fileData[1].asCompileString.replace("[", " ").replace("]", " ").replace(","," ").replace("\""," "); | |
); | |
w.onClose = { | |
~outSynth.set(\gate, 0); | |
~kps.set(\gate, 0); | |
~kps_2.set(\gate, 0); | |
~reverb.set(\gate, 0); | |
~bass.set(\gate, 0); | |
v.size.do{|i| v[i].free }; | |
s.quit | |
}; | |
w.front | |
); | |
); | |
}) | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment