[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [sc-users] routine that returns events problems
On Fri, Mar 15, 2019 at 11:02 PM <josh@xxxxxxxxxxxxxxxxx> wrote:
> I think you are confusing the James’s.
FWIW, since joining the lists in 2002 or '03, I've signed my posts
with my initials "hjh" so as *not* to be mistaken for James McCartney
:D
Adam:
> inval = <object>.embedInStream;
Almost. Really, you need this:
inval = someObject.embedInStream(inval);
Formally, it's required to pass the input value down to the child.
First, let's do it wrong.
(
r = Routine { |inval|
loop {
inval = (x: 10.rand).embedInStream;
}
};
)
r.next((a: 1));
-> ( 'x': 9 ) // NO, this is wrong -- where is 'a'?
Easy fix:
(
r = Routine { |inval|
loop {
// note '(inval)' argument -- IMPORTANT
inval = (x: 10.rand).embedInStream(inval);
}
};
)
r.next((a: 1));
-> ( 'x': 2, 'a': 1 ) // YES, that's right
I can't stress this enough. You must pass the input value down to the
child. You can skip this only if you're not using the inval at all
(which is kind of often). But when your pattern was losing the
NodeProxy's group and bus, then you need to take care not to throw
away the inval.
> (since it seems .embedInStream is a synonym for .yield?)
It's not exactly a synonym, but close. The baseline embedInStream
behavior comes from Object:
embedInStream { ^this.yield; }
But many classes (including almost every type of Pattern) override this.
The difference is that .yield outputs exactly one object, while
.embedInStream can act like a subroutine that yields multiple values
in succession.
hjh
_______________________________________________
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/