-
-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2cfbe0e
commit 3b4f0f0
Showing
3 changed files
with
97 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,36 @@ | ||
#pragma once | ||
#include <argon.hpp> | ||
#include <cstddef> | ||
|
||
namespace deluge::dsp::interpolated { | ||
class Parameter { | ||
public: | ||
Parameter(float& state, float new_value, size_t size) | ||
: state_(state), value_(new_value), increment_((new_value - state) / static_cast<float>(size)) {} | ||
Parameter(float old_value, float new_value, size_t size) | ||
: value_(old_value), target_(new_value), increment_((new_value - old_value) / static_cast<float>(size)) {} | ||
|
||
constexpr float Next() { | ||
if (value_ >= target_) { | ||
return target_; | ||
} | ||
value_ += increment_; | ||
return value_; | ||
} | ||
|
||
constexpr Argon<float> NextSIMD() { | ||
Argon<float> value = Argon{value_}.MultiplyAdd(increment_, {1.f, 2.f, 3.f, 4.f}); | ||
value = (((value <= target_) & value.As<uint32_t>()) // keep lanes less than or equal to target | ||
| ((value > target_) & Argon{target_}.As<uint32_t>())) // replace lanes greater than target with target | ||
.As<float>(); | ||
|
||
value_ = value.LastLane(); | ||
return value; | ||
} | ||
|
||
constexpr float subsample(float t) { return value_ + (increment_ * t); } | ||
|
||
private: | ||
float& state_; | ||
float value_; | ||
float target_; | ||
float increment_; | ||
}; | ||
} // namespace deluge::dsp::interpolated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters