how to import modules int custom python coded nodes
I'm writing a custom python coded node that would need to import pygame (https://github.com/pygame/pygame). This would enable me to output midi notes to a synth. Is this at all possible?
Thanks for any help in advance.
|?||Show this help|
|ESC||Blurs the current field|
|r||Focus the comment reply box|
|^ + ↩||Submit the comment|
You can use
Command ⌘ instead of
Control ^ on Mac
Support Staff 1 Posted by john on 06 Jan, 2023 10:51 PM
Sorry, but I'm out of my depth on this one.
In theory, I think you should be able to access python libraries using custom nodes. But there may be some issues. I found this exchange in the forum:
"NodeBox uses Jython, a version of Python 2.7 that runs on the JVM. So it doesn't look in the sys.path of Python 2 or 3."
You could try installing pygame on your machine and invoke it your .py file (import pygame). But if Nodebox doesn't see it, you'll get a "No module name pygame" error.
I also see that pygame is based on Python 3.6 and has some other dependencies as well. This may cause further issues.
If you do get it working on your system, be aware that it would not work for anyone else unless they also install pygame and do whatever additional voodoo required.
Could you use OSC instead of midi to output to your synth? That's probably a stupid question, but if somehow you could, you might try the send OSC node.
Wish I could be of more help. Adding Frederik to the list on the off chance he will have time to weigh in.
2 Posted by xtensor on 07 Jan, 2023 11:18 AM
Thank you very much for your reply. It's clarified things for me and was
I've been working on making so called 'parquet deformations' and nodebox 3
has made it possible, but without your invaluable Cartan Node Library I
couldn't have done it. So thank you for making them available to us.
I've included a couple of examples. I really wanted, out of interest, to
see if I could use some of the parameters to trigger some sound on my Mac
using an internal synth. This was just an idea on top, I've really
completed what I set out to do.
Many thanks again, I'll look into jython and OSC just for fun anyway.
Support Staff 3 Posted by john on 08 Jan, 2023 10:57 PM
Thanks for those kind words. Much appreciated.
I am also quite impressed by your parquet deformations - very Escher-like. It might be interesting to capture each enclosed area as a separate shape and play with coloring them.
I look forward to seeing more of your work!
4 Posted by xtensor on 09 Jan, 2023 11:45 AM
I'll post more work on the 'show your work' thread. And thank you for the
Cartan 3.1 Library you've just made available.