Page 1 of 1

Why is this loop running if the flag is 0?

Posted: Jul 20th, '16, 02:33
by mguzdial
I'm working on creating FFT and Sonogram views of sound as they're being recorded. I'm storing the current sound input in a shared variable soundseg, then adding all segments together (for later playback) and also creating a list of lists of segments (for a sonogram view). I have a separate instance continually watching for changes in soundseg to display an FFT view.

The below image captures one of the things I'm trying to understand. I want to keep recording while the shared variable "recording" is 1. The record loop is still running (as the highlight around the script suggests). The shared variable recording is 0. Why is the loop still running?
soundseg.png

Re: Why is this loop running if the flag is 0?

Posted: Jul 24th, '16, 21:03
by JohnM
I'm pretty sure this is a bug in "sound input". For some reason, the low-level sound input primitive sometimes stops getting samples and blocks forever. You can test this by dragging out another "sound input" block and and clicking it. Normally, this should show a thought-bubble with a bunch of numbers. When sound input has gotten stuck, it never returns -- the block stay highlighted showing that it's still waiting for sound samples, but you never get any.

This appears to be a bug in the Mac sound input library, not in GP. To fix this problem, I may need to add some sort of "watchdog timer" that notices when this happens and re-starts the sound input process.

In any case, its not a bug in your code. You can get out of this situation by saving your project, restarting GP, and reloading your project. It should start working -- until the next time the sound input gets stuck, of course...