Dear all, This is a rather
technical question, so please let me know if I should better
post it in sc-dev. Right now I'm
developing a kr UGen that reads data in from a specific sensor
over an I2C bus. When this UGen is instantiated, there is code
in its constructor method that creates an I2C object which
establishes a connection to the I2C bus and configures
everything properly. And inside the deconstructor method there
is code that cleans up the I2C bus and then deletes the I2C
object. The UGen works fine
when synths are manually instantiated and freed, but encounters
some problems when using it inside an Ndef (nodeproxy). The problem as I can see it (from print statements) is that when I update the UGen graph of a running Ndef, the order of allocation/deallocation goes something like this: 1. UGens of the new
graph are instantiated (I get a "hello world" print statement
from my UGen's constructor) - however there is already an
existing I2C connection being managed by the already existing
UGen instance (BAD!) 2. UGens of the old graph are de-allocated (I get a "goodbye world" statement from my UGen's deconstructor) - the "clean up I2C bus" code is called by the old UGen while the new one has an active connection to the I2C bus that it is managing (ALSO BAD!)
Does anyone on the list have any suggestions for how to deal with this behavior? I would very much like to be able to use JitLIB in developing programs with this UGen... there must be some clever way to specify the order of allocation/deallocation? Or...? any thoughts are very welcome! best Jon
|