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"):
|
case hash("hint_stealing"):
|
||||||
switch(hash(member.value)) {
|
switch(hash(member.value)) {
|
||||||
case hash("first"):
|
case hash("first"):
|
||||||
|
for (auto& voice : voices)
|
||||||
|
voice->disablePowerFollower();
|
||||||
|
|
||||||
stealer.setStealingAlgorithm(VoiceStealing::StealingAlgorithm::First);
|
stealer.setStealingAlgorithm(VoiceStealing::StealingAlgorithm::First);
|
||||||
break;
|
break;
|
||||||
case hash("oldest"):
|
case hash("oldest"):
|
||||||
|
for (auto& voice : voices)
|
||||||
|
voice->disablePowerFollower();
|
||||||
|
|
||||||
stealer.setStealingAlgorithm(VoiceStealing::StealingAlgorithm::Oldest);
|
stealer.setStealingAlgorithm(VoiceStealing::StealingAlgorithm::Oldest);
|
||||||
break;
|
break;
|
||||||
case hash("envelope_and_age"):
|
case hash("envelope_and_age"):
|
||||||
|
for (auto& voice : voices)
|
||||||
|
voice->enablePowerFollower();
|
||||||
|
|
||||||
stealer.setStealingAlgorithm(VoiceStealing::StealingAlgorithm::EnvelopeAndAge);
|
stealer.setStealingAlgorithm(VoiceStealing::StealingAlgorithm::EnvelopeAndAge);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -848,7 +848,10 @@ void sfz::Voice::removeVoiceFromRing() noexcept
|
||||||
|
|
||||||
float sfz::Voice::getAveragePower() const noexcept
|
float sfz::Voice::getAveragePower() const noexcept
|
||||||
{
|
{
|
||||||
|
if (followPower)
|
||||||
return powerFollower.getAveragePower();
|
return powerFollower.getAveragePower();
|
||||||
|
else
|
||||||
|
return 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool sfz::Voice::releasedOrFree() const noexcept
|
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()));
|
oscillatorDetuneTarget = mm.findTarget(ModKey::createNXYZ(ModId::OscillatorDetune, region->getId()));
|
||||||
oscillatorModDepthTarget = mm.findTarget(ModKey::createNXYZ(ModId::OscillatorModDepth, 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
|
* @return float
|
||||||
*/
|
*/
|
||||||
float getAveragePower() const noexcept;
|
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!
|
* 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 oscillatorDetuneTarget;
|
||||||
ModMatrix::TargetId oscillatorModDepthTarget;
|
ModMatrix::TargetId oscillatorModDepthTarget;
|
||||||
|
|
||||||
|
bool followPower { false };
|
||||||
PowerFollower powerFollower;
|
PowerFollower powerFollower;
|
||||||
|
|
||||||
LEAK_DETECTOR(Voice);
|
LEAK_DETECTOR(Voice);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue