OpenShot Library | libopenshot-audio
0.2.0
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
class
JUCE_API
AudioProcessLoadMeasurer
40
{
41
public
:
42
/** */
43
AudioProcessLoadMeasurer
();
44
45
/** Destructor. */
46
~AudioProcessLoadMeasurer
();
47
48
//==============================================================================
49
/** Resets the state. */
50
void
reset();
51
52
/** Resets the counter, in preparation for use with the given sample rate and block size. */
53
void
reset (
double
sampleRate,
int
blockSize);
54
55
/** Returns the current load as a proportion 0 to 1.0 */
56
double
getLoadAsProportion()
const
;
57
58
/** Returns the current load as a percentage 0 to 100.0 */
59
double
getLoadAsPercentage()
const
;
60
61
/** Returns the number of over- (or under-) runs recorded since the state was reset. */
62
int
getXRunCount()
const
;
63
64
//==============================================================================
65
/** This class measures the time between its construction and destruction and
66
adds it to an AudioProcessLoadMeasurer.
67
68
e.g.
69
@code
70
{
71
AudioProcessLoadMeasurer::ScopedTimer timer (myProcessLoadMeasurer);
72
myCallback->doTheCallback();
73
}
74
@endcode
75
*/
76
struct
JUCE_API
ScopedTimer
77
{
78
ScopedTimer
(
AudioProcessLoadMeasurer
&);
79
~ScopedTimer
();
80
81
private
:
82
AudioProcessLoadMeasurer
& owner;
83
double
startTime;
84
85
JUCE_DECLARE_NON_COPYABLE (
ScopedTimer
)
86
};
87
88
/** Can be called manually to add the time of a callback to the stats.
89
Normally you probably would never call this - it's simpler and more robust to
90
use a ScopedTimer to measure the time using an RAII pattern.
91
*/
92
void
registerBlockRenderTime (
double
millisecondsTaken
);
93
94
private
:
95
double
cpuUsageMs = 0, timeToCpuScale = 0, msPerBlock = 0;
96
int
xruns = 0;
97
};
98
99
100
}
// namespace juce
101
102
/** @}*/
juce::Array
Holds a resizable array of primitive or copy-by-value objects.
Definition
juce_Array.h:60
juce::AudioProcessLoadMeasurer
Maintains an ongoing measurement of the proportion of time which is being spent inside an audio callb...
Definition
juce_AudioProcessLoadMeasurer.h:40
JUCE_API
#define JUCE_API
This macro is added to all JUCE public class declarations.
Definition
juce_StandardHeader.h:143
juce::AudioProcessLoadMeasurer::ScopedTimer
This class measures the time between its construction and destruction and adds it to an AudioProcessL...
Definition
juce_AudioProcessLoadMeasurer.h:77
juce_audio_basics
buffers
juce_AudioProcessLoadMeasurer.h
Generated on Fri Sep 20 2024 04:11:05 for OpenShot Library | libopenshot-audio by
1.9.8