Naive question about interfacing MAX and C

May 15, 2009 at 3:53pm

Naive question about interfacing MAX and C

I’m just getting started with MAX, so what I’m after is a reading on whether what I’d like to do is feasible and if so, what particular MAX facilities I should aim to study so that I can do it.

I have some C code that processes MIDI data. It takes in a set of data related to MIDI notes as they come in and produces other data as its output. The amount of data is modest — no more than a few dozen integers per note processes. The processing is also trivial by signal-processing standards — probably no more than a few thousand instructions per note. However, it is complicated enough that I would rather not translate the C code into another language if I can avoid it.

So my question is this: Once I am comfortable in using MAX, how can I go about writing an interface that will let me use this C code. Ideally what I would like is to write something in MAX that I can interpose between a piece of commercial software, such as a sequencer, and the MIDI device that it is controlling. The MAX part would inspect the MIDI signals as they flow by, figure out what to send to the C code, and send the possibly altered MIDI data on to the device.

Is there a normal way of doing this in MAX? If so, can you point me at the particular MAX objects that I need for this purpose?

#43936
May 15, 2009 at 4:07pm
#157808
May 15, 2009 at 4:16pm

Duh. Of course!

Looks big, but maybe I’ll be able to figure it out when I get there.

#157809
May 15, 2009 at 8:54pm

Also, depending on what the code is actually doing, you could figure out how to process it using Max objects—everything you need is there. Though I understand that you’ve already written a considerable amount, there will be a lot of “a-ha!” moments as you progress, which will undoubtedly give you more ideas of what’s possible. The real strength of Max is its connection between number manipulation and the UI, so you can draw upon either or both. In this case, you could probably utilize some UI elements to help your testing and performance.

#157810
May 16, 2009 at 6:28pm

Or if you want a “ligth” alternative to developing a full-fledged Max external, you can consider translating your code to Java or JavaScript, which can be used in Max utilising the mxj and js objects, respectively. Guess it all depends on the complexity of the code, and your which language you are most comforable working with.

#157811
May 16, 2009 at 8:31pm
ark wrote on Fri, 15 May 2009 17:53
However, it is complicated enough that I would rather not translate the C code into another language if I can avoid it.

I bet, if you redo it in Max, you’ll see that it isn’t that complicated to do the same in Max…Wink

But the straight forward way would be to create max objects out of the c code directly (SDK)… If you want it cross plattform, Java would eventually also be an option. Java was made to not confuse C programmers…

Stefan

#157812
May 16, 2009 at 8:38pm

It is probably worthwhile trying to translate it into Max once I know enough about Max’s data structures.

#157813

You must be logged in to reply to this topic.