Thread: Getting yourself API ready

  1. #1
    Registered User
    Join Date
    Dec 2016
    Posts
    2

    Getting yourself API ready

    Dear fellow forum users,

    I hope this is the right sub-forum, since the question is somehow C related but not an actual "code question".
    I'm working in the field of electronic music / sound design mostly using high level languages like MaxMSP or SuperCollider.
    I'd like to be able to write my own external objects in C using the MaxMSP API Max API.
    I think i worked through my first C Tutorial book about 10 years ago after finishing school but I've never done a real project using C.
    About a year ago I started trying to relearn C using multiple online tutorials and books. I also worked my way through a Java book during a long and boring hospital stay. In general thinking as a programmer is not foreign to me.
    I basically know how control structures, structs, arrays, pointers (to pointers), casts etc. work but I somehow lack the competence the be able to use the MaxMSP API and really understand it's documentation.
    It's probably a problem of actual C programming experience that keeps me from being able to use the API.

    I guess what I'm looking for is a way to close the gap between the tutorials I've read and the (to me) advanced implementation of the API.
    I've been working on it for quite some time now and can't really feel any progress.
    Maybe some more experienced users here have ideas or tips which advanced literature I should try in order to get my knowledge to an adequate level.

    thank you for your time!
    Dominik

  2. #2
    Registered User
    Join Date
    Dec 2010
    Location
    Trinidad, CO (log cabin in middle of nowhere)
    Posts
    148
    Possibly post a function declaration found in the API documentation and ask questions about which parts of it you don't understand. Many C and C++ Apis define custom data types and structures which need to be understood somewhat before using the Api. It is in many cases useful to examine carefully various #defines and typedefs used in the header files. Typedefs in particular are something that aren't overly emphasized in beginning tutorials, but hit you kind of like a sledge hammer when you start trying to understand complex APIs.

  3. #3
    Registered User
    Join Date
    Jun 2015
    Posts
    1,640
    API's are designed with particular usage cases in mind. Look at example programs using the API.

    It should be noted that that is a well-documented API. You're lucky! You should see the crap we have to deal with.

    How much of the API documentation have you actually read? Have you got any of the examples to work? Do you understand them?

  4. #4
    Registered User
    Join Date
    Dec 2016
    Posts
    2
    Being hit with a sledge hammer is really what it feels like. I'll try to read more about typedefs, maybe I can find something that deals with APIs in general.

    I think I've read most of the APIs documentation text except some of the very special parts concerning the video (jitter) part because it's not very important to me.
    I compiled some of the example source code that comes with the API and even created one external myself, actually only an extension to an example external that was described in a book that deals with that topic. It wasn't that hard because what I did mostly happened without much use of the API's functions, I wrote signal processing code, pushing audio samples around, which is something I'm more comfortable with. I understand how the externals have to be constructed, which basic methods are needed and what they do.

    Maybe I post an example of something I don't understand. I could post many many things but the problem is basically always the same.
    There is one example source code of an external called "simpletext" in which a function can be found which opens the built in text editor on double click:

    Code:
     
    void simpletext_dblclick(t_simpletext *x)
    {
        if (x->t_editor)
            object_attr_setchar(x->t_editor, gensym("visible"), 1);
        else {
            x->t_editor = object_new(CLASS_NOBOX, gensym("jed"), x, 0);
            object_method(x->t_editor, gensym("settext"), *x->t_text, gensym("utf-8"));
            object_attr_setchar(x->t_editor, gensym("scratch"), 1);
            object_attr_setsym(x->t_editor, gensym("title"), gensym("simpletext"));
        }
    }
    t_editor is of type t_object* and is defined in the main struct of the class.
    Apparently there is a new object created, "object_method" sends a message to the new object and attributes of the object "t_editor" are being set. It's just completely beyond me how one would no which attributes to set or why this particular object_method is needed. I can't find their definition anywhere.
    Being inexperienced it's difficult to judge if something is actually referring to a standard defined in the API or just used in this particular project. It feels like I also have problems with the vocabulary which is used in the function documentations which is why I'm really interested in advanced literature.

    thank you

  5. #5
    Registered User
    Join Date
    Jun 2015
    Posts
    1,640
    Although information exists on how to design a good API, it really doesn't make sense to ask for information about using API's in general. API's can be radically different.

    You just need to keep working at it, swimming around, coughing and spluttering, until you finally get the hang of it and can keep your head above water. It's not easy.

    The first thing to understand about a particular API is how the developers have analyzed the problem. You need to learn their terminology and the types that they've defined.

    If possible, try to find a tutorial on it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ready for GUI
    By bertazoid in forum C Programming
    Replies: 7
    Last Post: 10-31-2008, 05:08 AM
  2. are you ready?
    By Aran in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 05-12-2002, 01:38 PM
  3. Are you ready?
    By lostminds in forum Game Programming
    Replies: 6
    Last Post: 05-08-2002, 02:11 PM
  4. ready?!
    By pode in forum Game Programming
    Replies: 2
    Last Post: 03-08-2002, 01:53 AM
  5. Am I ready????
    By aresashura in forum Game Programming
    Replies: 12
    Last Post: 12-20-2001, 11:08 PM

Tags for this Thread