@@ -50,30 +50,18 @@ class AhdEnvelope
5050public:
5151 struct Parameters
5252 {
53- <<<<<<< HEAD
54- float attack = 0 .015f ;
55- float hold = 0 .08f ;
56- float decay = 0 .5f ;
57-
58- float attackSkew = 0 ;
59- float decaySkew = 10 ;
60- =======
6153 bool enabled = true ;
6254 float attack = 0 .015f ;
6355 float hold = 0 .08f ;
6456 float decay = 0 .5f ;
6557 float attackBend = 0 ;
6658 float decayBend = 0 ;
6759 float depth = 1 .0f ;
68- >>>>>>> a5e5c670fddd956080480f24e1397fa5872f9993
6960 };
7061
7162 enum class State
7263 {
73- <<<<<<< HEAD
74- =======
7564 Disabled,
76- >>>>>>> a5e5c670fddd956080480f24e1397fa5872f9993
7765 Attack,
7866 Hold,
7967 Decay,
@@ -82,8 +70,6 @@ class AhdEnvelope
8270
8371 constexpr AhdEnvelope () noexcept = default;
8472
85- <<<<<<< HEAD
86- =======
8773 inline void setParameters (const juce::AudioProcessorValueTreeState& apvts,
8874 juce::String prefix) noexcept
8975 {
@@ -98,7 +84,6 @@ class AhdEnvelope
9884 params.depth = apvts.getRawParameterValue (base + " Depth" )->load ();
9985 }
10086
101- >>>>>>> a5e5c670fddd956080480f24e1397fa5872f9993
10287 /* *
10388 * @brief Set the envelope parameters.
10489 * @param _newParams The new parameters to set.
@@ -109,16 +94,13 @@ class AhdEnvelope
10994 }
11095
11196 /* *
112- <<<<<<< HEAD
113- =======
11497 * @brief Get the Parameters object
11598 *
11699 * @return The current Parameters object
117100 */
118101 inline Parameters getParameters () const noexcept { return params; }
119102
120103 /* *
121- >>>>>>> a5e5c670fddd956080480f24e1397fa5872f9993
122104 * @brief Set the sample rate.
123105 * @param _newSampleRate The new sample rate to set.
124106 */
@@ -138,21 +120,13 @@ class AhdEnvelope
138120 */
139121 [[nodiscard]] inline State getState () const noexcept
140122 {
141- <<<<<<< HEAD
142- if (sampleIndex < getHoldStart ()) [[likely]]
143- return State::Attack;
144- if (sampleIndex < getDecayStart ()) [[likely]]
145- return State::Hold;
146- if (sampleIndex < getDecayEnd ()) [[likely]]
147- =======
148123 if (!params.enabled )
149124 return State::Disabled;
150125 if (sampleIndex < getHoldStart ())
151126 return State::Attack;
152127 if (sampleIndex < getDecayStart ())
153128 return State::Hold;
154129 if (sampleIndex < getDecayEnd ())
155- >>>>>>> a5e5c670fddd956080480f24e1397fa5872f9993
156130 return State::Decay;
157131 return State::Idle;
158132 }
@@ -181,58 +155,29 @@ class AhdEnvelope
181155 constexpr float zero = 0 .0f ;
182156
183157 switch (_state) {
184- <<<<<<< HEAD
185- case State::Attack: {
186- const float normalizedPosition =
187- static_cast <float >(sampleIndex) / sampleRate;
188- const float skew = getSkew (State::Attack);
189- return std::pow (normalizedPosition / params.attack , skew);
190- =======
191158 case State::Disabled:
192159 return 0 .0f ;
193160 case State::Attack: {
194161 const float normalizedPosition =
195162 static_cast <float >(sampleIndex) / sampleRate;
196163 const float phaseProgress = normalizedPosition / params.attack ;
197164 return applyAtanBend (phaseProgress, params.attackBend );
198- >>>>>>> a5e5c670fddd956080480f24e1397fa5872f9993
199165 }
200166 case State::Hold:
201167 return one;
202168 case State::Decay: {
203169 const float decayStart = static_cast <float >(getDecayStart ());
204170 const float normalizedPosition =
205171 (static_cast <float >(sampleIndex) - decayStart) / sampleRate;
206- <<<<<<< HEAD
207- const float skew = getSkew (State::Decay);
208- return one - std::pow (normalizedPosition / params.decay , skew);
209- =======
210172 const float phaseProgress = normalizedPosition / params.decay ;
211173 return one - applyAtanBend (phaseProgress, params.decayBend );
212- >>>>>>> a5e5c670fddd956080480f24e1397fa5872f9993
213174 }
214175 default :
215176 return zero;
216177 }
217178 }
218179
219180 /* *
220- <<<<<<< HEAD
221- * @brief Get the skew value for the given state.
222- * @param _state The current state of the envelope.
223- * @return The skew value.
224- */
225- [[nodiscard]] inline float getSkew (const State _state) const noexcept
226- {
227- switch (_state) {
228- case State::Attack:
229- return dmt::math::linearToExponent (params.attackSkew );
230- case State::Decay:
231- return dmt::math::linearToExponent (-params.decaySkew );
232- default :
233- return 1 .0f ;
234- }
235- =======
236181 * @brief Apply atan-based bend to normalized phase in range [0, 1].
237182 */
238183 [[nodiscard]] static inline float applyAtanBend (float normalizedPhase,
@@ -256,7 +201,6 @@ class AhdEnvelope
256201
257202 // Negative bend
258203 return 1 .0f - (atan (k * (1 .0f - x)) / normalizer);
259- >>>>>>> a5e5c670fddd956080480f24e1397fa5872f9993
260204 }
261205
262206 /* *
0 commit comments