Enable and disable the power follower depending on the chosen algorithm
This commit is contained in:
parent
49c9e43687
commit
0142c385dc
3 changed files with 38 additions and 1 deletions
|
|
@ -366,12 +366,21 @@ void sfz::Synth::handleControlOpcodes(const std::vector<Opcode>& members)
|
|||
case hash("hint_stealing"):
|
||||
switch(hash(member.value)) {
|
||||
case hash("first"):
|
||||
for (auto& voice : voices)
|
||||
voice->disablePowerFollower();
|
||||
|
||||
stealer.setStealingAlgorithm(VoiceStealing::StealingAlgorithm::First);
|
||||
break;
|
||||
case hash("oldest"):
|
||||
for (auto& voice : voices)
|
||||
voice->disablePowerFollower();
|
||||
|
||||
stealer.setStealingAlgorithm(VoiceStealing::StealingAlgorithm::Oldest);
|
||||
break;
|
||||
case hash("envelope_and_age"):
|
||||
for (auto& voice : voices)
|
||||
voice->enablePowerFollower();
|
||||
|
||||
stealer.setStealingAlgorithm(VoiceStealing::StealingAlgorithm::EnvelopeAndAge);
|
||||
break;
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -848,7 +848,10 @@ void sfz::Voice::removeVoiceFromRing() noexcept
|
|||
|
||||
float sfz::Voice::getAveragePower() const noexcept
|
||||
{
|
||||
return powerFollower.getAveragePower();
|
||||
if (followPower)
|
||||
return powerFollower.getAveragePower();
|
||||
else
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
bool sfz::Voice::releasedOrFree() const noexcept
|
||||
|
|
@ -1030,3 +1033,14 @@ void sfz::Voice::saveModulationTargets(const Region* region) noexcept
|
|||
oscillatorDetuneTarget = mm.findTarget(ModKey::createNXYZ(ModId::OscillatorDetune, region->getId()));
|
||||
oscillatorModDepthTarget = mm.findTarget(ModKey::createNXYZ(ModId::OscillatorModDepth, region->getId()));
|
||||
}
|
||||
|
||||
void sfz::Voice::enablePowerFollower() noexcept
|
||||
{
|
||||
followPower = true;
|
||||
powerFollower.clear();
|
||||
}
|
||||
|
||||
void sfz::Voice::disablePowerFollower() noexcept
|
||||
{
|
||||
followPower = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -248,6 +248,19 @@ public:
|
|||
* @return float
|
||||
*/
|
||||
float getAveragePower() const noexcept;
|
||||
|
||||
/**
|
||||
* @brief Enable the power follower
|
||||
*
|
||||
*/
|
||||
|
||||
void enablePowerFollower() noexcept;
|
||||
/**
|
||||
* @brief Disable the power follower
|
||||
*
|
||||
*/
|
||||
void disablePowerFollower() noexcept;
|
||||
|
||||
/**
|
||||
* Returns the region that is currently playing. May be null if the voice is not active!
|
||||
*
|
||||
|
|
@ -519,6 +532,7 @@ private:
|
|||
ModMatrix::TargetId oscillatorDetuneTarget;
|
||||
ModMatrix::TargetId oscillatorModDepthTarget;
|
||||
|
||||
bool followPower { false };
|
||||
PowerFollower powerFollower;
|
||||
|
||||
LEAK_DETECTOR(Voice);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue