For Readers of "Designing Audio Objects for Max/MSP and Pd"
As some of you may know, I published a book on designing audio objects (externals) in 2012. Although most of the code in the book remains valid, there has been a change in the most recent Max SDK, version 6.1.4 that requires an update to all of the externals described in my book (and indeed to every third-party external written prior to SDK 6.1.4).
Put briefly, the declaration of the main() function has changed from:
int C74_EXPORT main()
Externals compiled with the old declaration will compile without error, but will not load into Max.
I have updated the book’s CDROM with new projects that will compile and load to any version of Max, up through version 6.1. The update is only for Mac, and has been tested with Xcode 5.1 on OS X 10.9.2. The same code fix should work on Windows, but I don’t currently have access to a Windows system to test it. The updated CDROM can be downloaded here:
Thanks for the update Eric. I still haven’t found time to read the book several months after having bought it however…
I downloaded the latest CD and tried the mirror~ example. While the code compiles correctly, the resulting object doesn’t work in Max. Here is everything I’ve tried:
(i) Using the old mirror~ Xcode project from the original CD with the included Max SDK. Result: Didn’t compile because I had the latest version of Max/MSP (i.e. 6.1.4) and the SDK that came with the CD was old.
(ii) Using the old mirror~ Xcode project from the original CD with the latest Max SDK (6.1.4). Result: Compiled correctly in Xcode 5.1.1 (on Mac OS X 10.9.4) with the only exception being the dsp_add warning (which, if I understand correctly, shouldn’t be an issue). When I tried using the result .mxo external in an example Max patch, it didn’t work (it wasn’t allowing audio through it).
(iii) Using the new (from the latest CD you posted above) mirror~ Xcode project with the latest Max SDK (6.1.4). Result: Same as (ii)
(iv) Using an example Xcode project (lores~) included in Max SDK 6.1.4 with lores.c replaced with the latest version of mirror.c, renaming the lores~ Xcode project to mirror~ (all these steps were followed from an earlier post of yours in another thread) etc. and compiling. Result: Same as (ii) and (iii). Note that I could compile lores~ as included in the Max SDK 6.1.4 and use the newly created lores.mxo file in a Max patch without issue.
I really don’t know what the problem could be. It’s quite frustrating. Although this may not be terribly useful, I’ve tried to attach the mirror.mxo file I generated if you think you’d like to test it on your computer. Other than that, I would be happy to try any ideas you might have.
Thanks for reporting this issue. I hope we will be able to get you on track to start using the book. Please report back here if the following does not solve your problem.
Based on your observation ii) here is what I think is happening: since you were able to load mirror~ to Max 6.1, your compile environment is probably set up correctly. As a bit of history, Max 6 had only just become available as my book went to press. I was able to put a chapter on the CDROM about writing 64-bit externals for Max 6, but the content of the book is based on Max 5. That was not really an issue for Max 6, which supports 32-bit objects, but as of Max 6.1, all audio objects need to be written for 64-bit processing. I’m guessing that that is why your compiled mirror~ loads, but does not produce audio on Max 6.1. You could try it under Max 6 and it should work.
The coding changes required to write Max 6.1-compatible externals are mainly local to the dsp and perform methods. Additionally, all float variables should be changed to double. So the long-term solution is to read the CDROM chapter on 64-bit processing, and apply those changes to the externals in the book.
The CDROM chapter on Max 6 provides a complete update to the multy~ object. Please compile and test that version of multy~ on Max 6.1. If that works, you can apply coding changes as necessary to the other externals of the book to get them to work on Max 6.1.
Thanks for the response Eric. I suspected that not using 64-bit processing might have been the problem but convinced myself against this by assuming that all versions of Max would be perfectly backwards compatible. As you point out, it looks like Max 6.1 and beyond requires audio objects to be written for 64-bit processing which, I suppose, is a good thing. Anyway, I first tried compiling and using the 32-bit version of multy~. It compiled but didn’t work, as expected. Then I tried the 64-bit version of multy~ (with the int main declaration appropriately modified) and, sure enough, it worked perfectly. Converting the rest of the examples to 64-bit shouldn’t be a problem with your guide included in the CD.
I look forward to reading the rest of your book which, so far, looks to be a useful resource for Max/MSP novices. I appreciate your prompt help. Keep up the good work.
Thanks for posting this update! I’m slowly getting the hang of things, just working my way through Chapter 3 for the umpteenth time ;-)
I just spent 3 hours trying to run a 64 bit updated version of multy~. My method here was to create a new Xcode project for creating the external with a different name (cm.multy~ in my case). The external would compile, but wouldn’t load. Until I realized that I need to update the first argument in the class initialization in the main function (from "multy~" to "cm.multy~"). If this doesn’t match the external name in the project settings (product), the external will compile, but won’t load in Max.
I’m sorry if that sounds random, but I thought I’d share this insight, in case another noob like me falls into the same trap. Just to save some frustration. And you don’t mention it in the book, at least not in the first chapter where I think it would be most helpful.
Apart from that, I love the book. I just recently completed a self-study C course just for learning to program externals, and from this perspective, the book is extremely well written.
I am glad to hear that you are finding the book useful. Thanks for mentioning the point that the object name in the initialization routine must be consistent with the project name. I didn’t expect readers to be renaming objects until after they had worked through all the book examples, at which point, having seen multiple initialization routines, it should be clear how the name is set. That’s an advanced topic, but you jumped in early!
It’s really helpful for people to bring up issues with the book as they arise. I’m going to keep links to relevant forum discussions over here.
Is there already a collection of errata somewhere?
Not really crucial but it would probably save some time now and then.
Apart from that I really enjoy working with the book even itself is already falling apart.
I am glad to hear that you are enjoying the book. There is no errata list, but please email me any errata you have noticed and I will keep track of them.
I recently picked of the book again and tried to update an external to 64 bit but somehow I can’t get it to work. Even updating the multy~ patch with the updated multy.c file from the online source fails. No problem during compilation but as soon as I create an instance in Max 6 or 7 I end up with the following error:
"mymulty~: unable to load extern, object has no function named ‘ext_main’ or ‘main’ "
I’m using the Max7 SDK.
Maybe somebody has an idea how this can be solved?
As always, after trial and error for about have a day I remembered that the main routine needs the additional C74_EXPORT. Some research has to be done why the deus ex machina solution always turns up right after asking the community for help.
I honestly spent hours looking for that…
I have recently updated the online CD-ROM examples to the Max 7 coding style. These examples will compile with the Max/MSP/Jitter SDK 7.1 or later. The buffer~ editor example "bed" has been revised for the new buffer~ access protocols. The approach in my book may still work, but those calls are deprecated, and will doubtless eventually expire.
Only Xcode projects are provided, but the code should work equally well on Windows. I have not had time for exhaustive testing of this code, so please let me know of any problems that you encounter.
Thanks for the update. I think the book is excellent and I am really learning a lot from it. I just finished chapter 4 where we made the vdelay~ and I had one question that I have actually posted yesterday here.
It is basically about the algorithm for writing the input to the delay_line, and then reading the output from it. When I decided to use the object with delay=0, I got unexpected results. I would appreciate your opinion about it.
Thanks for your kind words about the book. The vdelay~ example requires a delay time of at least one sample to function correctly. (You can’t have feedback from a previous sample with a delay time of zero.) In general, the examples in the book are coded for pedagogical clarity, and are not generally protected against bad data, as would normally be the case for a production external. But you could improve the code if you wish!
Forums > MaxMSP