z_dsp.h typedefs


    Dec 12 2006 | 7:14 pm
    Hi there,
    reading source code from externals in the SDK and from 3rd party objects, I often find sample vectors in perform routines define as t_float or even t_sample. Also all myobject_dsp() methods pass vectors as t_int.
    I noticed they are types defined in z_dsp.h and I have always been wondering about them.
    It's not a big deal, but I am wondering if to be correct and maybe avoid rewrites in the future, are we supposed to use those typedefs in our perform methods or are they there only as a historical heritage from PD?
    Could somebody take 2 mins and explain?
    Thanks so much.
    - Luigi
    ------------------------------------------------------------ THIS E-MAIL MESSAGE IS FOR THE SOLE USE OF THE INTENDED RECIPIENT AND MAY CONTAIN CONFIDENTIAL AND/OR PRIVILEGED INFORMATION. ANY UNAUTHORIZED REVIEW, USE, DISCLOSURE OR DISTRIBUTION IS PROHIBITED. IF YOU ARE NOT THE INTENDED RECIPIENT, CONTACT THE SENDER BY E-MAIL AT SUPERBIGIO@YAHOO.COM AND DESTROY ALL COPIES OF THE ORIGINAL MESSAGE. WITHOUT PREJUDICE UCC1-207. ------------------------------------------------------------
    Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail beta. http://new.mail.yahoo.com

    • Dec 14 2006 | 10:36 am
      On 12-Dec-2006, at 20:14, Luigi Castelli wrote:
      > reading source code from externals in the SDK and from > 3rd party objects, I often find sample vectors in > perform routines define as t_float or even t_sample.
      I suppose it's good form to use t_sample as an abstract data type (although I personally hate underscores in identifiers, but I'll skip the rant).
      The idea is that if you have a compiler that interprets float as something other than 32-bit IEEE, you can conditionally compile the typedef t_sample statment to something that _is_ 32-bit IEEE.
      There is also the notion that when you use an abstract data type like t_sample, if some day MSP decides to switch to 128-bit samples or something, it would just take one change in z_dsp.h and--hey presto!-- all code would automatically recompile correctly. In practice there are so many interdependencies in MSP externals, partly because not everyone uses t_sample%-, that a change to any of the basic data type conventions has something like probability lim(x->inf) of 1/x.
      > Also all myobject_dsp() methods pass vectors as t_int.
      Do you mean your calls to dsp_add()? The prototyped function signature uses the ellipsis (...) convention, so there's no need to typecast anything to anything else, just as long as your vector addresses go in as the 32-bit values the MSP API expects.
      Actually, I'd avoid using t_int for this purpose because the C spec doesn't guarantee int to be 32-bit, and t_int is simply typedef'd to int. However, any compiler you're likely to use will implement int as 32-bit, so it's mainly a theoretical problem.
      Two minutes are up.-
      -------------- http://www.bek.no/~pcastine/Litter/ ------------- Peter Castine +--> Litter Power & Litter Bundle for Jitter Universal Binaries on the way iCE: Sequencing, Recording & Interface Building for |home | chez nous| Max/MSP Extremely cool |bei uns | i nostri| http://www.dspaudio.com/ http://www.castine.de