[chuck-users] a little debugging help for frozen VM!

Kassen signal.automatique at gmail.com
Fri May 25 15:57:11 EDT 2012


On Fri, May 25, 2012 at 12:32:35PM -0700, [chriswicks] wrote:
> Hey, all.  I'm attempting to build something that shifts layers of ChucK files based on OSC events, and I hit a snag really early on.  I'm a relatively new programmer, so hopefully this isn't too stupid of a question,

That one I could answer before considering the code; if you looked
yourself and considered the docs (which I'm sure you did) then there
are no stupid questions. Great, having established that, let's look at
the next issue;



> but I've got an issue that freezes the virtual machine and doesn't play any sound or send any OSC events.  Nothing happens..the VM shows that the shreds are added, and then it just freezes and I have to force quit...it won't take a --removeall or --kill command or anything.  Individually, each file works as it should, aside from the file whose code I am including here.  I think I may be missing a key concept as to the way Machine.add works and how it assigns the value of the shred to an int, but I'm just not sure.  If anyone can give me some direction here as to what might be happening I'd appreciate it!  I've tried advancing time in various places, setting my initial pedCount to various values, all to no avail.  Thanks very much,
>  and please let me know if this is unclear in any way.

Yes, I see. When this happens it most of the time means that you have
a infinite loop that doesn't advance time. That turns out to be the
case here, but it is a bit hard to see because yours is a quite
involved loop that does advance time, but only under some conditions.
Particularly; only when pedEvent.nextMsg() equals zero. When this
happens the shred will keep racing through the loop, without yielding
the cpu to other shreds. When this happens and nothing changes the
parameters tested for it will never get out of that state.

I expect you'll see a improvement in your code's behaviour by simply
adding "second => now;" as the last like of the "while(true)" loop.

I suspect that after that more improvements could be made because
quite likely your intention will be to go through the loop every time
OSC messages arrive to change the sitiation. In that case it would be
better to "chucK' that OSC event to now, instead of a rbitrary amount
of time like a second. That way you guarantee that you'll go thorugh
the loop when -and only when- such a message arrives. This is
explained in more detail in the documentation in the section on
events.

Best of luck; looks like a ambitious structure for a "new programmer"
which is of course the best way to get rid of the "new" clause :-).

Yours,
Kas.


More information about the chuck-users mailing list