Clean up ccModDepth/ccModParameters
This commit is contained in:
parent
171a5e5083
commit
c8e5483c59
2 changed files with 37 additions and 31 deletions
|
|
@ -1932,35 +1932,37 @@ sfz::Region::Connection& sfz::Region::getOrCreateConnection(const ModKey& source
|
||||||
return connections.back();
|
return connections.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sfz::Region::Connection* sfz::Region::getConnectionFromCC(int sourceCC, const ModKey& target)
|
||||||
|
{
|
||||||
|
for (sfz::Region::Connection& conn : connections) {
|
||||||
|
if (conn.source.id() == sfz::ModId::Controller && conn.target == target) {
|
||||||
|
auto p = conn.source.parameters();
|
||||||
|
if (p.cc == sourceCC)
|
||||||
|
return &conn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
bool sfz::Region::disabled() const noexcept
|
bool sfz::Region::disabled() const noexcept
|
||||||
{
|
{
|
||||||
return (sampleEnd == 0);
|
return (sampleEnd == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
absl::optional<float> sfz::Region::ccModDepth(int cc, ModId id) const noexcept
|
absl::optional<float> sfz::Region::ccModDepth(int cc, ModId id, uint8_t N, uint8_t X, uint8_t Y, uint8_t Z) const noexcept
|
||||||
{
|
{
|
||||||
const ModKey target = ModKey::createNXYZ(id, getId());
|
const ModKey target = ModKey::createNXYZ(id, getId(), N, X, Y, Z);
|
||||||
for (const sfz::Region::Connection& conn : connections) {
|
const Connection *conn = const_cast<Region*>(this)->getConnectionFromCC(cc, target);
|
||||||
if (conn.source.id() == sfz::ModId::Controller && conn.target == target) {
|
if (!conn)
|
||||||
auto p = conn.source.parameters();
|
return {};
|
||||||
if (p.cc == cc)
|
return conn->sourceDepth;
|
||||||
return conn.sourceDepth;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
absl::optional<sfz::ModKey::Parameters> sfz::Region::ccModParameters(int cc, ModId id) const noexcept
|
absl::optional<sfz::ModKey::Parameters> sfz::Region::ccModParameters(int cc, ModId id, uint8_t N, uint8_t X, uint8_t Y, uint8_t Z) const noexcept
|
||||||
{
|
{
|
||||||
const ModKey target = ModKey::createNXYZ(id, getId());
|
const ModKey target = ModKey::createNXYZ(id, getId(), N, X, Y, Z);
|
||||||
for (const sfz::Region::Connection& conn : connections) {
|
const Connection *conn = const_cast<Region*>(this)->getConnectionFromCC(cc, target);
|
||||||
if (conn.source.id() == sfz::ModId::Controller && conn.target == target) {
|
if (!conn)
|
||||||
auto p = conn.source.parameters();
|
return {};
|
||||||
if (p.cc == cc)
|
return conn->source.parameters();
|
||||||
return p;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -304,22 +304,25 @@ struct Region {
|
||||||
bool disabled() const noexcept;
|
bool disabled() const noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Extract the source depth modifier for a given cc and id.
|
* @brief Extract the source depth of the unique connection identified
|
||||||
|
* by a given CC and NXYZ target.
|
||||||
*
|
*
|
||||||
* @param cc
|
* @param cc the CC number of the modulation source
|
||||||
* @param id
|
* @param id the ID of the modulation target, which must be regional
|
||||||
* @return absl::optional<float>
|
* @return absl::optional<float>
|
||||||
*/
|
*/
|
||||||
absl::optional<float> ccModDepth(int cc, ModId id) const noexcept;
|
absl::optional<float> ccModDepth(int cc, ModId id, uint8_t N = 0, uint8_t X = 0, uint8_t Y = 0, uint8_t Z = 0) const noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Extract the parameters for a given modulation cc and id.
|
* @brief Extract the source parameters of the unique connection identified
|
||||||
|
* by a given CC and NXYZ target.
|
||||||
*
|
*
|
||||||
* @param cc
|
* @param cc the CC number of the modulation source
|
||||||
* @param id
|
* @param cc the CC number of the modulation source
|
||||||
* @return float
|
* @param id the ID of the modulation target, which must be regional
|
||||||
|
* @return absl::optional<ModKey::Parameters>
|
||||||
*/
|
*/
|
||||||
absl::optional<ModKey::Parameters> ccModParameters(int cc, ModId id) const noexcept;
|
absl::optional<ModKey::Parameters> ccModParameters(int cc, ModId id, uint8_t N = 0, uint8_t X = 0, uint8_t Y = 0, uint8_t Z = 0) const noexcept;
|
||||||
|
|
||||||
const NumericId<Region> id;
|
const NumericId<Region> id;
|
||||||
|
|
||||||
|
|
@ -466,6 +469,7 @@ struct Region {
|
||||||
std::vector<Connection> connections;
|
std::vector<Connection> connections;
|
||||||
Connection* getConnection(const ModKey& source, const ModKey& target);
|
Connection* getConnection(const ModKey& source, const ModKey& target);
|
||||||
Connection& getOrCreateConnection(const ModKey& source, const ModKey& target);
|
Connection& getOrCreateConnection(const ModKey& source, const ModKey& target);
|
||||||
|
Connection* getConnectionFromCC(int sourceCC, const ModKey& target);
|
||||||
|
|
||||||
// Parent
|
// Parent
|
||||||
RegionSet* parent { nullptr };
|
RegionSet* parent { nullptr };
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue