For Readers of "Designing Audio Objects for Max/MSP and Pd"

    Apr 07 2014 | 4:03 pm
    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 main(void)
    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:

    • Apr 07 2014 | 5:47 pm
      Thanks for the update Eric. I still haven't found time to read the book several months after having bought it however...
    • Jul 30 2014 | 8:21 pm
      Hi Eric,
      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.
    • Jul 30 2014 | 8:58 pm
      Hi Rahul,
      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.
    • Jul 31 2014 | 2:32 am
      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.
    • Sep 04 2014 | 7:35 pm
      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.
      Best, Matthias
    • Sep 04 2014 | 11:46 pm
      Hi Matthias,
      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.
    • Jul 14 2015 | 1:19 pm
      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.
    • Jul 14 2015 | 2:03 pm
      Hi Dominik,
      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.
    • Jan 23 2016 | 8:05 pm
      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?
    • Jan 23 2016 | 8:48 pm
      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. Sorry guys.. I honestly spent hours looking for that...
    • Apr 21 2016 | 5:00 pm
      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.
    • Apr 24 2016 | 12:46 pm
      Hello Eric,
      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.
      Best regards,
    • Apr 24 2016 | 2:00 pm
      Hi Juan,
      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!
    • Jan 12 2018 | 9:22 am
      Hello Eric, and readers of "Designing Audio Objects for Max/MSP and Pd",
      I want to share my implementation of the projects explained in the book. I have included many details about how I build the projects for Max and Pd, on macOS, Windows, and Linux (even for embedded platforms like Bela). The core code follows the one provided by the book, but is not necessarily updated to the latest developments of the Max or Pd API.
      I hope somebody finds something useful in this project. Feedback is very welcomed and appreciated.
    • Jan 12 2018 | 1:12 pm
      Thanks so much, Juan! I have added a link to your work on my website.