The filters have to be initialized with samplerate
This commit is contained in:
parent
2acd8f45a3
commit
d3592214b1
3 changed files with 27 additions and 2 deletions
|
|
@ -59,7 +59,7 @@ void sfz::FilterHolder::process(const float** inputs, float** outputs, unsigned
|
||||||
|
|
||||||
lastGain = baseGain;
|
lastGain = baseGain;
|
||||||
for (auto& mod: description->gainCC) {
|
for (auto& mod: description->gainCC) {
|
||||||
lastResonance += midiState.getCCValue(mod.first) * mod.second;
|
lastGain += midiState.getCCValue(mod.first) * mod.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
filter.process(inputs, outputs, lastCutoff, lastResonance, lastGain, numFrames);
|
filter.process(inputs, outputs, lastCutoff, lastResonance, lastGain, numFrames);
|
||||||
|
|
@ -132,3 +132,14 @@ size_t sfz::FilterPool::setNumFilters(size_t numFilters)
|
||||||
|
|
||||||
return filters.size();
|
return filters.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sfz::FilterPool::setSampleRate(float sampleRate)
|
||||||
|
{
|
||||||
|
for (auto& filter: filters)
|
||||||
|
filter->setSampleRate(sampleRate);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sfz::FilterHolder::setSampleRate(float sampleRate)
|
||||||
|
{
|
||||||
|
filter.init(static_cast<double>(sampleRate));
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,12 @@ public:
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
float getLastGain() const;
|
float getLastGain() const;
|
||||||
|
/**
|
||||||
|
* @brief Set the sample rate for a filter
|
||||||
|
*
|
||||||
|
* @param sampleRate
|
||||||
|
*/
|
||||||
|
void setSampleRate(float sampleRate);
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* Reset the filter. Is called internally when using setup().
|
* Reset the filter. Is called internally when using setup().
|
||||||
|
|
@ -103,10 +109,16 @@ public:
|
||||||
* @return size_t the actual number of filters in the pool
|
* @return size_t the actual number of filters in the pool
|
||||||
*/
|
*/
|
||||||
size_t setNumFilters(size_t numFilters);
|
size_t setNumFilters(size_t numFilters);
|
||||||
|
/**
|
||||||
|
* @brief Set the sample rate for all filters
|
||||||
|
*
|
||||||
|
* @param sampleRate
|
||||||
|
*/
|
||||||
|
void setSampleRate(float sampleRate);
|
||||||
private:
|
private:
|
||||||
std::atomic<bool> givingOutFilters { false };
|
std::atomic<bool> givingOutFilters { false };
|
||||||
std::atomic<bool> canGiveOutFilters { true };
|
std::atomic<bool> canGiveOutFilters { true };
|
||||||
|
float sampleRate { config::defaultSampleRate };
|
||||||
const MidiState& midiState;
|
const MidiState& midiState;
|
||||||
std::vector<FilterHolderPtr> filters;
|
std::vector<FilterHolderPtr> filters;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -401,6 +401,8 @@ void sfz::Synth::setSampleRate(float sampleRate) noexcept
|
||||||
this->sampleRate = sampleRate;
|
this->sampleRate = sampleRate;
|
||||||
for (auto& voice : voices)
|
for (auto& voice : voices)
|
||||||
voice->setSampleRate(sampleRate);
|
voice->setSampleRate(sampleRate);
|
||||||
|
|
||||||
|
resources.filterPool.setSampleRate(sampleRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sfz::Synth::renderBlock(AudioSpan<float> buffer) noexcept
|
void sfz::Synth::renderBlock(AudioSpan<float> buffer) noexcept
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue