Logo

ZLB



Posts Tagged ‘hint’

SC hint #4

Monday, December 28th, 2009

VCAs in SC : a question of summing. VCAs are usefull in order not to spend cpu cycles adjusting levels with a dedicated synth, but still keeping full range on your controlling faders, knobs, etc.

(~vca = 0;
w=FlowView.new;
g = EZSlider(	w,  	// parent
		390@20,	// bounds
		"The VCA ",	// label
		\db.asSpec, 	// controlSpec
		{|ez| ~vca = ez.value;i.value  = ~vca + h.value } // action
).value_(0);
h = EZSlider(	w,  	// parent
		390@20,	// bounds
		"The fader ",	// label
		\db.asSpec, 	// controlSpec
		{|ez| i.value  = ~vca + ez.value} // action
);
i = EZSlider(	w,  	// parent
		390@20,	// bounds
		"Result ",	// label
		\db.asSpec, 	// controlSpec
		{|ez| } // action
);
)

SC Hint #3 - Block - Break

Tuesday, December 22nd, 2009

if you need to break from the middle of a iteration, because let’s say you had an error and you shouldn’t continue, then you can use:

block{ |break| 10.do{ |i| if(i==5){ break.value(999) } } }

SC Hint #2 - get the Rect with the size of View

Friday, December 18th, 2009

If you have a view and you want to get a Rect with it’s width and height you can do:

Rect(0,0,view.bounds.width,view.bounds.height)

But it’s more compact to do:

view.bounds.extent.asRect

SC Hint #1 - reduce

Thursday, November 26th, 2009

A great way to apply a binary operator successively  to the elements of an array is to use reduce.

e.g.

[true,false,true].reduce('&&')
["This ","is ","a string."].reduce('++')

info_at_friendlyvirus.org
sales_at_friendlyvirus.org
www.myspace.com/friendlyvirus/