diff --git a/src/sfizz/modulations/ModKey.cpp b/src/sfizz/modulations/ModKey.cpp index 5ba5e02c..c5ee2a37 100644 --- a/src/sfizz/modulations/ModKey.cpp +++ b/src/sfizz/modulations/ModKey.cpp @@ -5,10 +5,8 @@ // If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz #include "ModKey.h" -#include "ModId.h" #include "../Debug.h" #include -#include namespace sfz { @@ -32,16 +30,6 @@ ModKey::Parameters& ModKey::Parameters::operator=(const Parameters& other) noexc return *this; } -bool ModKey::Parameters::operator==(const Parameters& other) const noexcept -{ - return std::memcmp(this, &other, sizeof(*this)) == 0; -} - -bool ModKey::Parameters::operator!=(const Parameters& other) const noexcept -{ - return std::memcmp(this, &other, sizeof(*this)) != 0; -} - ModKey ModKey::createCC(uint16_t cc, uint8_t curve, uint8_t smooth, float value, float step) { ModKey::Parameters p; @@ -74,10 +62,6 @@ bool ModKey::isTarget() const noexcept return ModIds::isTarget(id_); } -int ModKey::flags() const noexcept -{ - return ModIds::flags(id_); -} std::string ModKey::toString() const { @@ -111,13 +95,3 @@ std::string ModKey::toString() const } // namespace sfz -bool sfz::ModKey::operator==(const ModKey &other) const noexcept -{ - return id_ == other.id_ && region_ == other.region_ && - parameters() == other.parameters(); -} - -bool sfz::ModKey::operator!=(const ModKey &other) const noexcept -{ - return !this->operator==(other); -} diff --git a/src/sfizz/modulations/ModKey.h b/src/sfizz/modulations/ModKey.h index 37b8b072..5fff0197 100644 --- a/src/sfizz/modulations/ModKey.h +++ b/src/sfizz/modulations/ModKey.h @@ -6,8 +6,10 @@ #pragma once #include "ModKeyHash.h" +#include "ModId.h" #include "../NumericId.h" #include +#include namespace sfz { @@ -24,7 +26,7 @@ public: ModKey() = default; explicit ModKey(ModId id, NumericId region = {}, Parameters params = {}) - : id_(id), region_(region), params_(params) {} + : id_(id), region_(region), params_(params), flags_(ModIds::flags(id_)) {} static ModKey createCC(uint16_t cc, uint8_t curve, uint8_t smooth, float value, float step); static ModKey createNXYZ(ModId id, NumericId region, uint8_t N = 0, uint8_t X = 0, uint8_t Y = 0, uint8_t Z = 0); @@ -34,10 +36,10 @@ public: const ModId& id() const noexcept { return id_; } NumericId region() const noexcept { return region_; } const Parameters& parameters() const noexcept { return params_; } + int flags() const noexcept { return flags_; } bool isSource() const noexcept; bool isTarget() const noexcept; - int flags() const noexcept; std::string toString() const; struct Parameters { @@ -48,8 +50,15 @@ public: Parameters(Parameters&&) = delete; Parameters &operator=(Parameters&&) = delete; - bool operator==(const Parameters& other) const noexcept; - bool operator!=(const Parameters& other) const noexcept; + bool operator==(const Parameters& other) const noexcept + { + return std::memcmp(this, &other, sizeof(*this)) == 0; + } + + bool operator!=(const Parameters& other) const noexcept + { + return std::memcmp(this, &other, sizeof(*this)) != 0; + } union { //! Parameters if this key identifies a CC source @@ -63,8 +72,17 @@ public: }; public: - bool operator==(const ModKey &other) const noexcept; - bool operator!=(const ModKey &other) const noexcept; + bool operator==(const ModKey &other) const noexcept + { + return id_ == other.id_ && region_ == other.region_ && + parameters() == other.parameters(); + } + + bool operator!=(const ModKey &other) const noexcept + { + return !this->operator==(other); + } + private: //! Identifier @@ -73,6 +91,8 @@ private: NumericId region_; //! List of values which identify the key uniquely, along with the hash and region Parameters params_ {}; + // Memorize the flag + int flags_; }; } // namespace sfz diff --git a/src/sfizz/modulations/ModMatrix.cpp b/src/sfizz/modulations/ModMatrix.cpp index 9290ba2d..643f168d 100644 --- a/src/sfizz/modulations/ModMatrix.cpp +++ b/src/sfizz/modulations/ModMatrix.cpp @@ -364,8 +364,7 @@ float* ModMatrix::getModulation(TargetId targetId) } else { ASSERT(targetFlags & kModIsAdditive); - for (uint32_t i = 0; i < numFrames; ++i) - buffer[i] += sourceDepth * sourceBuffer[i]; + sfz::multiplyAdd1(sourceDepth, sourceBuffer, buffer); } } }