Advanced Multimedia Development - PowerPoint PPT Presentation

About This Presentation
Title:

Advanced Multimedia Development

Description:

Advanced Multimedia Development – PowerPoint PPT presentation

Number of Views:48
Avg rating:3.0/5.0
Slides: 21
Provided by: ichirof
Category:

less

Transcript and Presenter's Notes

Title: Advanced Multimedia Development


1
Advanced Multimedia Development
  • MUMT 402
  • E-230 (UCL)
  • Tuesday 435pm -725pm
  • Ichiro Fujinaga
  • Ich_at_music.mcgill.ca

2
Writing max External Objects
  • Initialization
  • main()
  • Definition of methods to create new object
  • Definition of methods to bind to other messages

3
The bang object Initialization
  • include "ext.h // Required for all Max
    external objectsvoid this_class // Required.
    Global pointing to this class
  • Required for all objects
  • ext.h in Max/MSP SDK
  • contains other header files
  • prototypes
  • this_class is used as a pointer to this class

4
The bang object Initialization (data)
  • typedef struct _bang // Data structure for this
    object t_object b_ob // Must always be the
    first field
  • // used by Max void b_out
    // Pointer to an outlet t_bang
  • Must start with t_object (see ext_mess.h)
  • Max convention first letter followed by
    underscore
  • Every object has an inlet
  • b_out is a pointer to an outlet

5
The bang object Initialization (methods)
  • // Prototypes for methods
  • // need a method for each incoming message
  • void bang_new(void) // object creation
    method void bang_bang(t_bang bang) // method
    for bang message
  • Declaration of class methods that will respond
    to Max messages
  • Objects respond to messages from the Max
    environment
  • Objects receive messages (integer, float
    ,symbol) in their inlets
  • Objects methods will process these messages in
    some way and then    send out messages
    using the objects outlets
  • This bang object responds to new an bang
    messages

6
The bang object main()
  • When an object is created for the first time
  • External object is loaded into memory
  • main() is executed once and only once
  • main() specifies how the object should be
    initialized
  • Setup the class
  • Allocate memory for the object
  • Specify method for the creation of instances of
    the object
  • Define messages that the object can respond to
    and bind each message to a method

7
The bang object main() cont.
  • void main(void)
  • // set up our class create a class definition
  • setup(this_class, (method)bang_new, 0L,
    (short)sizeof(t_bang), 0L, 0)
  • // bind method "bang_bang to the "bang" message
  • addbang((method)bang_bang)
  • Setup creates the class
  • Get pointer to the class, specify instance
    creation method, instance free method, size of
    each instance, GUI object.
  • addbang binds the method to bang message
    coming into the left inlet (addint, addinx,
    addmess, addft, and addftx)  

8
The bang object main() cont.
  • void main(void)
  • // set up our class create a class definition
  • setup(this_class, (method)bang_new, 0L,
    (short)sizeof(t_bang), 0L, 0)
  • // bind method "bang_bang to the "bang" message
  • addbang((method)bang_bang)
  • Setup creates the class
  • Get pointer to the class, specify instance
    creation method, instance free method, size of
    each instance, GUI object.
  • addbang binds the method to bang message
    coming into the left inlet (addint, addinx,
    addmess, addft, and addftx)  

9
The Binders
  • Max routines that binds messages to your methods
  • addbang(method mp) bang message into the
    left inlet bound to mp
  • addint(method mp) int into left inlet bound
    to mp
  • addinx(method mp, short inlet) int into
    inlet bound to mp
  • addfloat(method mp) float into left inlet
    bound to mp
  • addftx(method mp, short inlet) float into
    inlet bound to mp
  • addmess(method mp char sym short
    types...) any message into left inlet bound to
    mp

10
The bang object The object creation function
  • void bang_new(void)
  • t_bang bang
  • // create the new instance and return a pointer
    to it
  • bang (t_bang )newobject(this_class)
  • bang-gtb_out bangout(bang) // create a bang
    outlet
  • return(bang)// must return a pointer to the new
    instance
  • Creates an instance of the class by newobject()
  • Outlet is created by bangout() and assigned in
    the object s struct

11
The Outlet Creators
  • Max routines that creates outlets
  • bangout(void your_object) create outlet that
    sends bang
  • intout(void your_object) create outlet that
    sends int
  • floatout(void your_object) create outlet that
    sends float
  • listout(void your_object) create outlet that
    sends list
  • outlet_new(void your_object, char msgType)
    create outlet that sends any message

12
The bang object Handling the bang message
  • void bang_bang(t_bang bang)
  • // send a bang to the outlet bang-gtb_out
  • outlet_bang(bang-gtb_out)
  • This method is called when bang message is
    received at the left inlet. (because of
    addbang())
  • The bang_bang method simply sends a bang
    messages via the outlet via a max method,
    outlet_bang()
  • The outlet, bang-gtb_out was created by bangout()

13
The Senders
  • Max routines that sends messages from outlets
  • outlet_bang(Outlet outlet) sends bang
  • outlet_int(Outlet outlet) sends int
  • outlet_float(Outlet outlet) sends float
  • outlet_list(Outlet outlet, t_symbol
    msg, short argc, t_atom argv)
  • sends list
  • outlet_anything(Outlet outlet, t_symbol
    msg) sends any message

14
The diff object
  • Introduces how to add inlets and arguments to
    your object.
  • Same as the Max built-in - object.
  • Outputs the difference of two integers the
    number coming in on the left inlet minus the
    number stored in the object which can be either
    specified via the right inlet or in the argument
    inside the objects box.

15
The diff object Data structure
  • typedef struct _diff // Data structure for this
    object
  • t_object d_ob // Must always be the first field
  • long d_valleft // Last value sent to left
    inlet
  • long d_valright // Last value sent to right
    inlet
  • long d_valtotal // Value to be sent to outlet
  • void d_out // Pointer to outlet, need one
    for each outlet
  • t_diff
  • Note that three values are stored within the
    object.

16
The diff object Initialization
  • In the setup function in main() now has A_DEFLONG
    argument indicating that the object accept one
    integer argument in the object box.
  • setup((t_messlist ) this_class, diff_new, 0L,
    (short)sizeof(t_diff), 0L, A_DEFLONG, 0)
  • Three methods are bound with the three types of
    messages bang in the left inlet, integer
    entered in the left inlet, and integer entered in
    the right inlet.
  • addbang((method)diff_bang) // bind "diff_bang"
    to the //"bang" message
  • addint((method)diff_int) // bind "diff_int" to
    int //received in the
    left inlet
  • addinx((method)diff_in1,1) // bind "diff_in1" to
    int // received in the
    right inlet

17
The diff object Object creation
  • void diff_new(long value)
  • t_diff diff
  • diff (t_diff )newobject(this_class) //
    Create new // instance and
    return a pointer to it
  • diff-gtd_valright value // Initialize the diff
    values
  • diff-gtd_valleft 0
  • diff-gtd_valtotal -value
  • diff-gtd_out intout(diff) // Create our outlet
  • intin(diff,1) // Create the right inlet
  • return(diff) // Return a pointer to the new
    instance
  • Value is passed if the user types a number in the
    objects box

18
The diff object Methods
  • void diff_int(t_diff diff, long value)
  • diff-gtd_valleft value // Store the value
    received in the // left
    inlet
  • diff-gtd_valtotal diff-gtd_valleft -
    diff-gtd_valright// Subtract right inlet value
    from the left
  • diff_bang(diff) // Call bang method right away
    since it's // the left inlet
  • The diff_int method is called when an integer
    comes in on the left inlet. It stores the value
    in d_valleft, subtracts that value with
    d_valright, storing the result in d_valtotal,
    then calls the diff_bang method to output the
    result.

19
The diff_assist object Add to New Object list
  • To make an entry in the New Object list Include
    the following in your main()
  • finder_addclass("All Objects", "diff_assist")
  • To add the object to the Arithmetic/Logic list
    as well, you add the following
  • finder_addclass("Arithmetic/Logic","diff_assist")

20
The diff_assist object diff_assist method
  • To add assistance message, a method must be
    defined and bound to the MAX message assist.
    Thus in main()
  • addmess((method)diff_assist, "assist", A_CANT,
    0)
  • Then define the method
  • void diff_assist(t_diff diff, Object b, long
    msg, long arg, char s)
  • msg 1 if the cursor is over an inlet
  • msg 2 if the cursor is over an outlet
  • arg is the inlet or outlet number starting at 0
    from left
  • s is where the assistance message is copied
Write a Comment
User Comments (0)
About PowerShow.com