/[svn]/linuxsampler/trunk/src/common/RTMath.h
ViewVC logotype

Diff of /linuxsampler/trunk/src/common/RTMath.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2931 by schoenebeck, Sat Jul 9 14:38:33 2016 UTC revision 3054 by schoenebeck, Thu Dec 15 12:47:45 2016 UTC
# Line 44  enum implementation_t { Line 44  enum implementation_t {
44  class RTMathBase {  class RTMathBase {
45      public:      public:
46          /**          /**
47           * Highly accurate time stamp.           * High resolution time stamp.
48           */           */
49          typedef uint32_t time_stamp_t;          typedef uint32_t time_stamp_t;
50    
51            typedef uint64_t usecs_t;
52    
53          /**          /**
54           * We read the processor's cycle count register as a reference           * We read the processor's cycle count register as a reference
55           * for the real time. These are of course only abstract values           * for the real time. These are of course only abstract values
56           * with arbitrary time entity, but that's not a problem as long           * with arbitrary time entity, but that's not a problem as long
57           * as we calculate relatively.           * as we calculate relatively.
58             *
59             * @see unsafeMicroSeconds()
60           */           */
61          static time_stamp_t CreateTimeStamp();          static time_stamp_t CreateTimeStamp();
62    
# Line 119  class RTMathBase { Line 123  class RTMathBase {
123           * @param n - amount of sample values applied so far           * @param n - amount of sample values applied so far
124           * @returns new average value of all summed values (including the new @a sample)           * @returns new average value of all summed values (including the new @a sample)
125           */           */
126          inline static float RelativeSummedAvg(float current, float sample, int n) {          template<typename T_int>
127            inline static float RelativeSummedAvg(float current, float sample, T_int n) {
128              return current + (sample - current) / float(n);              return current + (sample - current) / float(n);
129          }          }
130    
131            /**
132             * Clock source to use for getting the current time.
133             */
134            enum clock_source_t {
135                real_clock,    ///< Use this to measure time that passed in reality (no matter if process got suspended).
136                process_clock, ///< Use this to measure only the CPU execution time of the current process (if the process got suspended, the clock is paused as well).
137                thread_clock,  ///< Use this to measure only the CPU execution time of the current thread (if the process got suspended or another thread is executed, the clock is paused as well).
138            };
139    
140            /**
141             * Returns a time stamp of the current time in microseconds (in
142             * probably real-time @b unsafe way). There is no guarantee about
143             * what the returned amount of microseconds relates to (i.e.
144             * microseconds since epoch, microseconds since system uptime, ...).
145             * So you should only use it to calculate time differences between
146             * values taken with this method.
147             *
148             * @b CAUTION: This method may not @b NOT be real-time safe! On some
149             * systems it could be RT safe, but there is no guarantee whatsoever!
150             * So this method should only be used for debugging, benchmarking and
151             * other developing purposes !
152             *
153             * For creating time stamps in real-time context, use
154             * CreateTimeStamp() instead.
155             *
156             * @param source - the actual clock to use for getting the current
157             *                 time, note that the various clock sources may not
158             *                 be implemented on all systems
159             * @returns time stamp in microseconds
160             *
161             * @see CreateTimeStamp()
162             */
163            static usecs_t unsafeMicroSeconds(clock_source_t source);
164    
165      private:      private:
166          static float* pCentsToFreqTable;          static float* pCentsToFreqTable;
167    

Legend:
Removed from v.2931  
changed lines
  Added in v.3054

  ViewVC Help
Powered by ViewVC