OpenShot Library | OpenShotAudio  0.2.2
juce_AudioProcessLoadMeasurer.h
1 
2 /** @weakgroup juce_audio_basics-buffers
3  * @{
4  */
5 /*
6  ==============================================================================
7 
8  This file is part of the JUCE library.
9  Copyright (c) 2017 - ROLI Ltd.
10 
11  JUCE is an open source library subject to commercial or open-source
12  licensing.
13 
14  By using JUCE, you agree to the terms of both the JUCE 5 End-User License
15  Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
16  27th April 2017).
17 
18  End User License Agreement: www.juce.com/juce-5-licence
19  Privacy Policy: www.juce.com/juce-5-privacy-policy
20 
21  Or: You may also use this code under the terms of the GPL v3 (see
22  www.gnu.org/licenses).
23 
24  JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
25  EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
26  DISCLAIMED.
27 
28  ==============================================================================
29 */
30 
31 namespace juce
32 {
33 
34 //==============================================================================
35 /**
36  Maintains an ongoing measurement of the proportion of time which is being
37  spent inside an audio callback.
38 
39  @tags{Audio}
40 */
42 {
43 public:
44  /** */
46 
47  /** Destructor. */
49 
50  //==============================================================================
51  /** Resets the state. */
52  void reset();
53 
54  /** Resets the counter, in preparation for use with the given sample rate and block size. */
55  void reset (double sampleRate, int blockSize);
56 
57  /** Returns the current load as a proportion 0 to 1.0 */
58  double getLoadAsProportion() const;
59 
60  /** Returns the current load as a percentage 0 to 100.0 */
61  double getLoadAsPercentage() const;
62 
63  /** Returns the number of over- (or under-) runs recorded since the state was reset. */
64  int getXRunCount() const;
65 
66  //==============================================================================
67  /** This class measures the time between its construction and destruction and
68  adds it to an AudioProcessLoadMeasurer.
69 
70  e.g.
71  @code
72  {
73  AudioProcessLoadMeasurer::ScopedTimer timer (myProcessLoadMeasurer);
74  myCallback->doTheCallback();
75  }
76  @endcode
77 
78  @tags{Audio}
79  */
81  {
83  ~ScopedTimer();
84 
85  private:
87  double startTime;
88 
89  JUCE_DECLARE_NON_COPYABLE (ScopedTimer)
90  };
91 
92  /** Can be called manually to add the time of a callback to the stats.
93  Normally you probably would never call this - it's simpler and more robust to
94  use a ScopedTimer to measure the time using an RAII pattern.
95  */
96  void registerBlockRenderTime (double millisecondsTaken);
97 
98 private:
99  double cpuUsageMs = 0, timeToCpuScale = 0, msPerBlock = 0;
100  int xruns = 0;
101 };
102 
103 
104 } // namespace juce
105 
106 /** @}*/
Maintains an ongoing measurement of the proportion of time which is being spent inside an audio callb...
#define JUCE_API
This macro is added to all JUCE public class declarations.
This class measures the time between its construction and destruction and adds it to an AudioProcessL...