diff options
author | Robin Gareus <robin@gareus.org> | 2016-04-03 18:27:32 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2016-04-03 22:45:23 +0200 |
commit | fe1985c3e3cfbaa73c8986710f97afc1cfbe076b (patch) | |
tree | e2d27e77d7833486d60ea2df416551772f639ae1 /libs/ardour/ardour/chan_count.h | |
parent | 4071e7731455223fb04214f846b6856ad83014f0 (diff) |
add channel count difference operator.
Diffstat (limited to 'libs/ardour/ardour/chan_count.h')
-rw-r--r-- | libs/ardour/ardour/chan_count.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/libs/ardour/ardour/chan_count.h b/libs/ardour/ardour/chan_count.h index ba4a2f17bb..b5699b6743 100644 --- a/libs/ardour/ardour/chan_count.h +++ b/libs/ardour/ardour/chan_count.h @@ -147,6 +147,19 @@ public: return ret; } + /** underflow safe subtraction */ + ChanCount operator-(const ChanCount& other) const { + ChanCount ret; + for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) { + if (get(*t) < other.get(*t)) { + ret.set(*t, 0); + } else { + ret.set(*t, get(*t) - other.get(*t)); + } + } + return ret; + } + ChanCount operator*(const unsigned int factor) const { ChanCount ret; for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) { @@ -155,6 +168,18 @@ public: return ret; } + /** underflow safe subtraction */ + ChanCount& operator-=(const ChanCount& other) { + for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) { + if (_counts[*t] < other._counts[*t]) { + _counts[*t] = 0; + } else { + _counts[*t] -= other._counts[*t]; + } + } + return *this; + } + ChanCount& operator+=(const ChanCount& other) { for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) { _counts[*t] += other._counts[*t]; |