From 283a7a39c74dfb02aad3f2d5624e6a610f9d019e Mon Sep 17 00:00:00 2001 From: Jean Pierre Cimalando Date: Sun, 27 Sep 2020 15:34:12 +0200 Subject: [PATCH] Make filN_random real-valued, and bipolar --- src/sfizz/Defaults.h | 4 ++-- src/sfizz/FilterDescription.h | 2 +- src/sfizz/FilterPool.cpp | 4 ++-- src/sfizz/FilterPool.h | 2 -- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/sfizz/Defaults.h b/src/sfizz/Defaults.h index 1550e749..e0ba851b 100644 --- a/src/sfizz/Defaults.h +++ b/src/sfizz/Defaults.h @@ -160,7 +160,7 @@ namespace Default constexpr float filterGain { 0 }; constexpr int filterKeytrack { 0 }; constexpr uint8_t filterKeycenter { 60 }; - constexpr int filterRandom { 0 }; + constexpr float filterRandom { 0 }; constexpr int filterVeltrack { 0 }; constexpr float filterCutoffCC { 0 }; constexpr float filterResonanceCC { 0 }; @@ -170,7 +170,7 @@ namespace Default constexpr Range filterGainRange { -96.0f, 96.0f }; constexpr Range filterGainModRange { -96.0f, 96.0f }; constexpr Range filterKeytrackRange { 0, 1200 }; - constexpr Range filterRandomRange { 0, 9600 }; + constexpr Range filterRandomRange { 0, 9600 }; constexpr Range filterVeltrackRange { -9600, 9600 }; constexpr Range filterResonanceRange { 0.0f, 96.0f }; constexpr Range filterResonanceModRange { 0.0f, 96.0f }; diff --git a/src/sfizz/FilterDescription.h b/src/sfizz/FilterDescription.h index f78b80d3..2f3193a0 100644 --- a/src/sfizz/FilterDescription.h +++ b/src/sfizz/FilterDescription.h @@ -20,7 +20,7 @@ struct FilterDescription int keytrack { Default::filterKeytrack }; uint8_t keycenter { Default::filterKeycenter }; int veltrack { Default::filterVeltrack }; - int random { Default::filterRandom }; + float random { Default::filterRandom }; FilterType type { FilterType::kFilterLpf2p }; }; } diff --git a/src/sfizz/FilterPool.cpp b/src/sfizz/FilterPool.cpp index c5eadcef..2463e721 100644 --- a/src/sfizz/FilterPool.cpp +++ b/src/sfizz/FilterPool.cpp @@ -30,8 +30,8 @@ void sfz::FilterHolder::setup(const Region& region, unsigned filterId, int noteN // Setup the base values baseCutoff = description->cutoff; if (description->random != 0) { - dist.param(filterRandomDist::param_type(0, description->random)); - baseCutoff *= centsFactor(dist(Random::randomGenerator)); + fast_real_distribution dist { -description->random, description->random }; + baseCutoff *= centsFactor(dist(Random::randomGenerator)); } const auto keytrack = description->keytrack * (noteNumber - description->keycenter); baseCutoff *= centsFactor(keytrack); diff --git a/src/sfizz/FilterPool.h b/src/sfizz/FilterPool.h index f11ede24..76074a0c 100644 --- a/src/sfizz/FilterPool.h +++ b/src/sfizz/FilterPool.h @@ -54,8 +54,6 @@ private: ModMatrix::TargetId cutoffTarget; ModMatrix::TargetId resonanceTarget; bool prepared { false }; - using filterRandomDist = std::uniform_int_distribution; - filterRandomDist dist { 0, sfz::Default::filterRandom }; }; }