OpenShot Audio Library | OpenShotAudio: juce_Phase.h Source File

OpenShot Audio Library | OpenShotAudio 0.3.1

Loading...
Searching...
No Matches
juce_Phase.h
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2017 - ROLI Ltd.
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 5 End-User License
11 Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
12 27th April 2017).
13
14 End User License Agreement: www.juce.com/juce-5-licence
15 Privacy Policy: www.juce.com/juce-5-privacy-policy
16
17 Or: You may also use this code under the terms of the GPL v3 (see
18 www.gnu.org/licenses).
19
20 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
21 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
22 DISCLAIMED.
23
24 ==============================================================================
25*/
26
27namespace juce
28{
29namespace dsp
30{
31
40template <typename Type>
41 struct Phase
42{
44 void reset() noexcept { phase = 0; }
45
50 Type advance (Type increment) noexcept
51 {
52 jassert (increment >= 0); // cannot run this value backwards!
53
54 auto last = phase;
55 auto next = last + increment;
56
57 while (next >= MathConstants<Type>::twoPi)
58 next -= MathConstants<Type>::twoPi;
59
60 phase = next;
61 return last;
62 }
63
64 Type phase = 0;
65};
66
67} // namespace dsp
68} // namespace juce
juce::MathConstants
Definition: juce_MathsFunctions.h:363
juce::dsp::Phase
Definition: juce_Phase.h:42
juce::dsp::Phase::reset
void reset() noexcept
Definition: juce_Phase.h:44
juce::dsp::Phase::advance
Type advance(Type increment) noexcept
Definition: juce_Phase.h:50