Browse files

just before making a new midi system

  • Loading branch information...
1 parent afcc664 commit 24e9ae0db4ab512f8e6ef60058f0b3472de09d38 @grirgz committed Dec 13, 2011
Showing with 3,290 additions and 77 deletions.
  1. +178 −0 crap2.sc
  2. +1,237 −0 crap4.sc
  3. +139 −0 crap5.sc
  4. +584 −0 crap6.sc
  5. +496 −0 crap7.sc
  6. +16 −4 editplayer.sc
  7. +46 −0 hardcopy.0
  8. +115 −33 hmatrix.sc
  9. +3 −0 keycode.sc
  10. +1 −1 live7.sc
  11. +134 −5 live8.sc
  12. +123 −0 live9.sc
  13. +49 −18 main.sc
  14. +13 −7 matrix.sc
  15. +105 −0 midi.sc
  16. +15 −0 mysynths.sc
  17. +36 −9 player.sc
View
178 crap2.sc
@@ -1610,3 +1610,181 @@ Pbind(
\dur, 0.5
).play
)
+
+
+
+a = PathName.new("sounds");
+a.files.do { arg x; ["wav"].includesEqual(x.extension).debug }
+a.files.do { arg x; ("wav" === x.extension).debug }
+
+(
+SynthDef(\sin5, { arg out=0, pan=0, gate=1, width=0.5,sustain=0.5, amp=0.1, freq=200;
+
+ var ou;
+
+ ou = Pulse.ar(freq,width);
+ ou = ou * EnvGen.ar(Env.linen(0.01,sustain,0.01,1),doneAction:2);
+ ou = Pan2.ar(ou,pan,amp);
+ Out.ar(out, ou);
+
+}).add;
+)
+(
+a = Pbind(
+ \type, \note,
+ \instrument, \sin1,
+ //\out, b,
+ \sustain, 0.1,
+ \sustain, Pseq([0.1,0.3],2),
+ \amp, 0.5,
+ \freq, Pseg(Pseq([1,2,3,4],inf),0.7,0)*110,
+ \dur, 0.5
+);
+Pn(a).play
+)
+
+
+(
+a = Signal.newClear(512);
+a.waveFill({ arg x, i; sin(x).max(0) }, 0, 3pi);
+a.plot;
+)
+
+s.boot
+
+a = [1, 6, 2, -5, 2].plot2;
+a.editMode = true;
+
+
+b = Buffer.alloc(s,1024)
+(1..2).sum
+
+
+x= 1
+(1..2).collect({arg k; sin(x*k)}).sum
+sin(x)+sin(2*x)
+(
+a = Signal.newClear(512);
+a.waveFill({ arg x, i; sin(x)+sin(2*x) }, 0, 2pi);
+a.waveFill({ arg x, i; (1..6).collect({arg k; sin((x*sin(x+k))*k)}).sum }, 0, 3pi);
+a.plot;
+b.loadCollection(a.asWavetable);
+
+SynthDef("help-Osc",{ arg out=0,freq=100,bufnum=0;
+ var ou,fou,ou2;
+ //fou = Osc.kr(bufnum, 0.1, 0, 0.5)*90+100;
+ fou = SinOsc.kr(43.5)*90+freq;
+ ou = Osc.ar(bufnum, [0.1,-1,0]+(freq+(SinOsc.kr(1)*5)), 0, 0.5).sum;
+ //ou = Pulse.ar(200);
+ ou = RLPF.ar(ou, fou.lag(0.1),0.03);
+ //ou = BPF.ar(ou, 200,SinOsc.kr(488)+1.1*0.3);
+ ou2 = BPF.ar(ou, freq*1.5,SinOsc.kr(5,0.1)+1.1*0.7);
+ ou = BPF.ar(ou, freq*0.5,SinOsc.kr(4)+1.1*0.7)+ou2;
+ ou = ou ! 2;
+ Out.ar(out,ou)
+
+}).play(s,[\out, 0, \bufnum, b.bufnum]);
+)
+
+
+
+// embedding in another GUI
+(
+w = Window("plot panel", Rect(20, 30, 520, 250));
+Slider.new(w, Rect(10, 10, 490, 20)).resize_(2).action_ { |v|
+ v.value.debug("val");
+ a.value = (0..(max(v.value,0.1) * 80).asInteger).scramble;
+ w.refresh;
+};
+z = CompositeView(w, Rect(10, 35, 490, 200)).background_(Color.rand(0.7)).resize_(5);
+a = Plotter("plot", parent: z).value_([0, 1, 2, 3, 4].scramble * 100);
+w.front;
+)
+
+(0..(0.51*80).asInteger)
+
+(
+a = Plotter("the plot", Rect(600, 30, 600, 400));
+a.value = (0..100).normalize(0, 8pi).sin;
+)
+
+a.value = { |i| (0..90) % (i + 12) + ( (0..90) % (i + 2 * 1) ) }.dup(3);
+a.value = (0..12).squared;
+a.plotMode = \points; a.refresh;
+a.plotMode = \levels; a.refresh;
+a.plotMode = \plines; a.refresh;
+
+a.domainSpecs = [[0, 115, \lin, 1]]; a.refresh;
+
+a.parent.close; // close window
+a.makeWindow; // open it again
+
+a.refresh
+a.value = { (0..70).scramble }.dup(3);
+a.plotMode = \linear; a.refresh;
+a.value = { |i| (0..2000).normalize(0, 4pi + i).sin } ! 4; // lots of values, test efficiency
+a.value = { |i| (0..10000).normalize(0, 8pi + i).sin } ! 3; // lots of values, test efficiency
+a.value = { (0..140).scramble } ! 7;
+
+a.value = { |i| (0..90).normalize(0, 8pi + (i*2pi)).sin } ! 2 * [400, 560] + 700;
+a.value = { |i| (_ + 2.0.rand).dup(100).normalize(0, 8pi + i).sin } ! 2 * 400 + 700;
+
+
+// multi channel expansion of single values
+a.value = { |i| (_ + 2.0.rand).dup(100).normalize(0, 8pi + i).sin *.t [1, 2, 3] } ! 2 * 400 + 700;
+a.value = { |i| (0..10) **.t [1, 1.2, 1.3, 1.5] * (3.5 ** i) }.dup(3);
+
+a.parent.bounds = Rect(400, 100, 500, 700);
+a.parent.bounds = Rect(600, 30, 500, 300);
+
+a.superpose = true;
+a.value = { |i| (0..20) * (3.5 ** i) }.dup(5);
+a.superpose = false;
+
+// specs
+
+a.value = (50..90).midicps.scramble;
+a.specs = \freq; a.refresh;
+a.value = (1..60).scramble.neg;
+a.specs = \db; a.refresh;
+
+a.value = { |i| { exprand(1e3, (10 ** (i + 8))) }.dup(90) }.dup(3);
+a.value = { { exprand(1e3, 1e9) }.dup(90) }.dup(3);
+a.specs = [[1e3, 1e10, \exp], [1e3, 1e20, \exp], [1e3, 1e30, \exp]]; a.refresh;
+a.domainSpecs = [[0, 5], [-8, 100], [-1, 1]]; a.refresh;
+
+
+// Array:plot
+(
+a = (4 ** (-5..0)).postln.plot2;
+a.specs = \delay; a.refresh;
+a.domainSpecs = [0, 10, \lin, 0, 0, " Kg"].asSpec; a.refresh;
+);
+
+a.domainSpecs = [0.1, 10, \exponential, 0, 0, " Kg"].asSpec; a.refresh;
+a.domainSpecs = [-10, 10, \lin, 0, 0, " Kg"].asSpec; a.refresh;
+
+
+a = [(0..100) * 9, (200..1300) * 2, (200..1000)/ 5].plot2;
+a.superpose = true;
+
+a = [[0, 1.2, 1.5], [0, 1.3, 1.5, 1.6], [0, 1.5, 1.8, 2, 6]].midiratio.plot2;
+a.plotMode = \levels; a.refresh;
+a.superpose = false;
+
+
+// Function:plot
+a = { SinOsc.ar([700, 357]) * SinOsc.ar([400, 476]) * 0.2 }.plot2;
+a = { SinOsc.ar([700, 357] *0.02) * SinOsc.ar([400, 476]) * 0.3 }.plot2(0.2, minval: -1);
+a = { SinOsc.ar(440) }.plot2(1);
+
+
+// Env:plot
+Env.perc(0.4, 0.6).plot2;
+Env.new({ 1.0.rand2 }! 8, { 1.0.rand } ! 7, \sin).plot2;
+
+// Buffer:plot
+b = Buffer.read(s, "sounds/SinedPink.aiff");
+ // "sounds/SinedPink.aiff" contains SinOsc on left, PinkNoise on right
+b.plot2;
+b.free;
View
1,237 crap4.sc
@@ -0,0 +1,1237 @@
+
+
+s.boot; // If you haven't already booted
+
+
+x = { Ringz.ar(PinkNoise.ar(0.1), {exprand(300, 20000)}.dup(100)).mean }.play;
+
+
+x.free; // To stop
+
+
+
+(
+
+x = {
+
+var driver, cutoffenv, freqs, res;
+
+cutoffenv = EnvGen.ar(Env.perc(0, 0.5)) * 20000 + 10;
+
+driver = LPF.ar(WhiteNoise.ar(0.1), cutoffenv);
+
+freqs = {exprand(300, 20000)}.dup(100);
+
+res = Ringz.ar(driver, freqs).mean.dup
+
+}.play;
+
+)
+
+
+x.free;
+
+
+
+
+(
+
+x = {
+
+var lodriver, locutoffenv, hidriver, hicutoffenv, freqs, res;
+
+locutoffenv = EnvGen.ar(Env.perc(0.25, 5)) * 20000 + 10;
+
+lodriver = LPF.ar(WhiteNoise.ar(0.1), locutoffenv);
+
+hicutoffenv = 10001 - (EnvGen.ar(Env.perc(1, 3)) * 10000);
+
+hidriver = HPF.ar(WhiteNoise.ar(0.1), hicutoffenv);
+
+hidriver = hidriver * EnvGen.ar(Env.perc(1, 2, 0.25));
+
+freqs = {exprand(300, 20000)}.dup(100);
+
+res = Ringz.ar(lodriver + hidriver, freqs).mean.dup
+
+}.play;
+
+)
+
+
+
+(
+
+x = {
+
+var lodriver, locutoffenv, hidriver, hicutoffenv, freqs, res;
+
+locutoffenv = EnvGen.ar(Env.perc(0.5, 5)) * 20000 + 10;
+
+lodriver = LPF.ar(WhiteNoise.ar(0.1), locutoffenv);
+
+hicutoffenv = 10001 - (EnvGen.ar(Env.perc(1, 3)) * 10000);
+
+hidriver = HPF.ar(WhiteNoise.ar(0.1), hicutoffenv);
+
+hidriver = hidriver * EnvGen.ar(Env.perc(1, 2, 0.25));
+
+freqs = {exprand(300, 20000)}.dup(100);
+
+res = Ringz.ar(lodriver + hidriver, freqs).mean;
+
+((res * 1) + (lodriver * 2)).dup;
+
+}.play;
+
+)
+
+
+
+(
+
+x = {
+
+var lodriver, locutoffenv, hidriver, hicutoffenv, freqs, res, thwack;
+
+locutoffenv = EnvGen.ar(Env.perc(0.5, 5)) * 20000 + 10;
+
+lodriver = LPF.ar(WhiteNoise.ar(0.1), locutoffenv);
+
+hicutoffenv = 10001 - (EnvGen.ar(Env.perc(1, 3)) * 10000);
+
+hidriver = HPF.ar(WhiteNoise.ar(0.1), hicutoffenv);
+
+hidriver = hidriver * EnvGen.ar(Env.perc(1, 2, 0.25));
+
+thwack = EnvGen.ar(Env.perc(0.001,0.001,1));
+
+freqs = {exprand(300, 20000)}.dup(100);
+
+res = Ringz.ar(lodriver + hidriver + thwack, freqs).mean;
+
+((res * 1) + (lodriver * 2) + thwack).dup;
+
+}.play;
+
+)
+
+
+x.free;
+
+
+
+//adapted from 2.18 Vibrations of a Stiff String, p61, Thomas D. Rossing and Neville H. Fletcher (1995) Principles of Vibration and Sound. New York: Springer-Verlag
+
+(
+
+var modes,modefreqs,modeamps;
+
+var mu,t,e,s,k,f1,l,c,a,beta,beta2,density;
+
+var decaytimefunc;
+
+var material;
+
+
+material= \nylon; // \steel
+
+
+//don't know values of E and mu for a nylon/gut string
+
+//so let's try steel
+
+
+//radius 1 cm
+
+a=0.06;
+
+
+s=pi*a*a;
+
+
+//radius of gyration
+
+k=a*0.1;
+
+
+
+if (material ==\nylon,{
+
+
+e=2e+7;
+
+
+density=2000;
+
+
+},{//steel
+
+
+e= 2e+11; // 2e+7; //2e+11 steel;
+
+
+//density p= 7800 kg m-3
+
+//linear density kg m = p*S
+
+
+density=7800;
+
+});
+
+
+mu=density*s;
+
+
+t=100000;
+
+
+c= (t/mu).sqrt; //speed of sound on wave
+
+
+l=1.1; //0.3
+
+
+f1= c/(2*l);
+
+
+beta= (a*a/l)*((pi*e/t).sqrt);
+
+
+beta2=beta*beta;
+
+
+modes=10;
+
+
+modefreqs= Array.fill(modes,{arg i;
+
+var n,fr;
+
+n=i+1;
+
+
+fr=n*f1*(1+beta+beta2+(n*n*pi*pi*beta2*0.125));
+
+
+if(fr>21000, {fr=21000}); //no aliasing
+
+
+fr
+
+});
+
+
+decaytimefunc= {arg freq;
+
+var t1,t2,t3;
+
+var m,calc,e1dive2;
+
+
+//VS p 50 2.13.1 air damping
+
+
+m=(a*0.5)*((2*pi*freq/(1.5e-5)).sqrt);
+
+
+calc= 2*m*m/((2*(2.sqrt)*m)+1);
+
+
+t1= (density/(2*pi*1.2*freq))*calc;
+
+
+e1dive2=0.01; //a guess!
+
+
+t2= e1dive2/(pi*freq);
+
+
+//leave G as 1
+
+t3= 1.0/(8*mu*l*freq*freq*1);
+
+
+1/((1/t1)+(1/t2)+(1/t3))
+
+};
+
+
+modeamps=Array.fill(modes,{arg i; decaytimefunc.value(modefreqs.at(i))});
+
+
+modefreqs.postln;
+
+modeamps.postln;
+
+
+{
+
+var output;
+
+//EnvGen.ar(Env.new([0.001,1.0,0.9,0.001],[0.001,0.01,0.3],'exponential'),WhiteNoise.ar)
+
+//could slightly vary amps and phases with each strike?
+
+
+output=EnvGen.ar(
+
+Env.new([0,1,1,0],[0,10,0]),doneAction:2)*
+
+//slight initial shape favouring lower harmonics- 1.0*((modes-i)/modes)
+
+Mix.fill(modes,{arg i; XLine.ar(1.0,modeamps.at(i),10.0)*SinOsc.ar(modefreqs.at(i),0,1.0/modes)});
+
+
+Pan2.ar(output,0)
+
+}.play;
+
+
+)
+
+
+
+(
+
+// this shows the building of the piano excitation function used below
+
+{
+
+var strike, env, noise;
+
+strike = Impulse.ar(0.01);
+
+env = Decay2.ar(strike, 0.008, 0.04);
+
+noise = LFNoise2.ar(3000, env);
+
+[strike, K2A.ar(env), noise]
+
+}.plot(0.03); //.scope
+
+)
+
+
+
+(
+
+// hear the energy impulse alone without any comb resonation
+
+{
+
+var strike, env, noise;
+
+strike = Impulse.ar(0.01);
+
+env = Decay2.ar(strike, 0.008, 0.04);
+
+noise = LFNoise2.ar(3000, env);
+
+10*noise
+
+}.scope
+
+)
+
+
+
+
+//single strike with comb resonation
+
+
+(
+
+{
+
+var strike, env, noise, pitch, delayTime, detune;
+
+strike = Impulse.ar(0.01);
+
+env = Decay2.ar(strike, 0.008, 0.04);
+
+pitch = (36 + 54.rand);
+
+Pan2.ar(
+
+// array of 3 strings per note
+
+Mix.ar(Array.fill(3, { arg i;
+
+// detune strings, calculate delay time :
+
+detune = #[-0.05, 0, 0.04].at(i);
+
+delayTime = 1 / (pitch + detune).midicps;
+
+// each string gets own exciter :
+
+noise = LFNoise2.ar(3000, env); // 3000 Hz was chosen by ear..
+
+CombL.ar(noise, // used as a string resonator
+
+delayTime, // max delay time
+
+delayTime, // actual delay time
+
+6) // decay time of string
+
+})),
+
+(pitch - 36)/27 - 1 // pan position: lo notes left, hi notes right
+
+)
+
+}.scope
+
+)
+
+
+
+
+(
+
+// synthetic piano patch (James McCartney)
+
+var n;
+
+n = 6; // number of keys playing
+
+play({
+
+Mix.ar(Array.fill(n, { // mix an array of notes
+
+var delayTime, pitch, detune, strike, hammerEnv, hammer;
+
+// calculate delay based on a random note
+
+pitch = (36 + 54.rand);
+
+strike = Impulse.ar(0.1+0.4.rand, 2pi.rand, 0.1); // random period for each key
+
+hammerEnv = Decay2.ar(strike, 0.008, 0.04); // excitation envelope
+
+Pan2.ar(
+
+// array of 3 strings per note
+
+Mix.ar(Array.fill(3, { arg i;
+
+// detune strings, calculate delay time :
+
+detune = #[-0.05, 0, 0.04].at(i);
+
+delayTime = 1 / (pitch + detune).midicps;
+
+// each string gets own exciter :
+
+hammer = LFNoise2.ar(3000, hammerEnv); // 3000 Hz was chosen by ear..
+
+CombL.ar(hammer, // used as a string resonator
+
+delayTime, // max delay time
+
+delayTime, // actual delay time
+
+6) // decay time of string
+
+})),
+
+(pitch - 36)/27 - 1 // pan position: lo notes left, hi notes right
+
+)
+
+}))
+
+})
+
+)
+
+
+
+
+
+(
+Display.make({ arg thisDisplay, carrier_freq, modulator_freq,
+amp, modulator_amp, pan;
+carrier_freq.spec_(\freq);
+modulator_freq.spec_(ControlSpec(0.1, 20000, \exp, 0, 1));
+amp.spec_(\amp);
+modulator_amp.spec_(\amp);
+pan.spec_(\pan);
+thisDisplay.synthDef_({ arg carrier_freq, modulator_freq,
+amp, modulator_amp, pan;
+var
+modulator, panner, result;
+modulator = SinOsc.ar(modulator_freq,
+mul: modulator_amp);
+result = SinOsc.ar(carrier_freq,
+mul: modulator * amp);
+panner = Pan2.ar(result, pan);
+Out.ar(0, panner);
+}, [\carrier_freq, carrier_freq, \modulator_freq,
+modulator_freq, \amp, amp, \modulator_amp, modulator_amp,
+\pan, pan]);
+thisDisplay.name_("Ring Modulation");
+}).show;
+)
+
+
+
+
+
+(
+SynthDef(\ring1, { arg out=0, freq=200, modulator_freq=5, amp=0.1, modulator_amp=1, pan=0;
+var modulator, panner, result, env;
+
+env = ~make_adsr.(\adsr);
+modulator = SinOsc.ar(modulator_freq, mul: modulator_amp);
+result = SinOsc.ar(carrier_freq, mul: modulator * amp);
+result = result * env;
+panner = Pan2.ar(result, pan);
+panner;
+//Out.ar(0, panner);
+}).store;
+)
+
+
+
+ // Setting envir variables in a Tdef:
+(
+Tdef(\text).set(\note, [0, 2, 7], \dur, { [0.1, 0.2, 0.4].choose }, \pan, 0, \amp, 0.1);
+
+w = Window("EZTexts", Rect(200, 400, 304, 120)).front;
+w.addFlowLayout;
+
+TdefGui(Tdef(\text), 0, parent: w);
+
+e = EnvirGui(Tdef(\text).envir, 4, parent: w);
+
+Tdef(\text, { |ev|
+ var mydur;
+ loop {
+ mydur = ev.dur;
+ (note: ev.note, dur: mydur, amp: ev.amp, pan: ev.pan).postln.play;
+ mydur.wait;
+ }
+}).play;
+)
+
+ // or equivalently, use the built-in EnvirGui in TdefGui:
+TdefGui(Tdef(\text), 4);
+
+Tdef(\text).set(\yuhu, Prand([2, 3, 5, 8, 13], inf), \magic, [\abra, \cadabra]);
+
+Tdef(\text).clear;
+
+
+
+// simple example
+g = NdefParamGui.new(nil, 5); // empty with 5 slots
+g.object_(Ndef(\a)); // put in a nodeproxy
+Ndef(\a, { |freq = 300, amp = 0.2| SinOsc.ar(freq) * amp });
+Ndef(\a).set(\freq, 2000); // add a setting
+
+g.object_(nil); // put in a nodeproxy
+
+g.object_(Ndef(\a)); // put in a nodeproxy
+Ndef(\a).set(\amp, 0.125); // add a setting
+Ndef(\a, { |freq = 300, amp = 0.2| SinOsc.ar(freq) * amp });
+Ndef(\a).set(\freq, 234); // add a setting
+
+Ndef(\a).play
+Ndef(\lfo, { LFNoise0.kr([12, 8], 200).sum + 500 });
+Ndef(\a).map(\freq, Ndef(\lfo));// mapped proxies are shown
+
+
+//Multichannel controls are shown in EZText
+
+Ndef(\a, { |freqs = #[300, 303], pan, amp = 0.2, moddd = 0.1| SinOsc.ar(freqs).sum * amp });
+Ndef(\a).play
+Ndef(\a).setn(\freqs, [300, 350])
+Ndef(\a).setn(\freqs, [330, 350])
+Ndef(\a).set(\harm, 123)
+
+Ndef(\a).nodeMap.clear
+
+Ndef(\lfos, { LFNoise0.kr([12, 8], 200) + 500 });
+Ndef(\a).map(\freqs, Ndef(\lfos))
+
+g.parent.close
+
+
+
+(
+{
+var vibrato;
+vibrato = SinOsc.kr(6, mul: 0.02, add: 1);
+SinOsc.ar(
+freq: MouseY.kr(3200, 200, lag: 0.5, warp: 1) *
+vibrato, //Vibrato
+mul: abs(MouseX.kr(0.02, 1)) //Amplitude
+)
+}.play
+)
+
+(
+//Vibrato
+{
+var depthChange, vibrato;
+depthChange = Line.kr(0, 5, 3);
+vibrato = SinOsc.ar(freq: 5, mul: depthChange, add: 440);
+SinOsc.ar(
+vibrato,
+mul: 0.5)
+}.play
+)
+(
+{ //SinOsc (sci-fi)
+var lfo;
+lfo = SinOsc.ar(freq: 10,mul: 100, add: 400);
+SinOsc.ar(lfo, mul: 0.5)
+}.play
+)
+mul: 100, add: 400);
+(
+{ //Pulse (phone ring)
+var lfo;
+lfo = LFPulse.ar(freq: 15, mul: 200, add: 1000);
+SinOsc.ar(lfo, mul: 0.5)
+}.play
+)
+(
+{ //Saw
+var lfo;
+lfo = LFSaw.ar(freq: 2, mul: -100, add: 600);
+SinOsc.ar(lfo, mul: 0.5)
+}.play
+)
+(
+{ //Noise (computer)
+var lfo;
+lfo = LFNoise0.ar(freq: [28, 27], mul: 1000, add: 2000);
+SinOsc.ar(lfo, mul: 0.5)
+}.play
+)
+(
+{ //Noise (manic birds)
+var lfo;
+lfo = LFNoise1.ar(freq: [28, 27], mul: 400, add: 2000);
+SinOsc.ar(lfo, mul: 0.5)
+}.play
+)
+
+
+(
+//frequency linked to envelope length
+//high notes short, low long
+{
+var frequency;
+Mix.ar(
+{
+frequency = rrand(100, 5000);
+Pan2.ar(
+SinOsc.ar(
+frequency,
+mul: EnvGen.kr(
+Env.perc(0.001, 500/frequency),
+Dust.kr(0.05),
+0.2
+)
+),
+rrand(-1.0, 1.0)
+)
+}.dup(100)
+)
+}.play
+)
+(
+//frequency linked to decay length
+//basically the same code but more compact
+//low notes short, high long
+{var frequency;
+Mix.ar({
+frequency = rrand(100, 3000);
+Pan2.ar(SinOsc.ar(frequency,
+mul: EnvGen.kr(Env.perc(0.001, frequency/1000),
+Dust.kr(0.05), 0.2)), rrand(-1.0, 1.0)) }.dup(100))}.play
+)
+(//high notes short, low long
+{var frequency;
+Mix.ar({
+frequency = rrand(100, 3000);
+Pan2.ar(SinOsc.ar(frequency,
+mul: EnvGen.kr(Env.perc(200/frequency, 0.0001),
+Dust.kr(0.05), 0.2)), rrand(-1.0, 1.0)) }.dup(100))}.play
+)
+(//low notes short, high long
+{var frequency;
+Mix.ar({
+frequency = rrand(100, 1000);
+Pan2.ar(SinOsc.ar(frequency,
+mul: EnvGen.kr(Env.perc(frequency/500, 0001),
+Dust.kr(0.05), 0.05)), rrand(-1.0, 1.0)) }.dup(100))}.play
+)
+
+
+
+(
+{
+f = 100;
+[
+SinOsc.ar(f*1, mul: 1), SinOsc.ar(f*2, mul: 1/2),
+SinOsc.ar(f*3, mul: 1/3), SinOsc.ar(f*4, mul: 1/4),
+SinOsc.ar(f*5, mul: 1/5), SinOsc.ar(f*6, mul: 1/6),
+SinOsc.ar(f*7, mul: 1/7), SinOsc.ar(f*8, mul: 1/8),
+SinOsc.ar(f*9, mul: 1/9), SinOsc.ar(f*10, mul: 1/10),
+SinOsc.ar(f*11, mul: 1/11), SinOsc.ar(f*12, mul: 1/12)
+]
+}.scope(12)
+)
+
+
+(
+
+{
+ var speed=70, freq=200;
+ freq = MouseX.kr(20,2000);
+ freq = SinOsc.kr(1,add:1.1).explin(0.1,2,20,1000);
+ Mix.new(Array.fill(8, { arg m;
+ n=m+1;
+ SinOsc.ar(freq*n, LFNoise0.kr(rrand(speed, speed*2)), 0.5, 0.5)/n;
+ }));
+}.play
+)
+
+
+
+(
+{
+f = 100;
+t = Impulse.kr(1/3);
+Mix.ar([
+SinOsc.ar(f*1, mul: EnvGen.kr(Env.perc(0, 1.4), t)/1),
+SinOsc.ar(f*2, mul: EnvGen.kr(Env.perc(0, 1.1), t)/2),
+SinOsc.ar(f*3, mul: EnvGen.kr(Env.perc(0, 2), t)/3),
+SinOsc.ar(f*4, mul: EnvGen.kr(Env.perc(0, 1), t)/4),
+SinOsc.ar(f*5, mul: EnvGen.kr(Env.perc(0, 1.8), t)/5),
+SinOsc.ar(f*6, mul: EnvGen.kr(Env.perc(0, 2.9), t)/6),
+SinOsc.ar(f*7, mul: EnvGen.kr(Env.perc(0, 4), t)/7),
+SinOsc.ar(f*8, mul: EnvGen.kr(Env.perc(0, 0.3), t)/8),
+SinOsc.ar(f*9, mul: EnvGen.kr(Env.perc(0, 1), t)/9),
+SinOsc.ar(f*10, mul: EnvGen.kr(Env.perc(0, 3.6), t)/10),
+SinOsc.ar(f*11, mul: EnvGen.kr(Env.perc(0, 2.3), t)/11),
+SinOsc.ar(f*12, mul: EnvGen.kr(Env.perc(0, 1.1), t)/12)
+])*0.5
+}.scope(1)
+)
+
+
+(
+{
+SinOsc.ar([100,200,300])
+}.play
+)
+(
+{
+Mix.new(SinOsc.ar([100,200,300]))
+}.play
+)
+
+
+( // Let it run for a while, the strikes are random
+{
+var trigger, partials = 12;
+trigger = Dust.kr(3/7);
+Pan2.ar(
+Mix.ar(
+{
+SinOsc.ar(exprand(50.0, 4000)) *
+EnvGen.kr(
+Env.perc(0, rrand(0.2, 3.0)),
+trigger,
+1.0.rand
+)
+}.dup(partials)
+)/partials,
+1.0.rand2
+)
+}.play
+)
+
+
+(
+{
+var dur = 6, base, aenv, fenv, out, trig;
+base = Rand(40, 100);
+trig = SinOsc.ar(1/10);
+out = Mix.fill(15,{
+var thisDur;
+thisDur = dur * rrand(0.5, 1.0);
+aenv = EnvGen.kr(Env.perc(0, thisDur), trig);
+fenv = EnvGen.kr(Env.new([0, 0, 1, 0], [0.25*thisDur, 0.75*thisDur, 0]), trig);
+Pan2.ar(SinOsc.ar( Rand(base, base * 12) *
+LFNoise1.kr(10, mul: 0.02 * fenv, add: 1), // freq
+mul: aenv // amp
+), ([1, -1].choose) * fenv)
+}) * 0.05;
+out
+}.play(s);
+{
+var dur = 6, base, aenv, fenv, out, trig, detune;
+base = Rand(40, 60);
+detune = 0.1; // increase this number to detune the second bell
+trig = SinOsc.ar(1/10, pi);
+out = Mix.fill(15,
+{ arg count;
+var thisDur;
+thisDur = dur * rrand(0.5, 1.0);
+aenv = EnvGen.kr(Env.perc(0, thisDur), trig);
+fenv = EnvGen.kr(Env.new([1, 1, 0, 1], [0.05*thisDur, 0.95*thisDur, 0]), trig);
+Pan2.ar(SinOsc.ar( base*(count+1+ detune.rand) *
+LFNoise1.kr(10, mul: 0.02 * fenv, add: 1), // freq
+mul: aenv // amp
+), ([1, -1].choose) * fenv)
+}) * 0.05;
+out
+}.play(s);
+)
+
+
+(
+{
+var aenv, fenv, out, trig, dur, base;
+dur = rrand(1.0, 6.0);
+base = exprand(100, 1000);
+trig = Impulse.kr(1/6);
+out = Mix.ar(
+Array.fill(15,{
+arg count;
+var thisDur;
+thisDur = dur * rrand(0.5, 1.0);
+aenv = EnvGen.kr(
+Env.new([0, 1, 0.4, 1, 0], [0, 0.5, 0.5, 0]), trig,
+timeScale: thisDur);
+fenv = EnvGen.kr(
+Env.new([0, 0, 0.5, 0.5, 0], [0.25, 0.5, 0.25, 0]),
+trig, timeScale: thisDur);
+Pan2.ar(SinOsc.ar( Rand(base, base * 12) *
+LFNoise1.kr(10, mul: 0.1 * fenv, add: 1), // freq
+mul: aenv // amp
+), ([1, -1].choose) * fenv)
+})
+) * EnvGen.kr(Env.linen(0, dur, 0), Impulse.kr(6), timeScale: dur,
+levelScale: 0.05, doneAction: 2);
+out*0.3;
+}.play;
+)
+
+{Mix.fill(1000, {SinOsc.ar(rrand(1.0, 20000))})*0.01}.play
+{WhiteNoise.ar(1)}.play
+
+
+(
+{
+var signal, filter, cutoff, resonance;
+signal = PinkNoise.ar(mul: 0.7);
+cutoff = MouseX.kr(40, 10000, 1);
+resonance = MouseY.kr(0.01, 2.0);
+RHPF.ar(signal, cutoff, resonance)}.scope(1)
+)
+(
+{
+var signal, filter, cutoff, resonance;
+signal = PinkNoise.ar(mul: 0.7);
+cutoff = MouseX.kr(40, 10000, 1);
+resonance = MouseY.kr(0.01, 2.0);
+RLPF.ar(signal, cutoff, resonance)}.scope(1)
+)
+(
+{
+var signal, filter, cutoff, resonance;
+signal = PinkNoise.ar(mul: 0.7);
+cutoff = MouseX.kr(40, 10000, 1);
+resonance = MouseY.kr(0.01, 2.0);
+BPF.ar(signal, cutoff, resonance)}.scope(1)
+)
+{RLPF.ar(PinkNoise.ar(0.3), LFNoise0.kr([12, 12], 500, 500), 0.02)}.play
+
+
+(
+{
+Klank.ar(
+`[[100, 200, 300, 400, 500, 600, 700, 800, 900, 1000], //freq array
+[0.05, 0.2, 0.04, 0.06, 0.11, 0.01, 0.15, 0.03, 0.15, 0.2]],
+PinkNoise.ar(MouseX.kr(0.01, 0.1)))
+}.scope(1)
+)
+(
+{
+Klank.ar(
+`[Array.series(10, 50, 50),
+Array.series(10, 1.0, -0.1)],
+ClipNoise.ar(0.01)
+)
+}.scope(1)
+)
+
+
+(
+{
+Klank.ar(
+`[{exprand(60, 10000)}.dup(15)],
+PinkNoise.ar(0.005)
+)
+}.scope(1);
+)
+
+
+(
+{
+var burstEnv, att = 0, burstLength = 0.0001, signal; //Variables
+burstEnv = Env.perc(0, burstLength); //envelope times
+signal = PinkNoise.ar(EnvGen.kr(burstEnv, gate: Impulse.kr(1))); //Noise burst
+signal;
+}.play
+)
+
+
+(
+{
+var chime, freqSpecs, burst, totalHarm = 10;
+var burstEnv, att = 0, burstLength = 0.0001;
+freqSpecs = `[
+{rrand(100, 1200)}.dup(totalHarm), //freq array
+{rrand(0.3, 1.0)}.dup(totalHarm).normalizeSum.round(0.01), //amp array
+{rrand(2.0, 4.0)}.dup(totalHarm)]; //decay rate array
+burstEnv = Env.perc(0, burstLength); //envelope times
+burst = PinkNoise.ar(EnvGen.kr(burstEnv, gate: Impulse.kr(1))); //Noise burst
+Klank.ar(freqSpecs, burst)*MouseX.kr(0.1, 0.8)
+}.scope(1)
+)
+
+
+(
+{
+var chime, freqSpecs, burst, totalHarm = 10;
+var burstEnv, att = 0, burstLength = 0.0001;
+freqSpecs = `[
+{rrand(1, 30)*200}.dup(totalHarm),
+{rrand(0.1, 0.9)}.dup(totalHarm).normalizeSum,
+{rrand(1.0, 3.0)}.dup(totalHarm)];
+burstEnv = Env.perc(0, burstLength);
+burst = PinkNoise.ar(EnvGen.kr(burstEnv, gate: Impulse.kr(1)));
+Klank.ar(freqSpecs, burst)*MouseX.kr(0.1, 0.8)
+}.scope(1)
+)
+
+
+(
+{
+var totalInst, totalPartials, baseFreq, ampControl, chimes, cavern;
+totalInst = 5; //Total number of chimes
+totalPartials = 12; //Number of partials in each chime
+baseFreq = rrand(200, 1000); //Base frequency for chimes
+chimes =
+Mix.ar(
+{
+Pan2.ar(
+Klank.ar(`[
+{baseFreq*rrand(1.0, 12.0)}.dup(totalPartials),
+Array.rand(totalPartials, 0.3, 0.9),
+Array.rand(totalPartials, 0.5, 6.0)],
+Decay.ar(
+Dust.ar(0.2, 0.02), //Times per second, amp
+0.001, //decay rate
+PinkNoise.ar //Noise
+)), 1.0.rand2) //Pan position
+}.dup(totalInst)
+);
+cavern =
+Mix.ar(
+{
+var base;
+base = exprand(50, 500);
+Klank.ar(
+`[ //frequency, amplitudes, and decays
+{rrand(1, 24) * base *
+rrand(1.0, 1.1)}.dup(totalPartials),
+Array.rand(10, 1.0, 5.0).normalizeSum
+],
+GrayNoise.ar( [rrand(0.03, 0.1), rrand(0.03, 0.1)])
+)*max(0, LFNoise1.kr(3/rrand(5, 20), mul: 0.005))
+}.dup(5));
+cavern + chimes
+}.play
+)
+
+
+(
+{
+var totalPartials = 4;
+Mix.ar(
+{
+var base;
+base = exprand(50, 10000);
+Pan2.ar(
+Klank.ar(
+`[ //frequency, amplitudes, and decays
+{rrand(1, 24) * base *
+rrand(1.0, 1.1)}.dup(totalPartials),
+Array.rand(10, 1.0, 5.0).normalizeSum
+],
+GrayNoise.ar( rrand(0.03, 0.1))
+)*max(0, SinOsc.kr(6/rrand(1, 10), mul: 0.005)),
+LFNoise1.kr(1))
+}.dup(8));
+}.play
+)
+
+
+(
+{PMOsc.ar(LFNoise0.kr([9, 9], 300, 700),
+LFNoise0.kr([9, 9], 500, 700),
+LFNoise0.kr([9, 9], 6, 12),
+mul: 0.5
+)}.scope(1)
+)
+
+
+(
+{
+SinOsc.ar(
+Latch.kr(
+LFSaw.kr(Line.kr(0.1, 20, 60), 0, 500, 600),
+Impulse.kr(10)),
+mul: 0.3 //Volume of Blip
+)
+}.scope(1)
+)
+
+
+
+
+
+
+
+s.boot
+
+
+(
+Ndef(\plop, { arg freq=50, amp=0.4, noise=10, freq2=100, attime=0.01, dctime=0.1, ctime=5, ffreqr=0.5, rq=0.1;
+ var ou, ou1, ou2, gate;
+ gate = Impulse.ar(1/5);
+ //ou = Decay2.ar(gate,attime,dctime);
+ //ou = EnvGen.ar(Env.perc(0.00001,1.5),gate);
+ ou = 1;
+ ou2 = Pulse.ar(freq*[1.0154,1,0.99874,0.9789]).sum;
+ //ou2 = 0;
+ ou1 = PinkNoise.ar(noise);
+ ou1 = 0;
+ ou = ou * (ou2 + ou1);
+ //ou = SinOsc.ar(freq2) * ou;
+ //ou = Pulse.ar(freq2) * ou;
+ //ou = ou * WhiteNoise.ar(1);
+ //ou = CombL.ar(ou, (freq+10).reciprocal,(freq*[1.01,0.9987,1.0123]).reciprocal,ctime).sum;
+ //ou = CombL.ar(ou, (freq+10).reciprocal,(freq*([1.01,0.9987,1.0123]+0.01)).reciprocal,5);
+ //ou = Decay.ar(Impulse.ar(1),1)*ou;
+ ou = EnvGen.ar(Env.perc(0.00001,5.5),gate) * ou;
+ ou = Decay2.ar(gate,0.00001,50)*ou;
+ ou = BPF.ar(ou,freq*ffreqr,rq);
+ ou = ou * amp * AmpComp.kr(freq,30,1.23);
+
+ ou = ou!2;
+
+}).play;
+)
+NdefGui(Ndef(\rla),12)
+
+
+
+Pdef(\a, Pbind(\freq, Prand((1..16) * 55, inf)));
+Pdef(\a).play;
+t = PdefGui(Pdef(\a), 4);
+Pdef(\a).set(\dur, 0.125, \amp, 0.05);
+
+(
+Ndef(\bla, {
+ var aa = Pulse.kr(100.2,0.5,100,200);
+ LFSaw.ar(aa);
+ //SinOsc.ar(500)*SinOsc.ar(300,0,0.1,SinOsc.kr(1,0,0.1,1))
+}).play
+
+)
+(
+Ndef(\rla, { arg freq = 100, amp=0.1, att=0.1,dc=0.1, dec=0.1,rq=0.5,ffr=0.9, fshift= (-100);
+ var ou;
+ freq = freq*[1.01,1,0.99];
+ RandSeed.kr(Impulse.ar(1),1244);
+ ou = PinkNoise.ar(1);
+ ou = ou * Decay2.ar(Impulse.ar(1), att, dc);
+ ou = DynKlank.ar(`[(1..15)*freq,1,dec],ou);
+ ou = FreqShift.ar(ou, fshift);
+ ou = BPF.ar(ou,freq*ffr,rq);
+ ou = ou.sum;
+ ou = ou * amp;
+ ou = Limiter.ar(ou,0.9);
+ ou = ou!2;
+ //SinOsc.ar(500)*SinOsc.ar(300,0,0.1,SinOsc.kr(1,0,0.1,1))
+}).play
+
+)
+(
+SynthDef(\rla, { arg freq = 100, amp=0.1, att=0.1,dc=0.1, dec=0.1,rq=0.5,ffr=0.9, fshift= (-100);
+ var ou;
+ freq = freq*[1.01,1,0.99];
+ RandSeed.kr(Impulse.ar(1),1244);
+ ou = PinkNoise.ar(1);
+ ou = ou * Decay2.ar(Impulse.ar(1), att, dc);
+ ou = DynKlank.ar(`[(1..15)*freq,1,dec],ou);
+ ou = FreqShift.ar(ou, fshift);
+ ou = BPF.ar(ou,freq*ffr,rq);
+ ou = ou.sum;
+ ou = ou * amp;
+ ou = Limiter.ar(ou,0.9);
+ ou = ou!2;
+ Out.ar(0,ou);
+ //SinOsc.ar(500)*SinOsc.ar(300,0,0.1,SinOsc.kr(1,0,0.1,1))
+}).add
+
+)
+
+(
+Pdef(\ni, Pbind(
+ \instrument, \rla,
+ \dur, 1
+)).play
+)
+)
+
+
+
+
+
+
+
+(
+{
+t = Impulse.kr(5);
+o = SinOsc.ar(TRand.kr(2000, 4000, t), mul: EnvGen.kr(Env.perc(0.001, 0.1), t))*0.1;
+Mix.ar(
+ Pan2.ar(
+ CombL.ar(o, 2.0,
+ Array.fill(5, {rrand(0.2, 1.9)}),
+ 1/5
+ ),
+ Array.fill(5, {1.0.rand2})
+ )
+);
+}.play
+)
+// Compare with
+(
+{
+t = Impulse.kr(Array.fill(5, {rrand(4.0, 7.0)}));
+Mix.ar(
+ Pan2.ar(
+ SinOsc.ar(TRand.kr(2000, 4000, t), mul: EnvGen.kr(Env.perc(0.001, 0.1), t))*0.1,
+ Array.fill(5, {1.0.rand2})
+));
+}.play
+)
+
+
+
+
+(//Original patch
+{
+var rate = 12, att = 0.1, decay = 0.2, offset = 180;
+var env, out, pan;
+pan = LFNoise1.kr(1/(decay+att))-1;
+env = EnvGen.kr(Env.perc(att, decay));
+out = Pan2.ar(
+Blip.ar(LFNoise0.ar([1.01,0.99,1]*rate, 10, offset),
+(env)*12 + 1, 0.3).sum,
+pan)*env;
+out
+}.play
+)
+
+(//Original patch
+{
+var rate = 12, att = 0, decay = 5.0, offset = 400;
+var env, out, pan;
+pan = LFNoise1.kr(1/3);
+env = EnvGen.kr(Env.perc(att, decay));
+out = Pan2.ar(
+Blip.ar(offset, (env)*12 + 1, 0.3), pan)*env;
+out = LPF.ar(out, 700, 0.7);
+out
+}.play
+)
+
+
+
+(
+SynthDef.new("KSpluck3",
+{ //Beginning of Ugen function
+arg midiPitch=50, art=0.5;
+var burstEnv, att = 0, dec = 0.01, legalPitches; //Variable declarations
+var out, delayTime;
+delayTime = [midiPitch, midiPitch + 12].midicps.reciprocal;
+burstEnv = EnvGen.kr(Env.perc(att, dec));
+out = PinkNoise.ar([burstEnv, burstEnv]); //Noise burst
+out = CombL.ar(out, delayTime, delayTime,
+art, add: out); //Echo chamber
+out = RLPF.ar(out, LFNoise1.kr(2, 2000, 2100), 0.1); //Filter
+DetectSilence.ar(out, doneAction:2);
+Out.ar(0, out*0.8)
+}
+).play;
+)
+
+(
+SynthDef.new("KSpluck3",
+{ //Beginning of Ugen function
+arg midiPitch=50, art=0.5;
+var burstEnv, att = 0, dec = 0.01, legalPitches; //Variable declarations
+var out, delayTime;
+delayTime = [midiPitch, midiPitch + 12].midicps.reciprocal;
+burstEnv = EnvGen.kr(Env.perc(att, dec));
+out = PinkNoise.ar([burstEnv, burstEnv]); //Noise burst
+out = CombL.ar(out, delayTime, delayTime,
+art, add: out); //Echo chamber
+out = RLPF.ar(out, LFNoise1.kr(2, 2000, 2100), 0.1); //Filter
+DetectSilence.ar(out, doneAction:2);
+Out.ar(0, out*0.8)
+}
+).play;
+)
+
+
+
+
+
+(
+{
+arg freq=200;
+var ou, ou2;
+ou = Klang.ar(`[({100.rand}!10)+freq,1,0]);
+ou = ou * EnvGen.ar(Env.perc(0.01,0.001));
+ou2 = WhiteNoise.ar(1);
+ou2 = EnvGen.ar(Env.perc(0.01,2);
+ou = CombL.ar(ou, 2, 0.01,0.08) + WhiteNoise.ar(1);
+ou = RLPF.ar(ou, freq, 0.8);
+
+
+
+}.play
+)
+
+
+
+
+
+
+
View
139 crap5.sc
@@ -0,0 +1,139 @@
+Server.default = s = Server.internal; s.boot;
+
+b = Buffer.alloc(s, 512, 1, { |buf| buf.chebyMsg([1,0,1,1,0,1])});
+
+(
+{
+ Shaper.ar(
+ b,
+ SinOsc.ar(300, 0, Line.kr(0,1,6)),
+ 0.5
+ )
+}.scope;
+)
+
+b.free;
+
+
+
+Env.new([-1,0,1],[0.1,0.1],[2,-2]).plot;
+Env.new([-1,0,1],[0.1,0.1],[8,-8]).plot;
+
+
+69.midicps
+
+KeyResponder
+
+(
+c = NoteOnResponder({ |src,chan,note,vel|
+ [src,chan,note,note.midicps,vel].postln;
+});
+c.learn; // wait for the first note
+)
+NoteOnResponder.removeAll
+
+67.midicps / 60.midicps
+
+(60.midicps * (1+(1/2))).cpsmidi
+
+{ LFNoise1.ar(1, 0.25,1) }.scope;
+
+x = { MoogFF.ar(Pulse.ar([121.1,121,120.9]), MouseY.kr(100, 10000, 1), MouseX.kr(0, 4)).sum ! 2 }.play(s);
+x = { BPF.ar(Pulse.ar([121.1,121,120.09]), MouseY.kr(100, 10000, 1)+LFNoise1.ar(4,100,101), MouseX.kr(0, 1)+LFNoise1.ar(1,0.1,0.11)).sum }.play(s);
+x = { BPF.ar(Pulse.ar([121.1,121,120.09]), MouseY.kr(100, 10000, 1), MouseX.kr(0.0001, 1)).sum }.play(s);
+x = { RLPF.ar(Pulse.ar([121.1,121,120.09]), MouseY.kr(100, 10000, 1), MouseX.kr(0.0001, 1)).sum }.play(s);
+
+(
+x = {
+ var ou = RLPF.ar(Pulse.ar([121.1,121,120.09]), MouseY.kr(100, 10000, 1), MouseX.kr([0.0001,0.5], 1)).sum;
+ ou = Limiter.ar(ou);
+ ou = ou ! 2
+}.play(s);
+)
+
+AllPass0
+CombL
+
+(
+{
+ z = WhiteNoise.ar(0.2);
+ z + AllpassN.ar(z, 1, XLine.kr(0.0001, 0.01, 20), 0.2)
+}.play
+)
+
+(
+SynthDef("aSynth",{
+ arg lagLev = 0.2, freq= 440, cutoff = 500, gate = 0.5;
+ var osc1 = Mix.fill(8, { SinOsc.ar(freq.lag(lagLev) + (freq*0.01.rand), 0, 0.05) });
+ var filterEnv = EnvGen.ar(Env.adsr(0.02, 0.1, 0.05, 1), gate, doneAction:2);
+ var filterOutput = MoogFF.ar(osc1, cutoff * filterEnv, 3.3); Out.ar(0, filterOutput);
+
+
+}).store
+)
+
+(
+PmonoArtic("aSynth",
+ \freq, Pseq([440,330,440,330,550,770,880], inf),
+ \legato, Pwrand(#[0.5, 1.0], #[0.1, 0.9], inf),
+ \dur, 0.3,
+ \cutoff, Pwhite(5000, 10000, inf)
+
+
+
+).play
+)
+
+
+(
+Ndef(\bla,{
+ arg freq=200, rq=0.1;
+ var ou;
+ //ou = WhiteNoise.ar(1);
+ ou = PinkNoise.ar(1);
+ ou = BPF.ar(ou, freq*[1.0146,0.9987,1], rq);
+
+}).play
+)
+Ndef(\bla).edit
+
+(
+Ndef(\blax,{
+arg freq=250, ifreq=(1/2);
+var gen, genenv, ou, ou2;
+//ou = Klang.ar(`[({100.rand + 10}!10)+freq,1,0]);
+//ou2 = WhiteNoise.ar(1);
+gen = Pulse.ar([1.01,1,0.996998]*freq);
+genenv = gen * EnvGen.ar(Env.perc(0.001,0.9),gate:Impulse.ar(ifreq));
+ou = genenv;
+//ou = AllpassL.ar(ou, 2, freq.reciprocal,0.01);
+ou = AllpassL.ar(ou, 2, (freq*0.99).reciprocal,1.51);
+ou = AllpassL.ar(ou, 2, (freq*1.09).reciprocal,1.51);
+//ou = AllpassL.ar(ou, 2, 0.02,0.1) + ou;
+//ou = AllpassL.ar(ou, 2, 0.001,2.5);
+//ou = AllpassL.ar(ou, 2, 0.01,1.5);
+//ou = AllpassL.ar(ou, 2, 0.051,4.5);
+ou = ou.sum;
+ou2 = BPF.ar(genenv, freq,10.10);
+//ou2 = 0;
+ou = BPF.ar(ou, freq*2,1);
+//ou = 0;
+ou = ou + ou2;
+
+ou = ou ! 2;
+
+}).play
+)
+(
+Ndef(\blax,{
+arg freq=250;
+var gen, genenv, ou, ou2;
+
+
+
+ou = ou ! 2;
+
+}).play
+)
+s.boot
+s.queryAllNodes
View
584 crap6.sc
@@ -0,0 +1,584 @@
+(
+var w, status, limit, buttons, controls = [], one_button, data, synths, one_synth, synths_generator,
+density_one = 1/4, density_many = 1/10, type_distribution = [0.85, 0.15], // tweak it to get more or less dense pattern grid
+task, resolution, direction, pos = 0, step = 1, border = 1, dims = [16,16]; // tweak dims to change size of grid
+w = Window("rand-n-step+", Rect(50,250,dims[0]*22+10+250,dims[1]*22+60)); // window init
+status = StaticText(w, Rect(5, w.bounds.height - 20, w.bounds.width, 20));
+limit = { ReplaceOut.ar(0, Limiter.ar(In.ar(0,2))) }.play( addAction:\addToTail ); // limiter
+data = Array2D(dims[1],dims[0]); // prepare data
+// and buttons
+one_button = { | b, density = 0.1 |
+ b.valueAction = 0; // reset
+ density.coin.if({ b.valueAction = [1,2].wchoose(type_distribution) }); // tweak it
+};
+synths = Array.fill(dims[1], { () });
+buttons = Array.fill(dims[1], { |l|
+ controls = controls.add([ // control buttons
+ Button( w, Rect( 10 + (22*dims[0]), 35 + (22*l), 20, 20) ).states_([['m'],['u']]).action_({ |b| // mute / unmute
+ synths[l].gate = b.value.asBoolean.not.binaryValue;
+ }).mouseOverAction_({ status.string = 'mute/unmute' }),
+ Button( w, Rect( 10 + (22*(dims[0]+1)), 35 + (22*l), 20, 20) ).states_([['p']]).action_({ // dice pattern line
+ buttons[l].do({ |b| one_button.(b, density_one) }); // tweak it
+ }).mouseOverAction_({ status.string = 'randomize pattern' }),
+ Button( w, Rect( 10 + (22*(dims[0]+2)), 35 + (22*l), 20, 20) ).states_([['s']]).action_({ // dice one synth
+ synths[l] = one_synth.(l);
+ }).mouseOverAction_({ status.string = 'randomize synth' }),
+ Slider( w, Rect( 10 + (22*(dims[0]+3)), 35 + (22*l), 60, 20) ).action_({ |b| // synth amp
+ synths[l].amp = b.value.linexp(0,1,1/16,16);
+ }).mouseOverAction_({ status.string = 'tweak synth amp' }),
+ Slider( w, Rect( 10 + (22*(dims[0]+3)+60), 35 + (22*l), 60, 20) ).action_({ |b| // synth stretch
+ synths[l].stretch = b.value.linexp(0,1,1/8,8);
+ }).mouseOverAction_({ status.string = 'tweak synth stretch' }),
+ Slider( w, Rect( 10 + (22*(dims[0]+3)+120), 35 + (22*l), 60, 20) ).action_({ |b| // synth pan
+ synths[l].pan = b.value.linlin(0,1,-1,1);
+ }).mouseOverAction_({ |b| status.string = 'tweak synth pan ' })
+ ]);
+ Array.fill(dims[0], { |i| // grid
+ Button( w, Rect( 5 + (22*i), 35 + (22*l), 20, 20) ).states_([ ['-'], ['+'], ['%'] ]).action_({
+ |b| data[l,i] = b.value
+ }).mouseOverAction_({ status.string = '"%" makes sound with 0.5 probability' });
+ });
+});
+// synth gen functions and initialization
+one_synth = { |i| // tweak this function to (generate and) return other synthdef names
+ var name = 'rstp'++i, pan = -1.0.rand2;
+ SynthDef(name, { |index = 0, amp = 1, stretch = 1, pan = 0| // args: horizontal position in grid, amplitude and stretch correction, pan
+ var sig = Pan2.ar( // tweak sig to get different sound texture
+ PMOsc.ar(80.exprand(10000), 1.exprand(200), 1.exprand(20)),
+ pan,
+ EnvGen.kr(Env(Array.rand(4, 0, 0.05.rrand(0.4)).add(0), Array.rand(3, 0.1, 1.2).add(0.1), 5.rand2), levelScale: amp, timeScale: stretch, doneAction: 2)
+ );
+ Out.ar(0, sig);
+ }).add;
+ controls[i][3].valueAction_(1.explin(1/16,16,0,1));
+ controls[i][4].valueAction_(1.explin(1/8,8,0,1));
+ controls[i][0].valueAction_(0);
+ controls[i][5].valueAction_(pan.linlin(-1,1,0,1));
+ (name: name, gate: 1, amp: 1, stretch: 1, pan: pan);
+};
+synths_generator = { Array.fill(dims[1], { |i| synths[i] = one_synth.(i) } ) };
+synths_generator.();
+// step task
+task = Task({
+ inf.do({
+ pos = (pos + step).mod(dims[0]);
+ dims[1].do({ |l|
+ (buttons[l] @@ pos).font_(Font("sans", 20));
+ (buttons[l] @@ (pos-step)).font_(Font("sans", 14));
+ synths[l].gate.asBoolean.if({
+ var args = [index: pos, amp: synths[l].amp, stretch: synths[l].stretch * TempoClock.tempo.reciprocal * resolution.reciprocal, pan: synths[l].pan ];
+ switch( data[l,pos],
+ 1, { Synth(synths[l].name, args) },
+ 2, { 0.5.coin.if({ Synth(synths[l].name, args) }) }
+ );
+ });
+ });
+ switch( pos,
+ 0, { (border == -1 && step == -1).if({ direction.valueAction = 0 }) },
+ (dims[0] - 1), { (border == -1 && step == 1).if({ direction.valueAction = 1 }) }
+ );
+ (TempoClock.default.tempo.reciprocal / resolution).yield;
+ });
+}, AppClock).play(quant:[0]);
+// app buttons
+Button(w, Rect(5,5, w.bounds.width - 10 / 7, 20)).states_([['reset']]).action_({ |b|
+ synths_generator.();
+ buttons.flat.do({ |b| one_button.(b, 0) }); // tweak it
+}).mouseOverAction_({ status.string = 'reset everything' });
+Button(w, Rect(w.bounds.width - 10 / 7 * 1 + 5, 5, w.bounds.width - 10 / 6, 20)).states_([['lucky?']]).action_({ |b| // lazy patterns
+ buttons.flat.do({ |b| one_button.(b, density_many) }); // tweak it
+}).mouseOverAction_({ status.string = 'create random pattern grid' });
+Button(w, Rect(w.bounds.width - 10 / 7 * 2 + 5, 5, w.bounds.width - 10 / 7, 20)).states_([['noisy?']]).action_({ |b|
+ synths_generator.();
+}).mouseOverAction_({ status.string = 'randomize all synths' });
+Button(w, Rect(w.bounds.width - 10 / 7 * 3 + 5, 5, w.bounds.width - 10 / 7, 20)).states_([['pause'],['play']]).action_({ |b|
+ b.value.asBoolean.if({ task.pause }, { task.resume(quant:[0]) });
+}).mouseOverAction_({ status.string = 'play/pause' });
+direction = Button(w, Rect(w.bounds.width - 10 / 7 * 4 + 5, 5, w.bounds.width - 10 / 7, 20)).states_([['r-t-l'],['l-t-r']]).action_({ |b|
+ b.value.asBoolean.if({ step = -1 }, { step = 1 });
+}).mouseOverAction_({ status.string = 'change playing direction' });
+Button(w, Rect(w.bounds.width - 10 / 7 * 5 + 5, 5, w.bounds.width - 10 / 7, 20)).states_([['fold'],['wrap']]).action_({ |b|
+ b.value.asBoolean.if({ border = -1 }, { border = 1 });
+}).mouseOverAction_({ status.string = 'behavior on the grid border' });
+Slider(w, Rect(w.bounds.width - 10 / 7 * 6 + 5, 5, w.bounds.width - 10 / 7, 20)).action_({ |b|
+ resolution = b.value.linlin(0, 1, 1, 8).quantize(1, 1);
+ status.string = 'resolution: ' ++ resolution;
+}).valueAction_(4.linlin(1,8,0,1)).mouseOverAction_({ status.string = 'change grid resulution' });
+// show
+w.front.onClose = { task.stop; limit.free };
+status.string_('hello, point something to get hint, hopefully..');
+)
+
+41.asBoolean
+Main.version
+s.boot
+
+true.binaryValue
+
+
+
+////////#superCollider///////////
+//////////////////////10_dic_2011
+/////// paisaje Espanol
+///// audio @ http://www.archive.org/details/PaisajeEspanol
+/////// escala A| B| C| D| E| F| G#| A menorArmonica
+/////// 57|59|60|62|64|65| 68|69 //////////////
+s.boot;
+s.scope;
+s.meter;
+FreqScope.new;
+//
+////////
+// *
+(//fx
+SynthDef(\master,{|gate=1|
+ var fx,env;
+ fx=In.ar(20);
+ fx=GVerb.ar(fx,24,3,0.2,mul:0.3);
+ env=EnvGen.ar(Env.asr(0.01,0.98,0.01),gate,doneAction:2);
+ Limiter.ar(Out.ar(0,Pan2.ar(fx*env,[0.92,-0.92])),0.75);
+}).add;
+);
+(//acordes
+SynthDef(\inst,{|gate=1,nota1,nota2,nota3,nota4,rel|
+ var cuerda,env;
+ cuerda=HPF.ar(
+ Limiter.ar((LFTri.ar(nota1.midicps,0,0.7)+SinOsc.ar(nota2.midicps,0.2,0.6)+
+ SinOsc.ar(nota3.midicps,-0.2,0.5)+SinOsc.ar(nota4.midicps,0.1,0.5))
+ +LFTri.ar(Mix(nota1.midicps,nota2.midicps,nota3.midicps,nota4.midicps),0,0.5),
+ 0.9),
+ 200,0.75);
+ env=EnvGen.ar(Env.perc(0.015,rel),gate,doneAction:2);
+ Out.ar([0,20],Pan2.ar(cuerda*env,[0.1,-0.9]))
+}).add;
+);
+(//melodia
+SynthDef(\inst2,{|gate=1,nota1|
+ var cuerda2,env;
+ cuerda2=Limiter.ar(SinOsc.ar(nota1.midicps,0,0.1)+
+ Saw.ar(nota1.midicps,0.1,0.06)+
+ RLPF.ar(
+ LFCub.ar(nota1.midicps,0.1,0.1)+
+ LFTri.ar(nota1.midicps,0.1,0.2),
+ Phasor.kr(Impulse.kr(1),60,10000),
+ 0.5),
+ 0.2);
+ env=EnvGen.ar(Env.perc(0.01,0.15),gate,doneAction:2);
+ Out.ar(20,Pan2.ar(cuerda2*env,[0.9,-0.82]))
+}).add;
+);
+////
+(
+Tdef(\acordes,{
+ var c=0,fund,primerg,segundog,tercerg,cuartog,quintog,sextog,septimog,tiempo,trans,release;
+ Synth(\master);//sinte master
+ ~acorde=Array.newClear(4);//1a,3a,5ta,7ma
+ ~a=[45,47,48,50,52,53,56,57,59,60,62,64,65,68,69,71,72,74,76,77,80,81,83,84,86,88,89,92,93];//escala 4 octavas
+ primerg=~a[0];//1er grado
+ segundog=~a[1];//2do grado
+ tercerg=~a[2];//3er grado
+ cuartog=~a[3];//4to grado
+ quintog=~a[4];//5to grado
+ sextog=~a[5];//6to grado
+ septimog=~a[6];//7mo grado
+ tiempo=Pwrand([0.25,0.5,0.75,1,2],[0.35,0.45,0.05,0.1,0.05],inf).asStream;
+ release=Pwrand([0.25,0.5,0.75,1],[0.1,0.5,0.2,0.2],inf).asStream;
+ inf.do{
+ c=c+1;
+ fund=Array.series(7,0);//fundamentales posibles la primera octava
+ ~numfund=fund.scramble.pyramid.mirror2.reverse[c%fund.size];//grado de la escala
+ //~numfund.postln;
+ ~acorde.put(0,~a[~numfund]);//pone en la tonica algun grado de la escala
+ trans=[0,0,12,24,36,0].choose;
+ //trans.postln;
+ if((~acorde[0]+trans)==(primerg+trans),{//Am7
+ ~acorde.put(1,~a[~numfund]+3);//menor
+ ~acorde.put(2,~a[~numfund]+7);//5ta justa
+ ~acorde.put(3,~a[~numfund]+11)//7ma mayor
+ }
+ );
+ if((~acorde[0]+trans)==(segundog+trans),{//Bm5b7m
+ ~acorde.put(1,~a[~numfund]+3);//menor
+ ~acorde.put(2,~a[~numfund]+6);//5ta disminuida
+ ~acorde.put(3,~a[~numfund]+10)//7ma menor
+ }
+ );
+ if((~acorde[0]+trans)==(tercerg+trans),{//C5#7
+ ~acorde.put(1,~a[~numfund]+4);//mayor
+ ~acorde.put(2,~a[~numfund]+8);//5ta aumentada
+ ~acorde.put(3,~a[~numfund]+11)//7ma mayor
+ }
+ );
+ if((~acorde[0]+trans)==(cuartog+trans),{//Dm7m
+ ~acorde.put(1,~a[~numfund]+3);
+ ~acorde.put(2,~a[~numfund]+7);
+ ~acorde.put(3,~a[~numfund]+10)
+ }
+ );
+ if((~acorde[0]+trans)==(quintog+trans),{//E7m
+ ~acorde.put(1,~a[~numfund]+4);
+ ~acorde.put(2,~a[~numfund]+7);
+ ~acorde.put(3,~a[~numfund]+10)
+ }
+ );
+ if((~acorde[0]+trans)==(sextog+trans),{//F7
+ ~acorde.put(1,~a[~numfund]+4);
+ ~acorde.put(2,~a[~numfund]+7);
+ ~acorde.put(3,~a[~numfund]+11)
+ }
+ );
+ if((~acorde[0]+trans)==(septimog+trans),{//G#5b7dis
+ ~acorde.put(1,~a[~numfund]+3);
+ ~acorde.put(2,~a[~numfund]+6);
+ ~acorde.put(3,~a[~numfund]+9)//7ma disminuida
+ }
+ );
+ ~acorde.postln;
+ ~ins=Synth(\inst);
+ ~ins.set(\nota1,~acorde[0]);
+ ~ins.set(\nota2,~acorde[1]);
+ ~ins.set(\nota3,~acorde[2]);
+ ~ins.set(\nota4,~acorde[3]);
+ ~ins.set(\rel,release.next);
+ tiempo.next.wait
+ }
+});
+);
+(
+Tdef(\melodia,{
+ var c=0,quinta,
+ tiempo=Pwrand([0.25,0.5,1,0.0125],[0.35,0.6,0.25,0.025],inf).asStream;
+ inf.do{
+ ~amel=[57,59,60,62,64,65,68,69,71,72,74,76,77,80,81,83,84,86,88,89,92,93];//3 octavas
+ c=c+1;
+ ~numel=~amel.scramble[c%~amel.size];
+ ~numel.postln;
+ quinta=[0,0,7,12,0].choose;//se transpone una quinta u octava
+ ~ins2=Synth(\inst2);
+ ~ins2.set(\nota1,~numel+quinta);
+ tiempo.next.wait
+ }
+});
+);
+(//
+Tdef(\acordes).play;
+Tdef(\melodia).play;
+)
+Tdef(\melodia).stop;
+Tdef(\acordes).stop;
+
+
+
+
+
+
+
+
+
+
+
+
+(
+Ndef(\bla,{
+var ou;
+var ph = MouseX.kr(30,700);
+var ph2 = MouseY.kr(1,100);
+var im = Impulse.kr(1/2);
+var env = EnvGen.kr(Env.perc(0.0001,0.1),im);
+var env2 = EnvGen.kr(Env.perc(0.1,0.001),im);
+ou = LFSaw.ar(ph) * env;
+ou = CombN.ar(ou,0.1, 1/(env * ph + ph2),2);
+ou = CombN.ar(ou,0.1, 1/ph2,2);
+ou = ou * 0.1;
+ou = ou !2;
+
+}).play
+)
+
+b = Buffer.read(s, "sounds/pok2.wav");
+
+(
+Ndef(\plop, {
+ var ou , tri, la, src;
+ tri = Impulse.kr(8);
+ src = PlayBuf.ar(1, b, BufRateScale.kr(b), loop:0);
+ ou = src;
+ //src = AllpassN.ar(src, 1, XLine.kr(1,1/20,0.2),5.1);
+ src = AllpassN.ar(src, 1, SinOsc.kr(8)*0.1+1.1001,5.1);
+ //src = AllpassN.ar(src, 1, XLine.kr(0.1,1/70,0.1),0.5) - src;
+ //src = AllpassN.ar(src, 1, XLine.kr(0.2,1/170,0.1),0.5) - src;
+ //src = AllpassN.ar(src, 1, XLine.kr(0.1,1/50,0.5),1.5) - src;
+ ou = ou - src;
+ ou = Limiter.ar(ou);
+
+ //src = PlayBuf.ar(1, b, BufRateScale.kr(b), loop:0);
+
+}).play
+)
+
+
+
+(
+b = Buffer.alloc(s,2048,1);
+c = Buffer.read(s,"sounds/a11wlk01.wav");
+)
+
+(
+//trig with MouseY
+SynthDef("help-diffuser", { arg out=0, bufnum=0 ;
+ var in, chain;
+ in = Mix.ar(SinOsc.ar(200 * (1..10), 0, Array.fill(10, {rrand(0.1, 0.2)}) ));
+ chain = FFT(bufnum, in);
+ chain = PV_Diffuser(chain, MouseY.kr > 0.5 );
+ Out.ar(out, 0.5 * IFFT(chain).dup);
+}).play(s,[\out, 0, \bufnum, b.bufnum ]);
+)
+
+(
+//trig with MouseY
+SynthDef("help-diffuser2", { arg out=0, bufnum=0, soundBufnum=2;
+ var in, chain;
+ in = PlayBuf.ar(1, soundBufnum, BufRateScale.kr(soundBufnum), loop: 1);
+ chain = FFT(bufnum, in);
+ chain = PV_Diffuser(chain, MouseY.kr > 0.5 );
+ Out.ar(out, 0.5 * IFFT(chain).dup);
+}).play(s,[\out, 0, \bufnum, b.bufnum, \soundBufnum, c.bufnum]);
+)
+
+Formlet
+HPZ1
+Integrator
+MidEQ
+
+
+a = Signal.sineFill(512, [1]);
+a.plot
+
+b = Signal.sineFill(512, [1]);
+b.waveFill({arg x, i; a.wrapAt(x.postln*2) },0,512)
+~signalFill.(b, b, [1,0.5,0.5]).plot
+~signalFill.(b, a, [0,1])
+b = b.atan
+b.plot2
+b.atan
+c = Signal.sineFill(512, [1,0.5,0.5]);
+[b,c].do(_.plot)
+[b,d].plot2
+d = ~signalLag.(b,100);
+(
+~signalFill = { arg sigthis, sigin, amps;
+ if(sigthis == sigin) {
+ sigin = sigin.copy
+ };
+ sigthis.waveFill({arg x;
+ amps.collect { arg amp, i;
+ sigin.wrapAt(x*(i+1)) * amp
+ }.sum;
+ }, 0, sigthis.size);
+ sigthis.normalize;
+};
+)
+(
+~signalLag = { arg sig, size=4;
+ var rs = sig[0] ! size;
+ var newsig;
+ newsig = sig.collect { arg x, i;
+ rs.insert(0,x);
+ rs.pop;
+ rs.sum / size;
+ };
+ newsig.as(Signal);
+}
+)
+
+k = Signal[1,2,3,4]
+j = Signal[0,0,0,0]
+~signalFill.(j, k, [0,1])
+k.lowpass(1000.004)
+k.pop(0)
+k.insert(0,7)
+k.sum
+d.as(Signal)
+
+~buf = Buffer.alloc(s, 1024, 1);
+~nbuf = Buffer.allocConsecutive(3,s,1024);
+
+~buf.loadCollection(e.asWavetable);
+~nbuf[0].loadCollection(b.asWavetable);
+~nbuf[1].loadCollection(d.asWavetable);
+~signalSpectre.(e)
+e = Signal.newClear(512);
+e.waveFill({arg x; 2**( 0 - (x**2)/0.001)},-2,2)
+(
+
+SynthDef("help-Osc",{ arg out=0,freq=100,bufnum=0;
+ var ou,fou,ou2;
+ ou = VOsc.ar(bufnum+MouseX.kr(0,1), freq);
+ ou = ou ! 2;
+ Out.ar(out,ou)
+
+}).play(s,[\out, 0, \bufnum, ~nbuf[0].bufnum]);
+)
+(
+
+SynthDef("help-Osc",{ arg out=0,freq=500,bufnum=0;
+ var ou,fou,ou2;
+ ou = COsc.ar(bufnum, MouseX.kr(30,freq));
+ ou = ou ! 2;
+ Out.ar(out,ou)
+
+}).play(s,[\out, 0, \bufnum, ~buf.bufnum]);
+)
+
+
+
+(
+var size = 512, real, imag, cosTable, complex;
+
+real = Signal.newClear(size);
+ // some harmonics
+real.sineFill2([[8], [13, 0.5], [21, 0.25], [55, 0.125, 0.5pi]]);
+ // add a little noise
+real.overDub(Signal.fill(size, { 0.2.bilinrand }));
+
+imag = Signal.newClear(size);
+cosTable = Signal.fftCosTable(size);
+
+complex = fft(real, imag, cosTable);
+[real, imag, (complex.magnitude) / 100 ].flop.flat
+ .plot2("fft", Rect(0, 0, 512 + 8, 500), numChannels: 3);
+)
+
+
+(
+~signalSpectre = { arg sig;
+ var real, imag, cosTable, complex, size;
+ size = sig.size;
+ real = sig;
+
+ imag = Signal.newClear(size);
+ cosTable = Signal.fftCosTable(size);
+ complex = fft(real, imag, cosTable);
+
+ [real, imag, (complex.magnitude) / 100 ].flop.flat
+ .plot2("fft", Rect(0, 0, 812 + 8, 700), numChannels: 3);
+};
+
+)
+
+
+
+(
+var w, status, limit, buttons, controls = [], one_button, data, synths, one_synth, synths_generator,
+density_one = 1/4, density_many = 1/10, type_distribution = [0.85, 0.15], // tweak it to get more or less dense pattern grid
+task, resolution, direction, pos = 0, step = 1, border = 1, dims = [16,16]; // tweak dims to change size of grid
+w = Window("rand-n-step+", Rect(50,250,dims[0]*22+10+250,dims[1]*22+60)); // window init
+status = StaticText(w, Rect(5, w.bounds.height - 20, w.bounds.width, 20));
+limit = { ReplaceOut.ar(0, Limiter.ar(In.ar(0,2))) }.play( addAction:\addToTail ); // limiter
+data = Array2D(dims[1],dims[0]); // prepare data
+// and buttons
+one_button = { | b, density = 0.1 |
+ b.valueAction = 0; // reset
+ density.coin.if({ b.valueAction = [1,2].wchoose(type_distribution) }); // tweak it
+};
+synths = Array.fill(dims[1], { () });
+buttons = Array.fill(dims[1], { |l|
+ controls = controls.add([ // control buttons
+ Button( w, Rect( 10 + (22*dims[0]), 35 + (22*l), 20, 20) ).states_([['m'],['u']]).action_({ |b| // mute / unmute
+ synths[l].gate = b.value.booleanValue.not.binaryValue;
+ }).mouseOverAction_({ status.string = 'mute/unmute' }),
+ Button( w, Rect( 10 + (22*(dims[0]+1)), 35 + (22*l), 20, 20) ).states_([['p']]).action_({ // dice pattern line
+ buttons[l].do({ |b| one_button.(b, density_one) }); // tweak it
+ }).mouseOverAction_({ status.string = 'randomize pattern' }),
+ Button( w, Rect( 10 + (22*(dims[0]+2)), 35 + (22*l), 20, 20) ).states_([['s']]).action_({ // dice one synth
+ synths[l] = one_synth.(l);
+ }).mouseOverAction_({ status.string = 'randomize synth' }),
+ Slider( w, Rect( 10 + (22*(dims[0]+3)), 35 + (22*l), 60, 20) ).action_({ |b| // synth amp
+ synths[l].amp = b.value.linexp(0,1,1/16,16);
+ }).mouseOverAction_({ status.string = 'tweak synth amp' }),
+ Slider( w, Rect( 10 + (22*(dims[0]+3)+60), 35 + (22*l), 60, 20) ).action_({ |b| // synth stretch
+ synths[l].stretch = b.value.linexp(0,1,1/8,8);
+ }).mouseOverAction_({ status.string = 'tweak synth stretch' }),
+ Slider( w, Rect( 10 + (22*(dims[0]+3)+120), 35 + (22*l), 60, 20) ).action_({ |b| // synth pan
+ synths[l].pan = b.value.linlin(0,1,-1,1);
+ }).mouseOverAction_({ |b| status.string = 'tweak synth pan ' })
+ ]);
+ Array.fill(dims[0], { |i| // grid
+ Button( w, Rect( 5 + (22*i), 35 + (22*l), 20, 20) ).states_([ ['-'], ['+'], ['%'] ]).action_({
+ |b| data[l,i] = b.value
+ }).mouseOverAction_({ status.string = '"%" makes sound with 0.5 probability' });
+ });
+});
+// synth gen functions and initialization
+one_synth = { |i| // tweak this function to (generate and) return other synthdef names
+ var name = 'rstp'++i, pan = -1.0.rand2;
+ SynthDef(name, { |index = 0, amp = 1, stretch = 1, pan = 0| // args: horizontal position in grid, amplitude and stretch correction, pan
+ var sig = Pan2.ar( // tweak sig to get different sound texture
+ PMOsc.ar(80.exprand(10000), 1.exprand(200), 1.exprand(20)),
+ pan,
+ EnvGen.kr(Env(Array.rand(4, 0, 0.05.rrand(0.4)).add(0), Array.rand(3, 0.1, 1.2).add(0.1), 5.rand2), levelScale: amp, timeScale: stretch, doneAction: 2)
+ );
+ Out.ar(0, sig);
+ }).add;
+ controls[i][3].valueAction_(1.explin(1/16,16,0,1));
+ controls[i][4].valueAction_(1.explin(1/8,8,0,1));
+ controls[i][0].valueAction_(0);
+ controls[i][5].valueAction_(pan.linlin(-1,1,0,1));
+ (name: name, gate: 1, amp: 1, stretch: 1, pan: pan);
+};
+synths_generator = { Array.fill(dims[1], { |i| synths[i] = one_synth.(i) } ) };
+synths_generator.();
+// step task
+task = Task({
+ inf.do({
+ pos = (pos + step).mod(dims[0]);
+ dims[1].do({ |l|
+ (buttons[l] @@ pos).font_(Font("sans", 20));
+ (buttons[l] @@ (pos-step)).font_(Font("sans", 14));
+ synths[l].gate.booleanValue.if({
+ var args = [index: pos, amp: synths[l].amp, stretch: synths[l].stretch * TempoClock.tempo.reciprocal * resolution.reciprocal, pan: synths[l].pan ];
+ switch( data[l,pos],
+ 1, { Synth(synths[l].name, args) },
+ 2, { 0.5.coin.if({ Synth(synths[l].name, args) }) }
+ );
+ });
+ });
+ switch( pos,
+ 0, { (border == -1 && step == -1).if({ direction.valueAction = 0 }) },
+ (dims[0] - 1), { (border == -1 && step == 1).if({ direction.valueAction = 1 }) }
+ );
+ (TempoClock.default.tempo.reciprocal / resolution).yield;
+ });
+}, AppClock).play(quant:[0]);
+// app buttons
+Button(w, Rect(5,5, w.bounds.width - 10 / 7, 20)).states_([['reset']]).action_({ |b|
+ synths_generator.();
+ buttons.flat.do({ |b| one_button.(b, 0) }); // tweak it
+}).mouseOverAction_({ status.string = 'reset everything' });
+Button(w, Rect(w.bounds.width - 10 / 7 * 1 + 5, 5, w.bounds.width - 10 / 6, 20)).states_([['lucky?']]).action_({ |b| // lazy patterns
+ buttons.flat.do({ |b| one_button.(b, density_many) }); // tweak it
+}).mouseOverAction_({ status.string = 'create random pattern grid' });
+Button(w, Rect(w.bounds.width - 10 / 7 * 2 + 5, 5, w.bounds.width - 10 / 7, 20)).states_([['noisy?']]).action_({ |b|
+ synths_generator.();
+}).mouseOverAction_({ status.string = 'randomize all synths' });
+Button(w, Rect(w.bounds.width - 10 / 7 * 3 + 5, 5, w.bounds.width - 10 / 7, 20)).states_([['pause'],['play']]).action_({ |b|
+ b.value.booleanValue.if({ task.pause }, { task.resume(quant:[0]) });
+}).mouseOverAction_({ status.string = 'play/pause' });
+direction = Button(w, Rect(w.bounds.width - 10 / 7 * 4 + 5, 5, w.bounds.width - 10 / 7, 20)).states_([['r-t-l'],['l-t-r']]).action_({ |b|
+ b.value.booleanValue.if({ step = -1 }, { step = 1 });
+}).mouseOverAction_({ status.string = 'change playing direction' });
+Button(w, Rect(w.bounds.width - 10 / 7 * 5 + 5, 5, w.bounds.width - 10 / 7, 20)).states_([['fold'],['wrap']]).action_({ |b|
+ b.value.booleanValue.if({ border = -1 }, { border = 1 });
+}).mouseOverAction_({ status.string = 'behavior on the grid border' });
+Slider(w, Rect(w.bounds.width - 10 / 7 * 6 + 5, 5, w.bounds.width - 10 / 7, 20)).action_({ |b|
+ resolution = b.value.linlin(0, 1, 1, 8).quantize(1, 1);
+ status.string = 'resolution: ' ++ resolution;
+}).valueAction_(4.linlin(1,8,0,1)).mouseOverAction_({ status.string = 'change grid resulution' });
+// show
+w.front.onClose = { task.stop; limit.free };
+status.string_('hello, point something to get hint, hopefully..');
+)
+
+
+a = ProcMod.new(Env([0, 1, 0], [1, 1], \sin, 1), server: s);
+s.boot
View
496 crap7.sc
@@ -0,0 +1,496 @@
+// a simple synth
+
+s.boot;
+
+Ndef(\test, { |pFreq=100, pWidth=0.5| LPF.ar(LFPulse.ar(pFreq, 0, pWidth), 1500) * 0.1 });
+
+Ndef(\test).play;
+
+Ndef(\test).scope;
+
+
+( // controlspecs for its params
+
+Spec.add(\pFreq, [2, 200, \exp]);
+
+Spec.add(\pWidth, [0.01, 0.5, \exp]);
+
+)
+
+// an editor to see the params changing
+
+NdefGui(Ndef(\test), 5);
+
+Ndef(\test).set(\pFreq, \pFreq.asSpec.map(0.5));
+
+Ndef(\test).set(\pWidth, \pWidth.asSpec.map(0.5));
+
+
+*new(key, ctlMap)
+
+// make a controlLoop to record and play back slider movement:
+
+// prepare for two normalized controls (range 0 - 1).
+
+// ctlMap defines the actions to take when a control event
+
+// is played back. here, \x sets the parameter \pFreq,
+
+// and y will set parameter \pWidth (later).
+Quarks.gui
+(
+
+c = CtLoop(\mytest,
+
+(
+
+x: { |val| Ndef(\test).set(\pFreq, \pFreq.asSpec.map(val)) },
+
+y: { |val| Ndef(\test).set(\pWidth, \pWidth.asSpec.map(val)) }
+
+)
+
+);
+
+)
+
+
+// a gui to control one synth param, and to record movements
+
+(
+
+EZSlider(nil, nil, \ctLooptest, nil, { |sl|
+
+var normVal = sl.value; //
+
+// keep new events if recording
+
+c.recordEvent(\x, normVal);
+
+// set synth param
+
+Ndef(\test).set(\pFreq, \pFreq.asSpec.map(normVal))
+
+});
+
+)
+
+
+c.startRec; // wiggle slider now
+
+c.stopRec; // stop when done
+
+
+c.play; // see slider in NodeProxyEditor for recorded movement
+
+c.stop;
+
+
+
+// use the same CtLoop with a 2D controller:
+
+(
+
+w = Window("play me").front;
+
+t = Slider2D(w, Rect(0,0,400,400))
+
+.action_({ |sl|
+
+var x, y; x = sl.x; y = sl.y;
+
+c.recordEvent(\x, x);
+
+c.recordEvent(\y, y);
+
+Ndef(\test).set(
+
+\pFreq, \pFreq.asSpec.map(x),
+
+\pWidth, \pWidth.asSpec.map(y)
+
+);
+
+});
+
+)
+
+
+c.startRec; // wiggle 2dslider now
+
+c.stopRec; // stop when done
+
+
+// playback options:
+
+c.play;
+
+c.togglePlay;
+
+c.togglePlay;
+
+
+// playback is looped by default
+
+c.reverse;
+
+c.forward;
+
+c.flip; // toggle loop direction
+
+c.flip;
+
+
+c.tempo = 2; // faster
+
+c.tempo = 0.5; // slower
+
+c.tempo = 1; // orig
+
+
+// play only part of the loop:
+
+c.start = 0.3; // a segment within range 0.0-1.0.
+
+// percentage is of the number of events, not of loop duration
+
+
+c.start = 1.0.rand; //
+
+c.length = 1.0.rand; //
+
+c.length = 0.1.rand; //
+
+
+// full loop
+
+c.start_(0).length_(1);
+
+
+// 'sequence jitter': loop index moves as before,
+
+// the actual event played is chosen within jitter range near the loop index.
+
+c.jitter = 0.1; // +- 10% loop length jitter
+
+c.jitter = 0.2;
+
+c.jitter = 0.0; // orig. sequence
+
+
+c.resetLoop; // reset to defaults;
+
+
+
+
+// gesture range can be rescaled in several ways
+
+
+// turn on gesture rescaling
+
+c.rescaled_(true);
+
+
+c.invert; // invert around middle axis
+
+c.up; // that is right side up
+
+c.flipInv; // toggle inversion on/off
+
+c.flipInv;
+
+
+
+c.scaler = 2; // make gesture bigger
+
+c.scaler = 1; // orig size
+
+c.scaler = 0.5; // smaller
+
+c.scaler = 0.2; // or even smaller
+
+
+c.shift = 0.1; // shift its range up
+
+c.shift = 0.2;
+
+c.shift = 0.3;
+
+// Q: maybe rescaling could optionally go outside the spec range?
+
+
+c.resetScaling; // back to orig
+
+
+
+c.rescaled_(false);
+
+c.scaler = 0.1; // no effect when rescaled is false
+
+
+c.rescaled_(true); // should rescale to tiny now
+
+c.scaler = 2; // and big again.
+
+
+
+c.dontRescale(\x); // except a control name from rescaling
+
+// so here, x will not be rescaled, but y will.
+
+c.nonRescalableCtls;
+
+
+c.dontRescale(\x, \y);
+
+c.doRescale(\x, \y); // make sure they all rescale again
+
+
+c.list; // the list of recorded control events
+
+c.clear; // clear it
+
+
+c.startRec; // this also clears the list;
+
+c.stopRec;
+
+
+c.list.printAll;
+
+c.play;
+
+
+
+CtLoop is more about capturing multidimensional gestures, e.g from a Wii or Gamepad joysticks,
+
+faderboxes etc. It is not about fader automation, but rather exploring and juggling with
+
+recorded movements as performance.
+
+
+It is used e.g. in the GamePad class, and could be used with lots of HID, MIDI,
+
+OSC etc controllers. It will likely move to the Modality quark.
+
+
+
+
+
+s.boot; // server must be booted, then:
+
+
+(
+
+GamePad.startHID; // builds the setup automatically.
+
+p = p ?? { ProxySpace(s); }; p.push; // make a proxyspace but only if needed.
+
+)
+
+
+// Now switch your gamepad to analog mode, and test that you get numbers:
+
+
+GamePad.verbose = true; // move joysticks to see e.g. [ hid, 19, 0.95686274509804 ] posted.
+
+GamePad.verbose = false;
+
+
+// GamePad.stop; // stop HID event loop to turn gamePad off.
+
+
+
+// Then you can put a proxy in room 0
+
+(
+
+// a simple proxy : modulating formant frequency, root and number of harmonics
+
+~formsing = { arg formfrq=500, root=300, harm=20, amp=0.4, lag= 0.2;
+
+var in = Blip.ar(root.lag(lag), harm.lag(lag), 0.1);
+
+Formlet.ar(in, formfrq.lag(lag) * [1, 1.06], 0.005, 0.04)
+
+* 5 * amp.lag(lag);
+
+};
+
+// make sure it plays sound
+
+~formsing.play(vol: 0.25);
+
+
+
+// make controlspecs for its parameters:
+
+Spec.specs.put(\formfrq, ControlSpec(100, 5000, \exp));
+
+Spec.specs.put(\root, ControlSpec(5, 500, \exp));
+
+Spec.specs.put(\harm, ControlSpec(1, 256, \exp));
+
+
+
+Spec.add(\formfrq, [100, 5000, \exp]);
+
+
+// make a GUI for the ProxySpace:
+
+ProxyMixer(p);
+
+
+// then put the proxy into the GamePad, at wing 0 + room 0;
+
+// wings are in groups of 4 proxies each.
+
+GamePad.putProxy(0,
+
+\formsing,
+
+(
+
+joyRY: { arg val; ~formsing.group.set(\amp, \amp.asSpec.map(val)) }, joyLX: { arg val; ~formsing.group.set(\formfrq, \formfrq.asSpec.map(val)) }, joyLY: { arg val; ~formsing.group.set(\root, \root.asSpec.map(val)) }, joyRX: { arg val; ~formsing.group.set(\harm,\harm.asSpec.map(val)) } )
+
+);
+
+)
+
+
+
+
+// Look for the devices that are attached:
+GeneralHID.buildDeviceList;
+// Get the list of devices:
+d = GeneralHID.deviceList;
+// Check which devices have been found:
+GeneralHID.postDevices;
+// Pick the 6th device and open it and create an instance of it:
+a = GeneralHID.open( d[5] )
+d.printAll
+// Get info on the device:
+a.info;
+
+
+
+GeneralHID.startEventLoop
+// Get the capabilities of the device in a readable format:
+a.caps;
+// there are different types of slots:
+// button (type 1), has only on/off (1/0) states
+// relative (type 2), counts up or down (scrollwheel for example)
+// absolute (type 3), continuous value between 0 and 1
+// some other may show up on Linux ( Syn (type 0) and Miscellaneous (type 4), but these are generally not very useful).
+// See if data is coming in:
+a.debug_( true );
+// Stop it:
+a.debug_( false );
+// Debugging can be turned on for each slot individually, if necessary:
+//(IBM trackpoint)
+a.slots[1].at( 272 ).debug_( true );
+// (external mouse on macbook pro)
+a.slots[3][1].debug_(true);
+(external mouse on ibm thinkpad)
+a.slots[2][1].debug_(true);
+// Turn it off again: // (IBM trackpoint)
+a.slots[1].at( 272 ).debug_( false );
+//(external mouse on macbook pro)
+a.slots[3][48].debug_(false);
+//(external mouse on ibm thinkpad)
+a.slots[3][1].debug_(false);
+
+// You can also create a generic gui to see what is coming in:
+a.makeGui;
+
+a.slots.keys
+a.slots[0]
+
+// The current value of a slot can be checked:
+a.slots[1].at( 272 ).value;