ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
Yet Another
 Max/MSP - Cocoa
    Integration
cocoa-send / cocoa-receive external objects

                Nao Tokui




                                              1
Why Integrate?

? Max/MSP
 ¡ð Useful for Audio / MIDI / Images .... !!
    Scalability
  ¡Á Hard to manage big data set.



                                              2
Why Integrate?
? Cocoa - Native OS X Environment
 ¡ð Lots of useful frameworks and easy-to-use
   tools for them.
   ? Frameworks - CoreData, Bonjour, QuartzComposer...
   ? Tool - Xcode, InterfaceBuilder...
 ¡Á  Audio / MIDI API is very very complicated.
   ? Core Audio / Core MIDI / Quick Time


                                                         3
Max/MSP                Cocoa

             Bonjour
    Audio

              CoreData
     MIDI

            OpenGL




                               4
Conventional Ways

? MIDI?
 ? CoreMIDI - Simply Overkill!
? Open Sound Control
 ? Very ?exible, but clumsy implementation
 ? Not easy to use in Cocoa

                                             5
NE
                       W


cocoa_send / receive
   external object


                           6
Features
¡ð Simple to implement and Just works!
¡ð No need to ¡°connect¡± explicitly (Always
  Connected!!)
¡Á Limited to local use
       OK                                      NG!
                                                                   Cocoa
     Max   Cocoa
                          Max


                         http://commons.wikimedia.org/w/index.php?title=Image:MacBook_Pro_transparency.png


                                                                                                             7
Technical Details

? cocoa_send/receive use OS X¡¯s Inter-
  Application Communication called
  ¡°Distributed Noti?cations¡±
 ? eg.) Preference Pane
 ?   http://developer.apple.com/documentation/UserExperience/Conceptual/
     PreferencePanes/Tasks/Communication.html




                                                                           8
How to Use #1
1. Download cocoa_send/receive objects and
   sample application from www.naotokui.com
2. Set ¡°Channel Names¡±
   ?   These names will be used to identify
       communication channels. They must be shared
       between Max objects and Cocoa project.



                             Max ¡û Cocoa
       Max ¡ú Cocoa

                                                     9
How to Use #2
3. Open Cocoa_SR_Test folder
   and include Cocoa_SR_Test.h/
   m in your own Cocoa Project.
4. Set the same Channel Names
    #define CH_NAME_FROM_COCOA

 @quot;FROM_Cocoaquot;
    #define CH_NAME_TO_COCOA

 @quot;TO_Cocoaquot;


5. Use -sendString: -sendFloat:/-
   sendInteger methods to send.




                                                 10
Sending from Cocoa
?   Use -send**: methods.
      - (void) sendString: (NSString *) str;

      - (void) sendFloat: (float) number;

      - (void) sendInteger: (int) number;




                                               11
Receiving in Cocoa
? Customize callbackWithNotification:
            a callback function:
  - (void)
- (void) callbackWithNotification:(NSNotification *)myNotification
{

 NSDictionary *dict = [myNotification userInfo];


  // a string value received
 
 NSString *string = [dict valueForKey:SHARED_DICTIONARY_KEY_FOR_ANYTHING];

 if (string) {
       // Do something
  } .....




    ? Dictionary Keys:
                                 SHARED_DICTIONARY_KEY_FOR_FLOAT
                                 SHARED_DICTIONARY_KEY_FOR_INT
                                 SHARED_DICTIONARY_KEY_FOR_ANYTHING


                                                                               12
Usage Cases
? Phonethica Rondo / VoiceCosmos


  http://www.ntticc.or.jp/Archive/2006/Openspace/network/phonethica_j.html




? Matarisama Binary 1.2 (by N.Nagano)
                                                                             13
Links


? Download
 ? www.naotokui.com/home/Downloads.html


                                          14

More Related Content

Yet Another Max/MSP-Cocoa Communication

  • 1. Yet Another Max/MSP - Cocoa Integration cocoa-send / cocoa-receive external objects Nao Tokui 1
  • 2. Why Integrate? ? Max/MSP ¡ð Useful for Audio / MIDI / Images .... !! Scalability ¡Á Hard to manage big data set. 2
  • 3. Why Integrate? ? Cocoa - Native OS X Environment ¡ð Lots of useful frameworks and easy-to-use tools for them. ? Frameworks - CoreData, Bonjour, QuartzComposer... ? Tool - Xcode, InterfaceBuilder... ¡Á Audio / MIDI API is very very complicated. ? Core Audio / Core MIDI / Quick Time 3
  • 4. Max/MSP Cocoa Bonjour Audio CoreData MIDI OpenGL 4
  • 5. Conventional Ways ? MIDI? ? CoreMIDI - Simply Overkill! ? Open Sound Control ? Very ?exible, but clumsy implementation ? Not easy to use in Cocoa 5
  • 6. NE W cocoa_send / receive external object 6
  • 7. Features ¡ð Simple to implement and Just works! ¡ð No need to ¡°connect¡± explicitly (Always Connected!!) ¡Á Limited to local use OK NG! Cocoa Max Cocoa Max http://commons.wikimedia.org/w/index.php?title=Image:MacBook_Pro_transparency.png 7
  • 8. Technical Details ? cocoa_send/receive use OS X¡¯s Inter- Application Communication called ¡°Distributed Noti?cations¡± ? eg.) Preference Pane ? http://developer.apple.com/documentation/UserExperience/Conceptual/ PreferencePanes/Tasks/Communication.html 8
  • 9. How to Use #1 1. Download cocoa_send/receive objects and sample application from www.naotokui.com 2. Set ¡°Channel Names¡± ? These names will be used to identify communication channels. They must be shared between Max objects and Cocoa project. Max ¡û Cocoa Max ¡ú Cocoa 9
  • 10. How to Use #2 3. Open Cocoa_SR_Test folder and include Cocoa_SR_Test.h/ m in your own Cocoa Project. 4. Set the same Channel Names #define CH_NAME_FROM_COCOA @quot;FROM_Cocoaquot; #define CH_NAME_TO_COCOA @quot;TO_Cocoaquot; 5. Use -sendString: -sendFloat:/- sendInteger methods to send. 10
  • 11. Sending from Cocoa ? Use -send**: methods. - (void) sendString: (NSString *) str; - (void) sendFloat: (float) number; - (void) sendInteger: (int) number; 11
  • 12. Receiving in Cocoa ? Customize callbackWithNotification: a callback function: - (void) - (void) callbackWithNotification:(NSNotification *)myNotification { NSDictionary *dict = [myNotification userInfo]; // a string value received NSString *string = [dict valueForKey:SHARED_DICTIONARY_KEY_FOR_ANYTHING]; if (string) { // Do something } ..... ? Dictionary Keys: SHARED_DICTIONARY_KEY_FOR_FLOAT SHARED_DICTIONARY_KEY_FOR_INT SHARED_DICTIONARY_KEY_FOR_ANYTHING 12
  • 13. Usage Cases ? Phonethica Rondo / VoiceCosmos http://www.ntticc.or.jp/Archive/2006/Openspace/network/phonethica_j.html ? Matarisama Binary 1.2 (by N.Nagano) 13
  • 14. Links ? Download ? www.naotokui.com/home/Downloads.html 14