I recently implemented pitchshifting using the elasticx~ objects which I can’t distribute together with the rest of my code. In order to avoid maintaining two versions, I’d like to transparently instantiate the elastic object, and if that fails, use a common max object instead (such as wave~ or groove~).
Is there a way to do that ?
Unfortunately, newdefault() will allow me to create the object, I just didn’t find a way to test whether the object creation was successful or not. If the external doesn’t exist, an error message is posted to the Max window. But testing the object reference (which should be null) with "if (myobject)" or "if (myobject.valid)" doesn’t really work out and seems to report true in any case.
I did succeed using the File object and the isopen method. Still, not the preferred solution as I would have to make explicit checks for OSX and WIN, due to different filetypes for externals (mxe vs. mxo).
any idea how to programmatically test for successful object creation ?
just in case anyone is interested.
using newdefault() obviously always creates a valid max object, therefore valid returns true.
Whether creating the object was successful can be tested using the maxclass method of the object to be tested. If not successful, the call will return "jbogus" which can be tested for.
C74 RSS Feed | © Copyright Cycling '74