Why is this loop running if the flag is 0?

Questions about GP commands and how to do things

Moderator: MSandro

Post Reply
Posts: 70
Joined: Sep 15th, '15, 11:21

Why is this loop running if the flag is 0?

Post by mguzdial » Jul 20th, '16, 02:33

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?

Posts: 379
Joined: Sep 11th, '15, 14:42

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

Post by JohnM » Jul 24th, '16, 21:03

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...

Post Reply