GenX subclasses not assigning properly (using @=>)
I've got this public class that goes like this: Phasor p => GenX g => env; with the assumption that I can just do a Gen9 gen @=> myObject.g; and have it all work out. However, this doesn't seem to be working. I do this: Gen9 gen; [1.0, 0.6, 0.3, 1.75, 0.1, 0.1] => gen.coefs; gen @=> s[i].g; and it gives me no sound, but if I change the GenX in the public class to Gen9 then it works. I've seen this work before with other things, so what am I doing wrong here? I'm not getting any compiler errors or warnings, either. I'm wondering if maybe it's calling some kind of earlier method, and not a more specific one. I've tried doing .lookup(int) on the Gen9 and it totally works, and when I do <<< s[i].g.toString() >>> it gives me "Gen9:1777af20" : (string). Sound just doesn't work though. Anyway, any help is appreciated here--I'm totally stuck on this one. Andrew
Andrew;
2010/2/8 Andrew C. Smith
I've got this public class that goes like this:
Phasor p => GenX g => env;
with the assumption that I can just do a Gen9 gen @=> myObject.g; and have it all work out. However, this doesn't seem to be working. I do this:
Gen9 gen; [1.0, 0.6, 0.3, 1.75, 0.1, 0.1] => gen.coefs; gen @=> s[i].g;
and it gives me no sound, but if I change the GenX in the public class to Gen9 then it works. I've seen this work before with other things, so what am I doing wrong here? I'm not getting any compiler errors or warnings, either.
I'm actually a bit surprised that it would work when changing the GenX to Gen9. As I understand the current situation assigning to a existing UGen will drop the reference count of the UGen being assigned to, kicking in the sort of GC for UGens which will disconnect it from the graph. Then new UGen will have the same reference in the same namespace but *not* the same connections in the graph, you'd need to connect it manually to have sound. I'm not sure about the exact types of the Gen UGens but off hand I would have expected a need for some casting here. I think that's what's going on; that would explain why you get no sound and no warnings either. I don't feel the current system should be the desired behaviour, to me assignment to UGens should "hot-swap" the two, maintaining the same links in the UGen graph, in addition to any links the UGen being swapped in may have. For a long time I've been thinking that we should have two member functions for all UGens; UGen[] .connectsTo() UGen[] .connectsFrom() These two should return a array of UGen references each, allowing us to write our own "hotswap" scripts like we want it to be. I haven't yet send my proposal (I have a draft somewhere) because there are a few complications. We could for example call fun void traverse( UGen foo) { for (int i; i< foo.connectsFrom().cap(); i++) { //do something with these UGens ......... ......... .......... traverse( foo.connectsFrom()[i]); }} traverse(dac); and so recursively traverse the whole UGen graph for the whole VM. Right now we don't have the tools to do much useful stuff with the results as we can't poll UGens for their type or name. We'd need some good ideas there. I do think that this would fly with regard to how the VM works, there would be no need to restart any shreds and lose data as the UGen graph is quite independent from shreds. This would allow us to pull stunts like put a lpf after all LiSa UGens in the whole vm without restarting anything. All of the data needed to do this is there, I think the capabilities are there, we just don't have the functions. This would obviously also lead to prime opportunities to cause crashes and dropped shreds but then we can do much of this already with public UGens and maintaining the required data manually; you could still easily crash it all with a wrong cast somewhere, this way it would just be easier. Yours, Kas.
Kas, Thanks for the help here. I think I get it, that the basic problem here is that the swapped UGens don't retain their connections. I see where the problem is for livecoding, too, although I'm just wanting to make classes that can be used for more than one thing. I think the solution (for me) will be to just subclass my GenX class to replace g with a Gen9. That way I can set it up with minimal code at the top of my program, while allowing more flexibility with a single public class. Thanks again, Andrew On Feb 8, 2010, at 9:00 AM, Kassen wrote:
Andrew;
2010/2/8 Andrew C. Smith
I've got this public class that goes like this: Phasor p => GenX g => env;
with the assumption that I can just do a Gen9 gen @=> myObject.g; and have it all work out. However, this doesn't seem to be working. I do this:
Gen9 gen; [1.0, 0.6, 0.3, 1.75, 0.1, 0.1] => gen.coefs; gen @=> s[i].g;
and it gives me no sound, but if I change the GenX in the public class to Gen9 then it works. I've seen this work before with other things, so what am I doing wrong here? I'm not getting any compiler errors or warnings, either.
I'm actually a bit surprised that it would work when changing the GenX to Gen9. As I understand the current situation assigning to a existing UGen will drop the reference count of the UGen being assigned to, kicking in the sort of GC for UGens which will disconnect it from the graph. Then new UGen will have the same reference in the same namespace but *not* the same connections in the graph, you'd need to connect it manually to have sound. I'm not sure about the exact types of the Gen UGens but off hand I would have expected a need for some casting here.
I think that's what's going on; that would explain why you get no sound and no warnings either. I don't feel the current system should be the desired behaviour, to me assignment to UGens should "hot-swap" the two, maintaining the same links in the UGen graph, in addition to any links the UGen being swapped in may have.
For a long time I've been thinking that we should have two member functions for all UGens; UGen[] .connectsTo() UGen[] .connectsFrom()
These two should return a array of UGen references each, allowing us to write our own "hotswap" scripts like we want it to be. I haven't yet send my proposal (I have a draft somewhere) because there are a few complications. We could for example call fun void traverse( UGen foo) { for (int i; i< foo.connectsFrom().cap(); i++) { //do something with these UGens ......... ......... .......... traverse( foo.connectsFrom()[i]); }}
traverse(dac);
and so recursively traverse the whole UGen graph for the whole VM. Right now we don't have the tools to do much useful stuff with the results as we can't poll UGens for their type or name. We'd need some good ideas there.
I do think that this would fly with regard to how the VM works, there would be no need to restart any shreds and lose data as the UGen graph is quite independent from shreds. This would allow us to pull stunts like put a lpf after all LiSa UGens in the whole vm without restarting anything. All of the data needed to do this is there, I think the capabilities are there, we just don't have the functions.
This would obviously also lead to prime opportunities to cause crashes and dropped shreds but then we can do much of this already with public UGens and maintaining the required data manually; you could still easily crash it all with a wrong cast somewhere, this way it would just be easier.
Yours, Kas. _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
Andrew; Thanks for the help here. I think I get it, that the basic problem here is
that the swapped UGens don't retain their connections.
Yes. And I feel that's counter-intuitive. When I'd say "I'm assigning Mike to Tom's spot" and Tom would have been charged with tending the fire I'd then expect Mike to tend the fire from there on. As it is assignment as it relates to UGens has some of the expected effects (like disconnecting UGens without references) and lacks others that I feel should be logical, without options to remedy this easily without extensive planning ahead.
I see where the problem is for livecoding, too, although I'm just wanting to make classes that can be used for more than one thing.
IMHO there is a strong correlation between the two. Versatile, powerful and easy to grasp UGens should be good for education, for composition, for DIY instruments and for livecoding. All of those areas have their own specific demands but I feel this issue can be linked to all of those. I still feel that the link between the UGen graph and the code could be extended.
I think the solution (for me) will be to just subclass my GenX class to replace g with a Gen9. That way I can set it up with minimal code at the top of my program, while allowing more flexibility with a single public class. Thanks again,
Happy to have been helpful, Kas.
participants (2)
-
Andrew C. Smith
-
Kassen