[chuck-users] Intraspection - an example of what I'm attempting

Andrew Turley aturley at acm.org
Mon Nov 8 14:24:46 EST 2010


On Mon, Nov 8, 2010 at 11:07 AM, Kassen <signal.automatique at gmail.com> wrote:
> On 8 November 2010 19:35, Rich Caloggero <rjc at mit.edu> wrote:
>>
>> Thanx Andy. I was worried that this would be the case; getting too used to
>> Javascript where anything is possible.
>> Will the casting work for any UGen type? I.e. since most (all) UGens
>> support mix, then can I just pretend that everything in the array is one
>> type (say Chorus for instance) and then use that type's mix?
>>
>
> Yes. If all of the UGens that you use there support .mix() you can cast to
> any one type of UGen that has .mix() and use it.
> The one downside to this is that you are removing the safety that the parser
> gives in type-checking so if somehow some UGen that lacks .mix() ends up in
> your array you'll crash the VM. With STKInstrument and it's sub-classes this
> works quite well, with members like .noteOn() being shared so there it's
> quite safe if done properly. Sadly we lack a "Effect" class that all effects
> like Churus could extend and that would provide extra safety and convenience
> in your case.
> Hope that helps,
> Kas.

Kas,

I'm not sure that's true. I just tried this:

// BEGIN CODE
SinOsc s => Chorus chorus => JCRev reverb => dac;
880.0 => s.freq;
.2 => s.gain;
UGen @ ug[0];
ug << chorus;
ug << reverb;
0.0 => (ug[1] $ Chorus).mix;

while (true) {
1::second => now;
} // main loop
// END CODE

and I got the following:

chuck_instr.cpp:4530: failed assertion `m_offset < obj->vtable->funcs.size()'
Abort trap

The "mix" method won't have a common location in the vtable. You might
get lucky casting a JCRev to a PitShift since "mix" is the first
method for both of them, but I certainly wouldn't count on that to
always work.

andy


More information about the chuck-users mailing list