Digital Music Programming II: Making a Max/MSP CodeWarrior Project




These sets of directions are for creating a Max/MSP external object on a Mac PPC OS 9 computer which has the following software installed:
  1. Max 4.0/MSP 2.0
  2. SDK for Max 4.0/MSP 2.0 for MAC OS 9.
  3. CodeWarrior 6.0 with IDE 4.1.

Computers at Peabody which are know to work for this lab: 307 Prep Station, 311 Laptop, 314.

The following instructions are taken from Ichiro Fujinaga's Max/MSP Externals Tutorial, version 2.41 (Sep 2002), pages 1-2.


  1. Open CodeWarrior IDE

  2. select menu File --> New...

  3. In the New window that opens, do the following:
    1. project name: mybang.mcp
    2. Set the location where you want to save your project. For example: Xenakis:Desktop Folder:Users:craig:mybang.
    3. In the Project tab subwindow, click on "Mac OS C Stationery"
    4. Click the OK button to go to the next window.

  4. In the "New Project" window, do the following:
    1. Open "Standard Console".
    2. Then open "PPC".
    3. Then choose "Std C Console PPC".
    4. Click on the OK button to go to the next window.

  5. A windows called "mybang.mcp" should now appear on the screen, do the following:
    1. Drag "Sources" folder to the trash.
    2. Drag "ANSI Library" folder to the trash.
    3. Open "MAC Libraries" folder and then drag "MSLRuntime PPC.lib" and MathLib into the trash, leaving only the file Interface.lib.

  6. Select menu File --> "New Text File" (or type apple-N) to create a new text file.
    1. Copy these contents into the new file (explained in Ich's Tutorial):
      
      #include "ext.h"
      
      typedef struct {
         t_object max_data;
         void*    output;
      } MyObject;
      
      void *object_data;
      
      void *create_object(void);
      void InputBang(MyObject *mo);
      
      void main(void) {
         setup((t_messlist**)&object_data, (method)create_object, 
               NULL, (short)sizeof(MyObject), NULL, A_NOTHING);
         addbang((method)InputBang);
      }
      
      void *create_object(void) {
         MyObject *mo;
         mo = (MyObject*)newobject(object_data);
         mo->output = bangout(mo);
         return mo;
      }
      
      void InputBang(MyObject* mo) {
         outlet_bang(mo->output);
      }
            
    2. Save the file to the project folder or wherever you want to save your source code.
    3. select menu Project --> "Add mybang.c to Project". Note that you must have the mybang.c window active when you do this; otherwise, that option will be grayed out. Your source code should now be listed in the "mybang.mcp" window.

  7. Add the Max/MSP libraries
    1. select menu Project --> "Add Files...". Locate the file MaxLib file. For example: Xenakis:Max4/MSP2:Max/MSP SDK:SDK Examples:Max includes:MaxLib.
    2. If you want to make a MSP object, select menu Project --> "Add Files...". Locate the file MaxAudioLib file. For example: Xenakis:Max4/MSP2:Max/MSP SDK:SDK Examples:MSP includes:MaxAudioLib.

  8. Adjust the project settings for compiling a Max/MSP project.
    1. select menu Edit --> "PPC Std C Console Settings..."
    2. in the "Target Settings Panels" subwindow on the left, select Target --> "PPC Target".
    3. in the "PPC Target" subwindow on the right, change the project type from Application to "Shared Library".
    4. change the Creator to be "max2.
    5. change the Type to be "iLaF" (I am sure you do).
    6. in the "Target Settings Panels" subwindow on the left, select Linker --> "PPC Linker".
    7. in the "PPC Linker" subwindow on the right, uncheck the "Generate SYM File" option.
    8. in the "Entry Points" field, change __start to main.
    9. in the "Target Settings Panels" subwindow on the left, select Linker --> "PPC PEF".
    10. in the "PPC PEF" subwindow in the right, check the option "Expand Uninitialized Data".
    11. in the "Target Settings Panels" subwindow on the left, select "Language Settings" --> "C/C++ Language".
    12. uncheck the "ANSI Strict" option.
    13. in the "Prefix File" field enter MacHeaders.h
    14. click on the Save button, and then close "PPC Std C Console Settings" window.

  9. Compile the object:
    1. select menu Project --> Make (or apple-M)
    2. if the compile is successful, then a Max object will be written into your project folder. Go to the finder and look for it.

  10. Test your compiled object:
    1. Start Max/MSP as you normally do, or by clicking on your new object.
    2. make a new patcher in Max/MSP and add the external object to the patch.