1 /* 2 ============================================================================== 3 4 This file is part of the JUCE library. 5 Copyright (c) 2020 - Raw Material Software Limited 6 7 JUCE is an open source library subject to commercial or open-source 8 licensing. 9 10 By using JUCE, you agree to the terms of both the JUCE 6 End-User License 11 Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020). 12 13 End User License Agreement: www.juce.com/juce-6-licence 14 Privacy Policy: www.juce.com/juce-privacy-policy 15 16 Or: You may also use this code under the terms of the GPL v3 (see 17 www.gnu.org/licenses). 18 19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER 20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE 21 DISCLAIMED. 22 23 ============================================================================== 24 */ 25 26 namespace juce 27 { 28 29 //============================================================================== 30 /** 31 An OSC time tag. 32 33 OSC time tags are part of OSCBundle objects. 34 35 In accordance with the OSC 1.0 specification, the internal timestamp stored in 36 OSCTimeTag uses the same binary format as NTP timestamps. The representation 37 is by a 64 bit fixed point number. The first 32 bits specify the number of 38 seconds since midnight on January 1, 1900, and the last 32 bits specify 39 fractional parts of a second to a precision of about 200 picoseconds. 40 41 The time tag value consisting of 63 zero bits followed by a one in the least 42 significant bit is a special case meaning "immediately". 43 44 For a more user-friendly time format, convert OSCTimeTag to a juce::Time object 45 using toTime(). 46 47 @tags{OSC} 48 */ 49 class JUCE_API OSCTimeTag 50 { 51 public: 52 //============================================================================== 53 /** Default constructor. 54 Constructs an OSCTimeTag object with the special value representing "immediately". 55 */ 56 OSCTimeTag() noexcept; 57 58 /** Constructs an OSCTimeTag object from a raw binary OSC time tag. */ 59 OSCTimeTag (uint64 rawTimeTag) noexcept; 60 61 /** Constructs an OSCTimeTag object from a juce::Time object. */ 62 OSCTimeTag (Time time) noexcept; 63 64 /** Returns a juce::Time object representing the same time as the OSCTimeTag. 65 66 If the OSCTimeTag has the special value representing "immediately", the 67 resulting juce::Time object will represent an arbitrary point of time (but 68 guaranteed to be in the past), since juce::Time does not have such a special value. 69 */ 70 Time toTime() const noexcept; 71 72 /** Returns true if the OSCTimeTag object has the special value representing "immediately". */ 73 bool isImmediately() const noexcept; 74 75 /** Returns the raw binary OSC time tag representation. */ getRawTimeTag()76 uint64 getRawTimeTag() const noexcept { return rawTimeTag; } 77 78 /** The special value representing "immediately". */ 79 static const OSCTimeTag immediately; 80 81 private: 82 //============================================================================== 83 uint64 rawTimeTag; 84 }; 85 86 } // namespace juce 87