maybites / NodeOSC

blender OSC addon to be used with nodes
GNU General Public License v3.0
123 stars 18 forks source link

AN osc input to listen all incoming messages #24

Closed dewiweb closed 2 years ago

dewiweb commented 2 years ago

Hello, Is there a way to listen to all incoming messages (without handlers filtering) and to output received address+args from the osc input node? Regards (and many thanks for this addon).

maybites commented 2 years ago

So I understand right: A kind of pass-through for osc messages?

dewiweb commented 2 years ago

Yes, to use incoming messages as variable for scripts in AN.

dewiweb commented 2 years ago

Maybe It could be clearest if I explain my final needs:

So if an incoming message's address contain unmatched track's number with any object's name in existing blender's scene--> blender create a new object(icosphere by default) and set is name as "icosphere.(number of track)". Else blender update matching object's properties accordingly to incoming messages.

So clearly I need to filter incoming osc messages by script before pythonosc dispatcher.

I hope this explanation is understandable...and you'll be able to help me. Regards;

dewiweb commented 2 years ago

I've found a workaround with two "Expression" AN and NodeOSC in debug mode. I've putted "lastaddr" and "lastpayload" datapaths in each of them and now I'm able to use these values in a py script. I now it isn't really clean but it seems to work (in localhost for now).

dewiweb commented 2 years ago

After tests(on lan) with this workaround, it appears that "lastaddr" and "lastpayload" don't return all incoming messages queued if incoming messages are sended at high frequency. Is nodeOSC dropping or queueing messages overflowing?

maybites commented 2 years ago

NodeOSC is in my opinion not suitable for your problem, at least not in its current architecture...

dewiweb commented 2 years ago

I'm agree with you but step by step, I'm able to receive incoming message, create objects,name them,set their locations, set their colors according to incoming OSC data. I've also made a py script to generate OSC config file based on existing objects(to control x,y,and z coordinates) and importable in your addon. So, it is imperfect for my needs but there's not really alternative apart completely rewrite an addon from scratch.... Thanks for replies.

maybites commented 2 years ago

I could implement the following:

inside the datapath field you could enter the following:

script.custom_callback.py

where 'script' is the name of the internal text datablock and 'custom_callback' the name of the function to be called.

where the structure of the function would be:

# address is the received address string
# args is the received args tuple
def custom_callback(address, args):
   print(address)
   print(args)

though I am not sure yet how to script inside my addon to load the text datablock. The best example I have found is this:

https://blender.stackexchange.com/questions/190404/how-do-i-run-a-function-from-a-custom-script-from-the-python-console

when the server is started, and there is a string that ends with .py inside the datapath field, it will call the custom function.

dewiweb commented 2 years ago

Maybe this can be relevant : https://blender.stackexchange.com/questions/260599/how-to-use-an-internal-text-file-in-an-add-on

dewiweb commented 2 years ago

I've made some progress: https://github.com/maybites/blender.NodeOSC/issues/23#issuecomment-1304466361