Unique composition ID, current filename OR: how to limit the scope of Spooky Send & Receive

mc's picture

I make extensive use of the awesome Spooky Send-Receive plugins to share data across patches. But as these data are global to one runtime environment (like Quartz Composer Editor), i cannot simply put spookies in macros and use them as virtual plugin in other compositions, if data should only be shared among one singular composition. In order to automatically limit the scope of a spooky pair by setting its channel to a unique string, i tried to figure out, how to get a unique id of the current composition. First, I checked all available info patches, but none provides any information that would serve as a unique ID. I hoped to determine the filename of the current composition (at least), but unfortunately Kineme Document Info only provide the name of first loaded patch in Quartz Composer and not the current one. This all may sound a bit abstract, but three simple questions result from my target practice of working as most modular and transparently as possible with QC:

  1. How to get the filename of the current composition?

  2. How to get a unique Id of the running composition, if instantiated several times from the same .qtz file in a runtime environment different from Quartz Composer Editor?

  3. How to limit the scope of Spooky Send & Receive to the currently running patch?

This last question may have an obvious solution by simply modifying the (pretty tiny) source code of Spooky Send & Receive, recently made available at github. Maybe someone familiar with objective C would want to compile a 'localized' Spooky version that automatically limits the scope of a channel to the currently running composition.

I guess, this would be helpful to a lot of other people and different problems, too.

Thanks in advance for comments and help, mc

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

gtoledo3's picture
Re: Unique composition ID, current filename OR: how to limit ...

I think the use concept is to just use different sender and receiver channels? Is there a reason that can't solve it?

gtoledo3's picture
Re: Unique composition ID, current filename OR: how to limit ...

Edit is still broken... I mean "multiple" by different.

gtoledo3's picture
Re: Unique composition ID, current filename OR: how to limit ...

Err, yeah, edit is broken, sorry if that's n/a. I think you can adjust the way you want to use it, but when you talk about initializing the same composition multiple times and wanting different sender/receivers, I don't know if you can work around that need.

mc's picture
mc

Thanks for the quick comment!

If diffrent, multiple of whatsoever, any other channel needs another string to specify it. So if i could only get a unique string per composition, i could easily set the spooky channel by that string and have the problem solved, no?

So is there not a unique Id for each composition anyway somewhere in the quartz API that, like possible the filename, could just be grabbed by the SkankySDK and made available through a super simple info plugin, possibly called either 'UniqueID' or 'Current Filename'?

usefuldesign.au's picture
Re: Unique composition ID, current filename OR: how to limit ...

There's a much easier way than building a plug-in. This is what I have used in a multi-composition context where I wanted to be able to dynamically assign which compositions to were broadcasting and receiving on which of my channels (not to be confused with Kineme Spooky Send/Received channels which enable my protocol by operating underneath it). I won't go into explaining all that since all you need it the first bit of my method:

Sample and hold the system time at start-up (there's virtually zero possibility that two comps start-up with the system time sampled). Concatenate the system time with your own string, say "mc.com" and send this string to your Spooky Receive patch's 'Channel' input. (You can even send it via another spooky channel and include it all in the macro so it 'just works' black box like). At the same time send the string to your Spooky Send patch's 'Channel' input.

You need to send the unique string just once at start-up and then latch onto it, so other comps that start-up don't pass their string to other compositions.

Hope that's clear. I also considered trying to use the command line patch or Dust's Applescript Plugin to somehow poll comp info, but this seemed more in-house and direct to my skill set/way of seeing.

usefuldesign.au's picture
Re: Unique composition ID, current filename OR: how to limit ...

compositions to were broadcasting and receiving ->

compositions were broadcasting and receiving

franz's picture
Re: Unique composition ID, current filename OR: how to limit ...

smart workaround !

mc's picture
Re: Unique composition ID, current filename OR: how to limit ...

Yes, many thanx!, time is indeed a unique identifier if sampled and hold. Only the resulting ID is a bit long and if used as a key to frequent OSC messages, the OSC-path takes up an unproportional amount of bytes compared to the actual message content.

So, as we need to "latch onto" our ID created by the above method anyway, why not simply abusing any non-Auto-Clead Spooky channel as a global storage to count up a global number at startup of each patch? The resulting ID is smart and short: a unique index.

I've put the typical use of this method (at least as far i understood it) together in a bunch of macros to realise a localised or 'this-composition-only' Spooky below. There is also a simple test/demo patch for quick examination by people.

<>

However, there a some shortcomings of this method, especially in the way the UniqueID (uID) has to be sent around to sub-patches, macros -- and most severe -- to macros used inside of iterators, or even iterators of iterators. Since you can't use an already localised channel to send your ID around, all localised receivers need to get initialised at startup. But if these receiving patches are not executed at startup (like macros in iterators) what are you going to do???

All in all, the nice workaround proposed above is far from a general solution and introduces a lot of extra 'patchwork' -- not necessary, if we only had a localised Spooky version as a plugin.

I would dig into this, if i only had time enough to learn objective-C right now.

p.s., i send this the second time. The first was notified but somehow did not come through to display as html here on the forum. Maybe i hit the wrong reply button?

PreviewAttachmentSize
uniqueID&localisedSpooky.zip30.39 KB

usefuldesign.au's picture
Re: Unique composition ID, current filename OR: how to limit ...

Quote:
So, as we need to "latch onto" our ID created by the above method anyway, why not simply abusing any non-Auto-Clead Spooky channel as a global storage to count up a global number at startup of each patch? The resulting ID is smart and short: a unique index.
Sounds smart to me! [quote] to macros used inside of iterators, or even iterators of iterators. Since you can't use an already localised channel to send your ID around, all localised receivers need to get initialised at startup. But if these receiving patches are not executed at startup (like macros in iterators) what are you going to do???[quote] Could you either publish the channel name up to root, or at least to get them out of the iterator patch(es) where they patch to a Spooky receiver for channel ID, or you could trigger the initialisation more than once (manually or set to a timer where each timer so each broadcast is unique, say: (patchtime_in_seconds + ch_ID) % global_channel_counter==0) ) Yeah, or learn Obj-C — it can't be that hard ;-)

Once a channel_ID has been sent to a Spooky Receive patch, if the Receive patch has a downstream patch executing all the time, the value should be available from that time onwards, whenever the iterator or whatever else wants to use the channel_ID it will be there ready and waiting. To force evaluation of the Spooky Receive patch, join one of it's output port to the Enable port of an iterator, this is a cheap way to force execution of upstream patch that is useful in many contexts.

mc's picture
Re: Unique composition ID, current filename OR: how to limit ...

Thanks for coming back on this once more. Nice modulo trick, too!

For now, things work for me as demonstrated by the attachment above. Nonetheless, these all stay inconvenient workarounds. The only straightforward solution will finally be a plugin. I may cross that bridge when time comes to it ;-).

usefuldesign.au's picture
Re: Unique composition ID, current filename OR: how to limit ...

Why not ask the nice folks at Kineme to mod the plugin for you with a local scope boolean input port? You can commission Kineme to work on a plugin at very reasonable rates and they have great familiarity with the Spooky plugin so will know what is involved to make your modification.

Yes work-arounds have their own costs in inconvenience…