Krotos Modules 3
Loading...
Searching...
No Matches
MuteValueGenerator.h
Go to the documentation of this file.
1#pragma once
2
3namespace krotos
4{
6 {
7 public:
12 inline void setMuteDirection(bool requestMute) { m_requestMute = requestMute; }
13
18 inline bool isFullyMuted() { return m_requestMute && m_muteValue == 0.0f; }
19
25 inline void reset(float sampleRate, float rampLengthInSeconds)
26 {
27 jassert(sampleRate > 0 && rampLengthInSeconds >= 0);
28 m_muteDelta = 1.0f / (sampleRate * rampLengthInSeconds);
29 }
30
35 inline bool calculateNextValue()
36 {
37 if (m_requestMute) // Heading down
38 {
40 if (m_muteValue <= 0.0f) // Reached 0.0
41 {
42 m_muteValue = 0.0f; // Never go below 0.0
43 return true;
44 }
45 }
46 else // Heading up
47 {
49 if (m_muteValue >= 1.0f) // Reached 1.0
50 {
51 m_muteValue = 1.0f; // Never go above 1.0
52 }
53 }
54 return false;
55 }
56
61 float getValue() { return m_muteValue; }
62
63 private:
64 float m_muteValue{1.0f};
65 float m_muteDelta{0.001f};
66 bool m_requestMute{false};
67 };
68} // namespace krotos
Definition MuteValueGenerator.h:6
float m_muteValue
Definition MuteValueGenerator.h:64
float m_muteDelta
Definition MuteValueGenerator.h:65
bool m_requestMute
Definition MuteValueGenerator.h:66
bool calculateNextValue()
Calculate the next mute value.
Definition MuteValueGenerator.h:35
void reset(float sampleRate, float rampLengthInSeconds)
Reset to a new sample rate and ramp length.
Definition MuteValueGenerator.h:25
float getValue()
Returns the current mute value.
Definition MuteValueGenerator.h:61
void setMuteDirection(bool requestMute)
Set mute direction.
Definition MuteValueGenerator.h:12
bool isFullyMuted()
Query whether mute is fully muted or not.
Definition MuteValueGenerator.h:18
Definition AirAbsorptionFilter.cpp:2