Final cleanups
This commit is contained in:
parent
81a4ed22eb
commit
cfae639d5f
6 changed files with 11 additions and 20 deletions
|
|
@ -143,7 +143,7 @@ void sfz::Oversampler::stream(AudioSpan<float> input, AudioSpan<float> output, s
|
|||
|
||||
void sfz::Oversampler::stream(AudioReader& input, AudioSpan<float> output, std::atomic<size_t>* framesReady)
|
||||
{
|
||||
ASSERT(output.getNumFrames() >= input.frames() * static_cast<int>(factor));
|
||||
ASSERT(output.getNumFrames() >= static_cast<size_t>(input.frames() * static_cast<int>(factor)));
|
||||
ASSERT(output.getNumChannels() == input.channels());
|
||||
|
||||
const auto numFrames = static_cast<size_t>(input.frames());
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@
|
|||
|
||||
namespace sfz {
|
||||
|
||||
struct Synth::Impl: public Parser::Listener {
|
||||
struct Synth::Impl final: public Parser::Listener {
|
||||
Impl();
|
||||
~Impl();
|
||||
|
||||
|
|
@ -241,9 +241,6 @@ struct Synth::Impl: public Parser::Listener {
|
|||
// These are more general "groups" than sfz and encapsulates the full hierarchy
|
||||
RegionSet* currentSet_ { nullptr };
|
||||
std::vector<RegionSetPtr> sets_;
|
||||
// This region set holds the engine set of voices, which tries to respect the required
|
||||
// engine polyphony
|
||||
RegionSetPtr engineSet_;
|
||||
|
||||
std::array<RegionViewVector, 128> lastKeyswitchLists_;
|
||||
std::array<RegionViewVector, 128> downKeyswitchLists_;
|
||||
|
|
@ -261,7 +258,6 @@ struct Synth::Impl: public Parser::Listener {
|
|||
float sampleRate_ { config::defaultSampleRate };
|
||||
float volume_ { Default::globalVolume };
|
||||
int numVoices_ { config::numVoices };
|
||||
int activeVoices_ { 0 };
|
||||
Oversampling oversamplingFactor_ { config::defaultOversamplingFactor };
|
||||
|
||||
// Distribution used to generate random value for the *rand opcodes
|
||||
|
|
@ -319,7 +315,6 @@ Synth::Impl::Impl()
|
|||
initializeSIMDDispatchers();
|
||||
|
||||
const std::lock_guard<SpinMutex> disableCallback { callbackGuard_ };
|
||||
engineSet_ = absl::make_unique<RegionSet>(nullptr, OpcodeScope::kOpcodeScopeGeneric);
|
||||
parser_.setListener(this);
|
||||
effectFactory_.registerStandardEffectTypes();
|
||||
effectBuses_.reserve(5); // sufficient room for main and fx1-4
|
||||
|
|
@ -1131,7 +1126,6 @@ void Synth::renderBlock(AudioSpan<float> buffer) noexcept
|
|||
}
|
||||
}
|
||||
|
||||
impl.activeVoices_ = 0;
|
||||
{ // Main render block
|
||||
ScopedTiming logger { callbackBreakdown.renderMethod, ScopedTiming::Operation::addToDuration };
|
||||
tempMixSpan->fill(0.0f);
|
||||
|
|
@ -1142,8 +1136,6 @@ void Synth::renderBlock(AudioSpan<float> buffer) noexcept
|
|||
|
||||
mm.beginVoice(voice.getId(), voice.getRegion()->getId(), voice.getTriggerEvent().value);
|
||||
|
||||
impl.activeVoices_++;
|
||||
|
||||
const Region* region = voice.getRegion();
|
||||
ASSERT(region != nullptr);
|
||||
|
||||
|
|
@ -1197,7 +1189,8 @@ void Synth::renderBlock(AudioSpan<float> buffer) noexcept
|
|||
}
|
||||
|
||||
callbackBreakdown.dispatch = impl.dispatchDuration_;
|
||||
impl.resources_.logger.logCallbackTime(callbackBreakdown, impl.activeVoices_, numFrames);
|
||||
impl.resources_.logger.logCallbackTime(
|
||||
callbackBreakdown, impl.voiceManager_.getNumActiveVoices(), numFrames);
|
||||
|
||||
// Reset the dispatch counter
|
||||
impl.dispatchDuration_ = Duration(0);
|
||||
|
|
@ -1727,8 +1720,6 @@ void Synth::Impl::resetVoices(int numVoices)
|
|||
|
||||
for (auto& set : sets_)
|
||||
set->removeAllVoices();
|
||||
engineSet_->removeAllVoices();
|
||||
engineSet_->setPolyphonyLimit(numVoices_);
|
||||
|
||||
voiceManager_.requireNumVoices(numVoices_, resources_);
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
namespace sfz {
|
||||
|
||||
struct VoiceManager : public Voice::StateListener
|
||||
struct VoiceManager final : public Voice::StateListener
|
||||
{
|
||||
/**
|
||||
* @brief The voice callback which is called during a change of state.
|
||||
|
|
|
|||
|
|
@ -50,14 +50,14 @@ Voice* FirstStealer::checkRegionPolyphony(const Region* region, absl::Span<Voice
|
|||
ASSERT(region);
|
||||
return genericPolyphonyCheck(candidates, region->polyphony,
|
||||
[=](const Voice* v) { return (!ignoreVoice(v) && v->getRegion() == region); },
|
||||
[=](const Voice* v, const Voice* c) { return c == nullptr; });
|
||||
[=](const Voice*, const Voice* c) { return c == nullptr; });
|
||||
}
|
||||
|
||||
Voice* FirstStealer::checkPolyphony(absl::Span<Voice*> candidates, unsigned maxPolyphony)
|
||||
{
|
||||
return genericPolyphonyCheck(candidates, maxPolyphony,
|
||||
[=](const Voice* v) { return (!ignoreVoice(v)); },
|
||||
[=](const Voice* v, const Voice* c) { return c == nullptr; });
|
||||
[=](const Voice*, const Voice* c) { return c == nullptr; });
|
||||
}
|
||||
|
||||
Voice* OldestStealer::checkRegionPolyphony(const Region* region, absl::Span<Voice*> candidates)
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ enum class StealingAlgorithm {
|
|||
class VoiceStealer
|
||||
{
|
||||
public:
|
||||
virtual ~VoiceStealer() {}
|
||||
/**
|
||||
* @brief Check that the region polyphony is respected.
|
||||
*
|
||||
|
|
@ -43,21 +44,21 @@ public:
|
|||
virtual Voice* checkPolyphony(absl::Span<Voice*> candidates, unsigned maxPolyphony) = 0;
|
||||
};
|
||||
|
||||
class FirstStealer : public VoiceStealer
|
||||
class FirstStealer final : public VoiceStealer
|
||||
{
|
||||
public:
|
||||
Voice* checkRegionPolyphony(const Region* region, absl::Span<Voice*> candidates) final;
|
||||
Voice* checkPolyphony(absl::Span<Voice*> candidates, unsigned maxPolyphony) final;
|
||||
};
|
||||
|
||||
class OldestStealer : public VoiceStealer
|
||||
class OldestStealer final : public VoiceStealer
|
||||
{
|
||||
public:
|
||||
Voice* checkRegionPolyphony(const Region* region, absl::Span<Voice*> candidates) final;
|
||||
Voice* checkPolyphony(absl::Span<Voice*> candidates, unsigned maxPolyphony) final;
|
||||
};
|
||||
|
||||
class EnvelopeAndAgeStealer : public VoiceStealer
|
||||
class EnvelopeAndAgeStealer final : public VoiceStealer
|
||||
{
|
||||
public:
|
||||
EnvelopeAndAgeStealer();
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ using namespace Catch::literals;
|
|||
template <class T, std::size_t A = sfz::config::defaultAlignment>
|
||||
using aligned_vector = std::vector<T, jsl::aligned_allocator<T, A>>;
|
||||
|
||||
constexpr int smallBufferSize { 3 };
|
||||
constexpr int bigBufferSize { 4095 };
|
||||
constexpr int medBufferSize { 127 };
|
||||
constexpr float fillValue { 1.3f };
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue