Filter shortcut by relative formula
This commit is contained in:
parent
47a8030e86
commit
e574aeb592
2 changed files with 11 additions and 1 deletions
|
|
@ -103,6 +103,10 @@ namespace config {
|
|||
Background file loading
|
||||
*/
|
||||
static constexpr int backgroundLoaderPthreadPriority = 50; // expressed in %
|
||||
/**
|
||||
@brief Ratio to target under which smoothing is considered as completed
|
||||
*/
|
||||
static constexpr float smoothingShortcutThreshold = 5e-3;
|
||||
} // namespace config
|
||||
|
||||
} // namespace sfz
|
||||
|
|
|
|||
|
|
@ -31,7 +31,13 @@ void Smoother::process(absl::Span<const float> input, absl::Span<float> output,
|
|||
if (input.size() == 0)
|
||||
return;
|
||||
|
||||
if (canShortcut && std::abs(input.front() - current()) < config::virtuallyZero) {
|
||||
if (canShortcut) {
|
||||
float in = input.front();
|
||||
float rel = std::abs(in - current()) / (std::abs(in) + config::virtuallyZero);
|
||||
canShortcut = rel < config::smoothingShortcutThreshold;
|
||||
}
|
||||
|
||||
if (canShortcut) {
|
||||
if (input.data() != output.data())
|
||||
copy<float>(input, output);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue