Differentiate between gnoise and noise in generators
This commit is contained in:
parent
17a64cc665
commit
c2dbd8929a
3 changed files with 17 additions and 3 deletions
|
|
@ -78,6 +78,7 @@ namespace config {
|
|||
constexpr int filtersPerVoice { 2 };
|
||||
constexpr int eqsPerVoice { 3 };
|
||||
constexpr int oscillatorsPerVoice { 9 };
|
||||
constexpr float uniformNoiseBounds { 0.25f };
|
||||
constexpr float noiseVariance { 0.25f };
|
||||
/**
|
||||
Minimum interval in frames between recomputations of coefficients of the
|
||||
|
|
|
|||
|
|
@ -609,8 +609,20 @@ void sfz::Voice::fillWithGenerator(AudioSpan<float> buffer) noexcept
|
|||
const auto rightSpan = buffer.getSpan(1);
|
||||
|
||||
if (region->sampleId.filename() == "*noise") {
|
||||
absl::c_generate(leftSpan, noiseDist);
|
||||
absl::c_generate(rightSpan, noiseDist);
|
||||
auto gen = [&]() {
|
||||
return uniformNoiseDist(Random::randomGenerator);
|
||||
};
|
||||
absl::c_generate(leftSpan, gen);
|
||||
absl::c_generate(rightSpan, gen);
|
||||
} else if (region->sampleId.filename() == "*gnoise") {
|
||||
// You need to wrap in a lambda, otherwise generate will
|
||||
// make a copy of the gaussian distribution *along with its state*
|
||||
// leading to periodic behavior....
|
||||
auto gen = [&]() {
|
||||
return gaussianNoiseDist();
|
||||
};
|
||||
absl::c_generate(leftSpan, gen);
|
||||
absl::c_generate(rightSpan, gen);
|
||||
} else {
|
||||
const auto numFrames = buffer.getNumFrames();
|
||||
|
||||
|
|
|
|||
|
|
@ -467,7 +467,8 @@ private:
|
|||
Voice* nextSisterVoice { this };
|
||||
Voice* previousSisterVoice { this };
|
||||
|
||||
fast_gaussian_generator<float> noiseDist { 0.0f, config::noiseVariance };
|
||||
fast_real_distribution<float> uniformNoiseDist { -config::uniformNoiseBounds, config::uniformNoiseBounds };
|
||||
fast_gaussian_generator<float> gaussianNoiseDist { 0.0f, config::noiseVariance };
|
||||
|
||||
ModifierArray<std::vector<Smoother>> modifierSmoothers;
|
||||
Smoother gainSmoother;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue