View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide

pdef sequencer

Home   How To   Code Pool   Public Library   Theory   Events

(
var w, size, list, keys, specs, currentKey, updView, round, putVal, derive;
var thumbSize;
thumbSize = 10; 
round = 0.05;
keys = [\x, \y, \z];
specs = (x: \amp, y: \amp, z:\amp).collect { arg item; item.asSpec.step_(round) };
currentKey = keys.first;
size = 32;

keys.do { arg key;
	var pat;
	pat = Pdefn.at(key);
	if(pat.isNil or: { pat.pattern.respondsTo(\list).not }) 
	{ Pdefn(key, Pseq(0.0 ! size)) };
};
updView = { b.value = specs[currentKey].unmap(Pdefn(currentKey).pattern.list) };
putVal = { arg i, val; Pdefn(currentKey).pattern.list.put(i, specs[currentKey].map(val)) };

w = SCWindow("pdefn seq", Rect(10, 450, 360, 150));
w.view.decorator =  FlowLayout(w.view.bounds);
b = SCMultiSliderView(w, Rect(0, 0, size * (thumbSize + 1), 100))
	.action_({ arg b; putVal.(b.index, b.currentvalue) });
SCPopUpMenu(w, Rect(10,10, 110, 18)).items_(keys)
				.action_({ arg view; 
					currentKey = view.items[view.value].round(round);
					updView.value;
				});
SCButton(w, Rect(10,10, 110, 18))
	.states_( [["code", Color.black, Color.clear]])
	.action_({ Pdefn(currentKey).asCompileString.postln });
SCButton(w, Rect(10,10, 110, 18))
	.states_( [["throw", Color.black, Color.clear]])
	.action_({ putVal.(size.rand, 1.0.rand.round(round)); updView.value; });
	
updView.value;
//b.isFilled_(true);
b.valueThumbSize_(1.0);
b.indexThumbSize_(thumbSize);
b.gap_(1.0);

w.front;
)

(
SynthDef("help-sinegrain", 
	{ arg out=0, freq=440, dur=0.05, amp=0.1;
		var env;
		env = EnvGen.kr(Env.perc(0.01, dur, amp), doneAction:2);
		Out.ar(out, SinOsc.ar(freq, 0, env))
	}).store;
)

s.boot;

(
var a;
a = Pshuf({ rrand(300, 700.0) } ! 16, inf);
Pbind(
	\instrument, 'help-sinegrain',
	\freq, Ptuple(a ! 3),
	\dur, 0.125,
	\amp, Ptuple([
			Pn(Pdefn(\x), inf),
			Pn(Pdefn(\y), inf),
			Pn(Pdefn(\z), inf)
		])
).play
)



Link to this Page