Naive question about interfacing MAX and C

    May 15 2009 | 3:53 pm
    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?

    • May 15 2009 | 4:07 pm
    • May 15 2009 | 4:16 pm
      Duh. Of course!
      Looks big, but maybe I'll be able to figure it out when I get there.
    • May 15 2009 | 8:54 pm
      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.
    • May 16 2009 | 6:28 pm
      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.
    • May 16 2009 | 8:31 pm
      ark wrote on Fri, 15 May 2009 17:53However, 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...
      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...
    • May 16 2009 | 8:38 pm
      It is probably worthwhile trying to translate it into Max once I know enough about Max's data structures.