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