On Apr 21, 2009, at 9:13 PM, Hans Aberg wrote:
Is it possible to kill a thread by saving a reference and calling exit() (or something) on that reference? Are there any means by which a created thread can be manipulated from without it by its reference?
On a keyboard, I want a generator to be disconnected first some time after a key has been released - otherwise the sound will be truncated. How long depends on the generator, so I want to be able to set it arbitrarily. Then the problem is when the key is depressed again before this waiting time for disconnect has elapsed. One way to fix it is to let the thread check if the key has been depressed again, say by looking at the key down times, and if so, just skip the disconnect.
If I understand this correctly, I would use an envelope for that. So when the key is pressed the envelope fires up, and when the key is released, the oscillator will stop at the end of the envelope's release time. You may want to have a look at a chuck template for polyphony I wrote a year ago for a workshop. You'll find it at http://www.lullcec.org/chuck/template_polyphony.ck . At that time it was working, not sure now. Be aware that envelope's release time is set quite long (1::second). hope it helps, eduard