Writing Objective-C Externals for Max

May 24, 2008 at 2:15pm

Writing Objective-C Externals for Max

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

#38035
May 28, 2008 at 1:25pm

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
>

#131837
May 28, 2008 at 8:07pm

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

#131838
Aug 8, 2010 at 4:50pm

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

#131839
Aug 9, 2010 at 5:27am

Is it possible to compile jitter objects with this method?

#131840
Aug 9, 2010 at 11:52am

@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!

#131841
Aug 9, 2010 at 1:51pm

Nice nice nice! time to clone the project!

#131842
Aug 9, 2010 at 3:09pm

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

matteo

#131843
Aug 9, 2010 at 3:34pm

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

#131844
Aug 15, 2010 at 1:02am

Thanks for the info. It’s been fixed. Details @ http://github.com/tap/ObjectiveMax/commit/025a94b6d67486cb99d238e1b46e0e4a6733779a

Cheers

#131845
Aug 15, 2010 at 10:09pm

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

#131846
Aug 16, 2010 at 1:35pm

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

#131847
Aug 16, 2010 at 2:41pm

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

#131848
Sep 17, 2010 at 2:13pm

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

#131849
Sep 27, 2010 at 2:36pm

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

#131851
Oct 5, 2010 at 1:57pm

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!

#131852
Oct 5, 2010 at 6:19pm

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

#131853
Oct 6, 2010 at 9:57am

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

#131854
Nov 17, 2011 at 12:08pm

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.

#131855
Nov 20, 2011 at 7:44am

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:

http://code.google.com/p/syphon-implementations/source/browse/trunk/Syphon%20Implementations/Jitter/jit.gl.syphonclient/jit.gl.syphonclient.m

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!

#131856
Nov 21, 2011 at 12:22pm

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.

#131857
Oct 24, 2012 at 12:14am

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.

#131858
Oct 24, 2012 at 1:25am

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.

#131859
Oct 24, 2012 at 2:36pm

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

#131860
Oct 24, 2012 at 4:01pm

As example : attached exercises (Peter was talking about) with objective-C i did long time ago.

Attachments:
  1. flopObjectiveC.zip
#131861

You must be logged in to reply to this topic.