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