how to import modules int custom python coded nodes

Michael Hobbs's Avatar

Michael Hobbs

06 Jan, 2023 01:07 PM

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.

  1. Support Staff 1 Posted by john on 06 Jan, 2023 10:51 PM

    john's Avatar

    Michael,

    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:

    http://support.nodebox.net/discussions/general-discussion/14716-pan...

    "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.

    John

  2. 2 Posted by michael hobbs on 07 Jan, 2023 11:18 AM

    michael hobbs's Avatar

    Hi John

    Thank you very much for your reply. It's clarified things for me and was
    helpful.

    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.

    Best wishes
    Michael

  3. Support Staff 3 Posted by john on 08 Jan, 2023 10:57 PM

    john's Avatar

    Michael,

    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!

    John

  4. 4 Posted by michael hobbs on 09 Jan, 2023 11:45 AM

    michael hobbs's Avatar

    Thanks John

    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.

    Best wishes
    Michael

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

31 Jan, 2023 11:29 PM
28 Jan, 2023 10:39 AM
26 Jan, 2023 01:30 AM
26 Jan, 2023 01:24 AM
26 Jan, 2023 12:48 AM

 

20 Jan, 2023 02:32 PM
13 Jan, 2023 09:54 PM
11 Jan, 2023 10:32 AM
09 Jan, 2023 11:45 AM
28 Dec, 2022 11:19 PM
27 Dec, 2022 06:57 AM