Math Coding for M4L

Learn about building and using Max for Live devices.
Post Reply
Statwerk
Posts: 63
Joined: Mon Aug 11, 2014 9:44 am

Math Coding for M4L

Post by Statwerk » Fri May 15, 2015 12:25 am

I am just beginning my journey towards developing VSTs for Ableton.

Many, if not most of my ideas rely heavily on relatively complex mathematics.

I know that many VSTs are programmed in C++ and that is where I had planned to start.

M4L has a large number of canned elements that would be most helpful for me.

I understand that M4L can integrate with Javascript, can it do so with C++? Or as crazy as it might sound, would it be feasible to use Javascript as an intermediary to send information and commands back and forth between C++ and M4L?

I really don't know anything about C++, Javascript or M4L at this point.

Just trying to figure out the best place to start 'eating the elephant'.

I do have subscriptions to the latest version of Max (7.1, I believe), and MS Visual Studio Online.

Any suggestions would be most helpful.

Thanks!

Statwerk
Posts: 63
Joined: Mon Aug 11, 2014 9:44 am

Re: Math Coding for M4L

Post by Statwerk » Fri May 15, 2015 12:43 am

Note: While I am new to C++, Max and Javascript, I am an extremely proficient SAS Programmer. I would use SAS, if it were not $15k per person per year :s. Now trying to backpedal and learn more common languages.

dataf1ow
Posts: 230
Joined: Wed Oct 08, 2008 4:28 pm

Re: Math Coding for M4L

Post by dataf1ow » Fri May 15, 2015 12:46 am

Statwerk wrote:I am just beginning my journey towards developing VSTs for Ableton.
VSTs or M4L devices? Two totally different things.
Statwerk wrote: I understand that M4L can integrate with Javascript, can it do so with C++? Or as crazy as it might sound, would it be feasible to use Javascript as an intermediary to send information and commands back and forth between C++ and M4L?
You can code externals (custom Max objects) in C++ which can be used within Max/M4L. You don't want to use javascript for anything audio related or timing sensitive. It runs in the low priority thread and isn't suitable for DSP tasks.
Statwerk wrote: I really don't know anything about C++, Javascript or M4L at this point.
better study up then :wink: there's a lot to learn.

Statwerk
Posts: 63
Joined: Mon Aug 11, 2014 9:44 am

Re: Math Coding for M4L

Post by Statwerk » Fri May 15, 2015 12:57 am

Excellent!

I do have quite the the learning curve ahead of me.

I am envisioning what I call VSTs, but I may not be using the appropriate definition.

I am envisioning a fully featured software program that has 'modules' that can be placed on individual tracks in Ableton. They would use M4L as a convenient way to send & receive information to and from Ableton. Ultimately it would need to be a C++ program that had M4L elements embedded rather than the reverse because there are a lot of sophisticated algorithms running in the background which require a robust, fully featured compiler to develop.

I should come up with a new name, though. VSTs as such are designed to run in many DAWs. My plans are Ableton specific. Maybe call them 'AVST'?

dataf1ow
Posts: 230
Joined: Wed Oct 08, 2008 4:28 pm

Re: Math Coding for M4L

Post by dataf1ow » Fri May 15, 2015 1:19 am

What you are talking about are not VSTs. It seems to me you want to code externals using C++ (due to your sophisticated algorithms) and house those with M4L devices which can communicate with each other. VST's don't talk to each other usually. They just process audio signals.

You wouldn't code a C++ program that had M4L elements in it, it just doesn't work like that. I doubt C74 would want you to embed their commercial software within your C++ programs.

Statwerk
Posts: 63
Joined: Mon Aug 11, 2014 9:44 am

Re: Math Coding for M4L

Post by Statwerk » Fri May 15, 2015 1:25 am

Sounds good. Thanks!

stringtapper
Posts: 6302
Joined: Sat Aug 28, 2004 6:21 pm

Re: Math Coding for M4L

Post by stringtapper » Fri May 15, 2015 3:14 pm

dataf1ow wrote:You can code externals (custom Max objects) in C++ which can be used within Max/M4L.
Unless something's changed that I missed, Max externals are coded in C, not C++. (A discussion about it here: Cycle74 support for Max External C++ API?)

That said, Gen has the code export feature which does create C++ code from what you've patched in the Gen object. That could possibly be a way in to at least creating the DSP parts of VSTs (if that's in fact what you're trying to do).

Other than that Gen is also a great way to essentially code something like an external without dealing with programming in C. You can do some powerful DSP with [gen~].
Unsound Designer

dataf1ow
Posts: 230
Joined: Wed Oct 08, 2008 4:28 pm

Re: Math Coding for M4L

Post by dataf1ow » Fri May 15, 2015 3:20 pm

stringtapper wrote:
dataf1ow wrote:You can code externals (custom Max objects) in C++ which can be used within Max/M4L.
Unless something's changed that I missed, Max externals are coded in C, not C++. (A discussion about it here: Cycle74 support for Max External C++ API?)
Yeah you're right. Although I think my points are still valid, regardless of the amount of plusses following the 'C'.

stringtapper
Posts: 6302
Joined: Sat Aug 28, 2004 6:21 pm

Re: Math Coding for M4L

Post by stringtapper » Fri May 15, 2015 4:16 pm

dataf1ow wrote:
stringtapper wrote:
dataf1ow wrote:You can code externals (custom Max objects) in C++ which can be used within Max/M4L.
Unless something's changed that I missed, Max externals are coded in C, not C++. (A discussion about it here: Cycle74 support for Max External C++ API?)
Yeah you're right. Although I think my points are still valid, regardless of the amount of plusses following the 'C'.
Just clearing up details. Never said anything about your points.
Unsound Designer

dataf1ow
Posts: 230
Joined: Wed Oct 08, 2008 4:28 pm

Re: Math Coding for M4L

Post by dataf1ow » Fri May 15, 2015 4:22 pm

And I do appreciate it! I'm not entirely clear on the finer points of developing externals.
I didn't mean to come off as unappreciative.

stringtapper
Posts: 6302
Joined: Sat Aug 28, 2004 6:21 pm

Re: Math Coding for M4L

Post by stringtapper » Fri May 15, 2015 4:35 pm

Nah it's all good. :)

I do think that Gen is a very good possibility for sidestepping the lower-level coding to create some serious DSP inside of a M4L device.

I took a class on delay-based signal processing using Gen a couple of years ago and it was a real eye opener. If you want to get into making filters and other effects with Gen this document that the professor gave us is a great start:

https://dl.dropboxusercontent.com/u/104 ... agrams.pdf

You can recreate those diagrams in Gen and it's very intuitive to do if you know what the symbols mean and how they correlate to the various Gen operators.

I gave a list of correlates for translating the diagrams in this thread:

https://cycling74.com/forums/topic/good ... de-online/
Unsound Designer

dataf1ow
Posts: 230
Joined: Wed Oct 08, 2008 4:28 pm

Re: Math Coding for M4L

Post by dataf1ow » Fri May 15, 2015 4:41 pm

I've been getting into Gen~ a lot lately as a way to get into more low-level signal processing stuff, and I just finished a M4L device where most of the audio stuff is Gen (although it's just recording and playing back a buffer, basically). Resources like this are great!

Funny - I have that cycling forum post bookmarked already :wink: I must've stumbled upon it in the past.

/hijack

Post Reply