OSC-timetag.h

Go to the documentation of this file.
00001 /*
00002 Copyright  1998. The Regents of the University of California (Regents). 
00003 All Rights Reserved.
00004 
00005 Written by Matt Wright, The Center for New Music and Audio Technologies,
00006 University of California, Berkeley.
00007 
00008 Permission to use, copy, modify, distribute, and distribute modified versions
00009 of this software and its documentation without fee and without a signed
00010 licensing agreement, is hereby granted, provided that the above copyright
00011 notice, this paragraph and the following two paragraphs appear in all copies,
00012 modifications, and distributions.
00013 
00014 IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
00015 SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING
00016 OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS
00017 BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00018 
00019 REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
00020 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00021 PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED
00022 HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE
00023 MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
00024 
00025 The OpenSound Control WWW page is 
00026     http://www.cnmat.berkeley.edu/OpenSoundControl
00027 */
00028 
00029 
00030 /*
00031  OSC_timeTag.h: library for manipulating OSC time tags
00032  Matt Wright, 5/29/97
00033 
00034  Time tags in OSC have the same format as in NTP: 64 bit fixed point, with the
00035  top 32 bits giving number of seconds sinve midnight 1/1/1900 and the bottom
00036  32 bits giving fractional parts of a second.  We represent this by an 8-byte
00037  unsigned long if possible, or else a struct. 
00038 
00039  NB: On many architectures with 8-byte ints, it's illegal (like maybe a bus error)
00040  to dereference a pointer to an 8 byte int that's not 8-byte aligned.  
00041 */
00042 
00043 #ifndef OSC_TIMETAG
00044 #define OSC_TIMETAG
00045 
00046 //#ifdef __sgi
00047     #define HAS8BYTEINT
00048 //#endif
00049 
00050 
00051 #ifdef HAS8BYTEINT
00052     typedef long long int8;
00053     typedef unsigned long long uint8;
00054     typedef unsigned long uint4;
00055     typedef uint8 OSCTimeTag;
00056 #else
00057     typedef unsigned int uint4;
00058     typedef struct {
00059         uint4 seconds;
00060         uint4 fraction;
00061     } OSCTimeTag;
00062 #endif
00063 
00064 
00065 
00066 /* Return a time tag representing the current time (as of when this
00067    procedure is called). */
00068 OSCTimeTag OSCTT_CurrentTime(void);
00069 
00070 /* Return the time tag 0x0000000000000001, indicating to the receiving device
00071    that it should process the message immediately. */
00072 OSCTimeTag OSCTT_Immediately(void);
00073 
00074 /* Return the time tag 0xffffffffffffffff, a time so far in the future that
00075    it's effectively infinity. */
00076 OSCTimeTag OSCTT_BiggestPossibleTimeTag(void);
00077 
00078 /* Given a time tag and a number of seconds to add to the time tag, return
00079    the new time tag */
00080 OSCTimeTag OSCTT_PlusSeconds(OSCTimeTag original, float secondsOffset);
00081 
00082 /* Compare two time tags.  Return negative if first is < second, 0 if
00083    they're equal, and positive if first > second. */
00084 int OSCTT_Compare(OSCTimeTag left, OSCTimeTag right);
00085 
00086 #endif /*  OSC_TIMETAG */

Generated on Thu Sep 17 23:14:15 2009 for CSL by  doxygen 1.5.8