[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-users] Fill array with UGen output



On Sunday 28 December 2008 20:49:10 Schell wrote:
> Hi, I am wondering how to fill an array with the output of a control rate
> from a unit generator, possibly at pre-determined intervals [every 2nd, 3rd
> or 4th value]. Possibly a function that uses a ugen to return an array? I
> can't seem to achieve this on my own...


I made a little class for this, as below.

Usage:

b = Bus.control(s, 10);

c = BusWatcher.new( b, { |vals| ~myarray = vals }, 0.1 );

sincerely,
Marije

--------- save the rest as a separate file (BusWatcher.sc) and put in 
Extensions -------------


BusWatcher{
	var <bus;
	var <>updateFunc;
	var <watcher;
	var <dt = 0.1;
	
	*new{ |bus,updateFunc,dt|
		^super.new.init( bus, updateFunc,dt );
	}

	init{ |b,updFunc,dT|
		bus = b;
		dt = dT ? 0.1;
		updateFunc = updFunc ? {};
		watcher = SkipJack.new( 
			{ bus.getn( bus.numChannels, updateFunc ) }
			,dt
		);
	}

	dt_{ |d|
		dt = d;
		watcher.dt = dt;
	}

	start{
		watcher.start;
	}

	stop{
		watcher.stop;
	}

}

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/