Merge pull request #452 from jpcima/fil-random

Make all the random opcodes bipolar
This commit is contained in:
JP Cimalando 2020-09-27 19:08:43 +02:00 committed by GitHub
commit cf90794dab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 9 additions and 11 deletions

View file

@ -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<float> filterGainRange { -96.0f, 96.0f };
constexpr Range<float> filterGainModRange { -96.0f, 96.0f };
constexpr Range<int> filterKeytrackRange { 0, 1200 };
constexpr Range<int> filterRandomRange { 0, 9600 };
constexpr Range<float> filterRandomRange { 0, 9600 };
constexpr Range<int> filterVeltrackRange { -9600, 9600 };
constexpr Range<float> filterResonanceRange { 0.0f, 96.0f };
constexpr Range<float> filterResonanceModRange { 0.0f, 96.0f };
@ -199,8 +199,8 @@ namespace Default
constexpr uint8_t pitchKeycenter { 60 };
constexpr int pitchKeytrack { 100 };
constexpr Range<int> pitchKeytrackRange { -1200, 1200 };
constexpr int pitchRandom { 0 };
constexpr Range<int> pitchRandomRange { 0, 9600 };
constexpr float pitchRandom { 0 };
constexpr Range<float> pitchRandomRange { 0, 9600 };
constexpr int pitchVeltrack { 0 };
constexpr Range<int> pitchVeltrackRange { -9600, 9600 };
constexpr int transpose { 0 };

View file

@ -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 };
};
}

View file

@ -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<float> dist { -description->random, description->random };
baseCutoff *= centsFactor(dist(Random::randomGenerator));
}
const auto keytrack = description->keytrack * (noteNumber - description->keycenter);
baseCutoff *= centsFactor(keytrack);

View file

@ -54,8 +54,6 @@ private:
ModMatrix::TargetId cutoffTarget;
ModMatrix::TargetId resonanceTarget;
bool prepared { false };
using filterRandomDist = std::uniform_int_distribution<int>;
filterRandomDist dist { 0, sfz::Default::filterRandom };
};
}

View file

@ -1714,7 +1714,7 @@ float sfz::Region::getBasePitchVariation(float noteNumber, float velocity) const
{
ASSERT(velocity >= 0.0f && velocity <= 1.0f);
std::uniform_int_distribution<int> pitchDistribution { -pitchRandom, pitchRandom };
fast_real_distribution<float> pitchDistribution { -pitchRandom, pitchRandom };
auto pitchVariationInCents = pitchKeytrack * (noteNumber - pitchKeycenter); // note difference with pitch center
pitchVariationInCents += tune; // sample tuning
pitchVariationInCents += config::centPerSemitone * transpose; // sample transpose

View file

@ -409,7 +409,7 @@ struct Region {
uint8_t pitchKeycenter { Default::pitchKeycenter }; // pitch_keycenter
bool pitchKeycenterFromSample { false };
int pitchKeytrack { Default::pitchKeytrack }; // pitch_keytrack
int pitchRandom { Default::pitchRandom }; // pitch_random
float pitchRandom { Default::pitchRandom }; // pitch_random
int pitchVeltrack { Default::pitchVeltrack }; // pitch_veltrack
int transpose { Default::transpose }; // transpose
int tune { Default::tune }; // tune