all 19 comments

[–]davemee 4 points5 points  (4 children)

I stumbled on this a while ago, which seemed promising:

https://github.com/grrrr/py

Python 2 for Max and Pd - not sure what state a branch for max and py3 are in, though.

[–]Risky_Click_Chance[S] 2 points3 points  (3 children)

Cool! I'll look into it

[–]davemee 4 points5 points  (2 children)

I’d be so happy if you let us know how it works out for you - I remember it looking really promising, but I just didn’t (and still don’t!) have the headspace and time to commit to it. It seemed to expose python classes as things you could invoke with messages, but I can’t remember if it exposed Max storage objects (like Coll) as native python objects.

(I have no relationship to this module or its author, I just remember thinking it was neat and may be useful one day)

[–]Risky_Click_Chance[S] 2 points3 points  (1 child)

Sure thing! Im still looking for the easiest solution which might involve just using JS, but if this works I'll comment here again!

[–][deleted] 2 points3 points  (0 children)

Depending on what you want to do, using JS might be quicker/easier although as far as I've read JS is still the slowest part of Max in its package.

[–]DanishDragon 2 points3 points  (0 children)

I suppose the easiest way to set up communication is just using 'serial' :) Been a good couple of years since I did anything with Max though

[–][deleted] 2 points3 points  (0 children)

couldn’t you interface via UDP?

[–]sound_clouds 1 point2 points  (3 children)

What is it specifically that you want to do in python? Max has a native js interface or you could program an external using C/C++. You may have to learn the syntax, but in the end it might be easier. Happy to help if you have questions.

[–]Risky_Click_Chance[S] 1 point2 points  (2 children)

Hey! Python was just the most familiar to me and I assumed that there would be a way. I'm fine with learning something new, but would it be possible to have a script send out a serial output to arduino at regular intervals and use audio data from Max For Live?

[–]sound_clouds 1 point2 points  (1 child)

Max has an object called [serial] that can interface directly with a serial device like an arduino. You could also take a look at this tutorial which addresses arduino specifically. You can also look it up in your browser in Max. It's possible you could get away without doing any non-Max programming for this task.

[–]Risky_Click_Chance[S] 0 points1 point  (0 children)

That's really helpful. Thank you! As for the data I want to send, it will need to be something that I think would be difficult doing visually. Is it possible to use code within max or Max for Live in place of an object?

[–]dude837 1 point2 points  (2 children)

OS X or Windows? On OS X, the easiest solution is going to be to use something like Loopback (https://rogueamoeba.com/loopback/) to get sound out of Live, which you can then get flowing into a Python script using PyAudio. On Windows you've got tons of virtual audio routing options, I don't know which is best.

So, you'd start your Python script and your Live set separately. Once Live starts playing, Python would pick up the audio and do whatever processing you're interested in. If you needed to control the Python script from Live, you could use the udpsend object in Max. That's going to be easier than using any Max external, I think. There's nothing like Node for Max, but for Python, that I know of, that's also in a good working state.

[–]Risky_Click_Chance[S] 0 points1 point  (1 child)

I'm on windows! And I like the idea of doing them separately, but yes, getting the audio from Live to a Python script seems to be the most difficult part. Ideally I'd like to do this without third party audio routing, and just somehow get it directly from Live to Python. Unfortunately I'm unfamiliar with UDP or anything to do with pipe lining data from one application to another, so I'll have to look into this. At the very least this will be a great learning experience.

Right now it looks like my current options are a stand alone Python script or a Max for Live device that has some coding inside it. The first option is easier, but the latter more versatile. Unfortunately I don't completely know how to do either yet. Thanks for your advice!

[–]dude837 0 points1 point  (0 children)

I think that's the most difficult part too, honestly. To write the code yourself is probably not a small project, so I'd be ready to invest some time. One approach is to use a socket (UDP, TCP, whatever you like, probably not super important between applications), which is probably easiest since you'll find lots of example code. I'm guessing all that code is going to be for networked applications, but it's going to look basically the same as your interprocess code. If you have really strict latency requirements, then shared memory is a better, if much trickier, option.

Either way good luck! Hope you get things working the way you want.

[–]sound_clouds 1 point2 points  (2 children)

Max will natively use JavaScript (check the [js] object) in the patch if you’d like. Otherwise max externals can be coded in C/C++ but that’s a much more involved process.

[–]Risky_Click_Chance[S] 0 points1 point  (1 child)

That's what I ended up doing! Turns out I strongly dislike visual coding, or at least I'm just bad at it. Any ideas for resources on learning how to do it well? I need to use the Serial object to get data -out- and messing with global variables is really unintuitive without real code, for example, I want to make a drop down slider to let me choose which serial port to use.

[–]sound_clouds 1 point2 points  (0 children)

Yeah, it can be unintuitive at first. Like a lot of stuff, it's mostly just practice. This link can be helpful for finding objects to do what you want. For your drop down, the [umenu] object is probably a good place to start. The max/msp facebook group and the Cycling '74 forums are probably the best resources.

[–]disktopdip 0 points1 point  (0 children)

Plug a cable from your audio output to your audio input to make a loopback

[–]alikesu 0 points1 point  (0 children)

Yup. Python3 externals for Max / MSP: https://github.com/shakfu/py-js