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

Re: [sc-users] Re: Pattern



Hi Bad Numbers,

Pfunc in the example below creates a stream of patterns (defined by Pn (..) ) not a stream of values.  
To get a stream of values, you need to tell the pattern to "act like a stream", with the embedInStream message.
However embedInStream can only be called within streams implemented as Routines.  
So, you have to use Prout instead of Pfunc.

Here is an example:

Pbind(*[
	degree: Prout({ Pseq((1..10)).embedInStream })
]).play

and here is a more elaborate example that takes advantage of the routine to define changing 'state' in the pattern:
Pbind(*[
	degree: Prout({
		loop {  
			[
				Pseq((1..4),2),
				Pseq(((1..4) ++ \r.dup(2)).scramble),	
				Pseq(((1..4) ++ \r.dup(4)).scramble),	
				Pseq(((1..4) ++ \r.dup(16)).scramble),	
				Pseq(((1..4) ++ \r.dup(4)).scramble),	
				Pseq(((1..4) ++ \r.dup(2)).scramble),	
			].do(_.embedInStream)
		} 
	}),
	dur: 0.2,
]).play

Cheers,

RJK

PS: 
TMI department (answering the question why can embedInStream only be called from a Routine?): 

1. This avoids getting nested Routine creations when the embedding gets recursive.  Otherwise, it 
ends up hammering the garbage collector with a  whole bunch of process contexts to clean up.

2. The sampled function of time patterns, Pseg and Pstep, stash their timing information in the 
context block of the routine.  So, they would not be available without this stipulation.


> On Dec 23, 2016, at 2:13 AM, Bad Numbers <badnumbersmusic@xxxxxxxxx> wrote:
> 
> Patterns are fixed once they're created. Sometimes you can get around this by
> wrapping them in Pfunc, which will force evaluation every time an event is
> demanded:
> 
> \degree, Pfunc({Pn(Pseries(0,1,~c),inf)})
> 
> But in this case (I don't have Supercollider to hand), I expect what will
> happen is that the Pseries pattern will be instantiated anew every time, and
> therefore output an endless series of 1s.
> 
> This *might* work, but like I said I can't test it right now:
> 
> \counter, Pseries(0,1,inf),
> \degree, Pfunc({|e| if (e.counter > ~c, nil, e.counter)})
> 
> 
> 
> --
> View this message in context: http://new-supercollider-mailing-lists-forums-use-these.2681727.n2.nabble.com/Pattern-tp7629661p7629693.html
> Sent from the SuperCollider Users New (Use this!!!!) mailing list archive at Nabble.com.
> 
> _______________________________________________
> sc-users mailing list
> 
> info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
> archive: https://listarc.bham.ac.uk/marchives/sc-users/
> search: https://listarc.bham.ac.uk/lists/sc-users/search/


_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/