Writing Objective-C Externals for Max

Timothy Place's icon

Hi all,

I thought you might be interested to know that I've finally done
something of a release of the ObjectiveMax project that was alluded to
here back in October.

I've posted a blog entry here:
    http://electrotap.net/blog/show/462

The direct link to the project site is here:
    http://code.google.com/p/objectivemax/

If you want to contribute please let me know. It would be great to
see this effort further developed by the community.

best,
Tim

_________________
Tap.Tools / Teabox / Hipno / Hemisphere
http://electrotap.com

keithmanlove's icon

Tim,

Am I missing something? I can't find a directory for
MaxObject.framework anywhere. Can't figure out how to build it
either. Any help would be great. Sorry if I'm missing anything
obvious. I'm very excited about this whole project.

Thanks,
Keith

On May 24, 2008, at 9:15 AM, Timothy Place wrote:

> Hi all,
>
> I thought you might be interested to know that I've finally done
> something of a release of the ObjectiveMax project that was alluded
> to here back in October.
>
> I've posted a blog entry here:
>     http://electrotap.net/blog/show/462
>
> The direct link to the project site is here:
>     http://code.google.com/p/objectivemax/
>
> If you want to contribute please let me know. It would be great to
> see this effort further developed by the community.
>
> best,
> Tim
>
> _________________
> Tap.Tools / Teabox / Hipno / Hemisphere
> http://electrotap.com
>

Timothy Place's icon

Hi Keith,

To build it, you should be able to do it by opening the Xcode project
in in the MaxObject folder and then building it. There is also a new
(as in it has only existed for a couple of days) list set up
specifically for ObjectiveMax below if you have other questions.
    http://groups.google.com/group/objectivemax

best,
Tim

On 2008 May 28, at 8:25 AM, Keith Manlove wrote:

> Tim,
>
> Am I missing something? I can't find a directory for
> MaxObject.framework anywhere. Can't figure out how to build it
> either. Any help would be great. Sorry if I'm missing anything
> obvious. I'm very excited about this whole project.
>
> Thanks,
> Keith
>
> On May 24, 2008, at 9:15 AM, Timothy Place wrote:
>
>> Hi all,
>>
>> I thought you might be interested to know that I've finally done
>> something of a release of the ObjectiveMax project that was alluded
>> to here back in October.
>>
>> I've posted a blog entry here:
>>     http://electrotap.net/blog/show/462
>>
>> The direct link to the project site is here:
>>     http://code.google.com/p/objectivemax/
>>
>> If you want to contribute please let me know. It would be great to
>> see this effort further developed by the community.
>>
>> best,
>> Tim

matteopennese's icon

I'm tryin' to follow the instructions to build a simple object (dr.op) in a very slavish way, but I receive a compiling error:
Command /Developer/usr/bin/gcc-4.2 failed with exit code 1

Building Maxobject.framework seemed ok, even tough MaxObject.a is in red and compiler shows a lot of advertising...

I'm really a newbie in C and similars, so any suggestion is very welcomed!

Thank you.

matteo

10.6.4.
Xcode 3.2.3.
MaxMsp 5.1.4.
Jit 1.7

efe's icon

Is it possible to compile jitter objects with this method?

Timothy Place's icon

@efe: I have not done any work to wrap/support Jitter methods with ObjectiveMax. If anyone would like to contribute this to the project, just let me know!

@matpe: When you build MaxObject, you can build it as either a framework or as a static library (the .a file). So it's fine that the .a file is red, because the example externs in ObjectiveMax use the .framework version. In Xcode you can switch between these in the pop-up menu in the upper-left of the main project window.

It turns out that there was some project maintenance that needed to be done. I've done it, and things should compile again. If you've checked-out using Git, then give it a pull and hopefully it will all work for you now.

For the gitophobes, you can now download @ http://github.com/tap/ObjectiveMax/downloads

Enjoy!

efe's icon

Nice nice nice! time to clone the project!

matteopennese's icon

Hi Tim,
it works like a charm! Thank you so much. A really exciting project.

matteo

matteopennese's icon

Hi Tim,
I also compiled dr.op~. Everytime I close the window I receive a message in the max window as:
freeobject: random string (e.g. 1995c4a7): bad object.
Any tip about developing an audio object with ObjectiveMax?
Thank you again.

matteo

Timothy Place's icon
matteopennese's icon

Hi Tim,
I downloaded again ObjectiveMax and recompiled but I receive the same error. Tried to correct only the MaxObject/maxobjectbridge.m, but no difference...
But I'm maybe misunderstanding something.
Thank you.

matteo

Timothy Place's icon

Hi Matteo,

First, when you say you downloaded again, can you confirm that you downloaded 1.7.1. Second, you would have needed to compile the MaxObject framework -- not just the object. Then, you might make sure that the framework was correctly copied to /Library/Frameworks. I have noticed in the past that sometimes Xcode will fail to replace a framework in /Library/Frameworks if it already exists.

HTH,
Tim

matteopennese's icon

Hi Tim,
I had to be more precise...
Yes, I followed all the steps:
- downloaded 1.7.1
- compiled MaxObject framework and copied to /Frameworks.
Closing window returns 'bad object' with dr.op~.
thank you

matteo

adam12's icon

Can someone gave me a hint or point me to the right resources about how to create a new ObjectiveMax project in Xcode 3.2?

BTW, objective max seems really cool! I can get everything compiled without a problem.

thanks,

adam

DiGiTaLFX's icon

Hi

I've been tinkering with ObjectiveMax for a little bit now, but I can't seem to find any documentation. So I have 2 questions:

First, is there documentation anywhere?

Second, as I've been trying to do things that aren't right, I end up completely crashing Max and it just quits. Whilst I understand I've done stuff wrong, is there a way I can just make the external complain quietly (e.g. like a js object would), rather than kill the whole Application? I don't think I'd really feel happy using my own externals knowing that this is the result if something went wrong.

Many thanks

DiGiTaLFX

Timothy Place's icon

Documentation for now consists just of the couple of example projects. If you (or anyone) wants to contribute documentation it is very much needed. Welcome to open source :-).

As for problems occurring at runtime instead of at compile time, this is one of the dangers of dynamic binding. With Objective-C it is arguably more important to pay attention to any compiler warnings, because they may point to serious problems in the compiled binary. Beyond that, it is difficult to speculate without seeing the project/code.

Cheers!

Joshua Kit Clayton's icon

If you are crashing with a crashlog, you can post it here. It most likely will point you to your problems. Also, you should run in the Xcode debugger to track this down(launch your patch in max runtime).

If it is simply quitting, it sounds like an uncaught exception, or has reached some part of a code path which calls exit(). If you are integrating other libraries or apple API features that throw exceptions, you will need to handle them.

Good luck!

-Joshua

DiGiTaLFX's icon

Thanks very much for the pointers! I'll keep experimenting and see how it goes :)

Peter Castine's icon

Is this project still active?

The GitHub pages now 404 and the version at Google Code is labeled v0.1.1 whereas the more recent discussion (a year ago now) talks about v1.7.1.

I've not had a need for using Objective C before, but now need to interface to Cocoa, so was hoping this might be an appropriate way.

vade's icon

Peter, you can just call into Cocoa via Objective-C in your Max externals C source anywhere, since Obj-C and C can be used interchangeably. The only gotcha is memory management, where you need to manage your own auto-release pools.

Syphon uses Objective C in the Jitter externals. Feel free to poke around the source if it is useful to you.

Edit: Here is a sample from the Syphon Client:

Note the source file is named a '.m' so Xcode can auto-magically compile it as Obj-C. We use an Objective-C object in the jitter struct on line 55, and anywhere we need to call into Obj-C / Cocoa, we ensure we create an auto-release pool (and drain it) as needed. See line 268 for example. Hope that helps!

Peter Castine's icon

Thanks very much, Vade.

Actually got this working last Thrus/Fri by reading some other code kindly posted to the forum (merci à toi, vanille !)

The library I'm linking to is actually in Objective-C++, so I have three C dialects dancing around the project. It's not hard once you get used to it, but it does take a little getting used to.

Now I just have to build a Windows version, which will be largely the same but without the Obj-C wrappers.

jbm's icon

Hello Timothy,

I've been wanting to try out ObjectiveMax for a while, but I'm getting bizarre errors while trying to build the MaxObject framework. For some reason, I get "Unknown type name" errors (for intmax_t, uintmax_t, etc.) and "Use of undeclared identifier errors" (for equally arbitrary type names) when I try to build. I can't see any obvious reason for this, but I'm guessing maybe it has to do with changes in the way Xcode works in more recent versions. Do you have any tips about how I might get this compiling?

thanks in advance.

J.

jbm's icon

hmm... actually, I hadn't read the thread carefully enough. I just tried putting an NSMutableDictionary in a "normal" max external, just by renaming the .c to a .m and using a local autoreleasepool, as Peter recommended, and it worked perfectly! How cool is that!

I really just wanted access to some of the data structures from Obj-C, so this is a great solution.

Thanks for the tip, Peter.

J.

tap's icon

I'm not sure what header defines intmax_t and friends, but you'll need to #include to fix that problem. On the otherhand, there are many ways to skin a cat. Glad you've found a way that works for you!

Cheers,
Tim