Merge pull request #410 from paulfd/mm-tweaks

Modulation matrix tweaks
This commit is contained in:
JP Cimalando 2020-09-09 06:24:42 +02:00 committed by GitHub
commit 1fee4f76a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 34 deletions

View file

@ -5,10 +5,8 @@
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz // If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
#include "ModKey.h" #include "ModKey.h"
#include "ModId.h"
#include "../Debug.h" #include "../Debug.h"
#include <absl/strings/str_cat.h> #include <absl/strings/str_cat.h>
#include <cstring>
namespace sfz { namespace sfz {
@ -32,16 +30,6 @@ ModKey::Parameters& ModKey::Parameters::operator=(const Parameters& other) noexc
return *this; 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 ModKey::createCC(uint16_t cc, uint8_t curve, uint8_t smooth, float value, float step)
{ {
ModKey::Parameters p; ModKey::Parameters p;
@ -74,10 +62,6 @@ bool ModKey::isTarget() const noexcept
return ModIds::isTarget(id_); return ModIds::isTarget(id_);
} }
int ModKey::flags() const noexcept
{
return ModIds::flags(id_);
}
std::string ModKey::toString() const std::string ModKey::toString() const
{ {
@ -111,13 +95,3 @@ std::string ModKey::toString() const
} // namespace sfz } // 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);
}

View file

@ -6,8 +6,10 @@
#pragma once #pragma once
#include "ModKeyHash.h" #include "ModKeyHash.h"
#include "ModId.h"
#include "../NumericId.h" #include "../NumericId.h"
#include <string> #include <string>
#include <cstring>
namespace sfz { namespace sfz {
@ -24,7 +26,7 @@ public:
ModKey() = default; ModKey() = default;
explicit ModKey(ModId id, NumericId<Region> region = {}, Parameters params = {}) explicit ModKey(ModId id, NumericId<Region> 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 createCC(uint16_t cc, uint8_t curve, uint8_t smooth, float value, float step);
static ModKey createNXYZ(ModId id, NumericId<Region> region, uint8_t N = 0, uint8_t X = 0, uint8_t Y = 0, uint8_t Z = 0); static ModKey createNXYZ(ModId id, NumericId<Region> 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_; } const ModId& id() const noexcept { return id_; }
NumericId<Region> region() const noexcept { return region_; } NumericId<Region> region() const noexcept { return region_; }
const Parameters& parameters() const noexcept { return params_; } const Parameters& parameters() const noexcept { return params_; }
int flags() const noexcept { return flags_; }
bool isSource() const noexcept; bool isSource() const noexcept;
bool isTarget() const noexcept; bool isTarget() const noexcept;
int flags() const noexcept;
std::string toString() const; std::string toString() const;
struct Parameters { struct Parameters {
@ -48,8 +50,15 @@ public:
Parameters(Parameters&&) = delete; Parameters(Parameters&&) = delete;
Parameters &operator=(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 { union {
//! Parameters if this key identifies a CC source //! Parameters if this key identifies a CC source
@ -63,8 +72,17 @@ public:
}; };
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: private:
//! Identifier //! Identifier
@ -73,6 +91,8 @@ private:
NumericId<Region> region_; NumericId<Region> region_;
//! List of values which identify the key uniquely, along with the hash and region //! List of values which identify the key uniquely, along with the hash and region
Parameters params_ {}; Parameters params_ {};
// Memorize the flag
int flags_;
}; };
} // namespace sfz } // namespace sfz

View file

@ -364,8 +364,7 @@ float* ModMatrix::getModulation(TargetId targetId)
} }
else { else {
ASSERT(targetFlags & kModIsAdditive); ASSERT(targetFlags & kModIsAdditive);
for (uint32_t i = 0; i < numFrames; ++i) sfz::multiplyAdd1<float>(sourceDepth, sourceBuffer, buffer);
buffer[i] += sourceDepth * sourceBuffer[i];
} }
} }
} }