diff --git a/demos/PlotLFO.cpp b/demos/PlotLFO.cpp index 61ca0371..6f77f2f5 100644 --- a/demos/PlotLFO.cpp +++ b/demos/PlotLFO.cpp @@ -114,7 +114,8 @@ int main(int argc, char* argv[]) std::vector> lfos(numLfos); for (size_t l = 0; l < numLfos; ++l) { - sfz::LFO* lfo = new sfz::LFO(bufferPool); + const NumericId id { static_cast(l) }; + sfz::LFO* lfo = new sfz::LFO(id, bufferPool); lfos[l].reset(lfo); lfo->setSampleRate(sampleRate); lfo->configure(&desc[l]); diff --git a/src/sfizz/LFO.cpp b/src/sfizz/LFO.cpp index 6dd5c168..353ab899 100644 --- a/src/sfizz/LFO.cpp +++ b/src/sfizz/LFO.cpp @@ -18,14 +18,16 @@ namespace sfz { struct LFO::Impl { - explicit Impl(BufferPool& bufferPool, BeatClock* beatClock) - : bufferPool_(bufferPool), + explicit Impl(NumericId id, BufferPool& bufferPool, BeatClock* beatClock) + : id_(id), + bufferPool_(bufferPool), beatClock_(beatClock), sampleRate_(config::defaultSampleRate), desc_(&LFODescription::getDefault()) { } + NumericId id_; BufferPool& bufferPool_; BeatClock* beatClock_ = nullptr; float sampleRate_ = 0; @@ -41,8 +43,8 @@ struct LFO::Impl { std::array sampleHoldState_ {{}}; }; -LFO::LFO(BufferPool& bufferPool, BeatClock* beatClock) - : impl_(new Impl(bufferPool, beatClock)) +LFO::LFO(NumericId id, BufferPool& bufferPool, BeatClock* beatClock) + : impl_(new Impl(id, bufferPool, beatClock)) { } @@ -50,6 +52,11 @@ LFO::~LFO() { } +NumericId LFO::getId() const noexcept +{ + return impl_->id_; +} + void LFO::setSampleRate(double sampleRate) { impl_->sampleRate_ = sampleRate; diff --git a/src/sfizz/LFO.h b/src/sfizz/LFO.h index 1a908932..fecadc8b 100644 --- a/src/sfizz/LFO.h +++ b/src/sfizz/LFO.h @@ -5,6 +5,7 @@ // If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz #pragma once +#include "utility/NumericId.h" #include #include @@ -52,10 +53,13 @@ struct LFODescription; class LFO { public: explicit LFO( + NumericId id, BufferPool& bufferPool, BeatClock* beatClock = nullptr); ~LFO(); + NumericId getId() const noexcept; + /** Sets the sample rate. */ diff --git a/src/sfizz/Voice.cpp b/src/sfizz/Voice.cpp index e3181121..6c25eee8 100644 --- a/src/sfizz/Voice.cpp +++ b/src/sfizz/Voice.cpp @@ -1480,7 +1480,8 @@ void Voice::setMaxLFOsPerVoice(size_t numLFOs) impl.lfos_.resize(numLFOs); for (size_t i = 0; i < numLFOs; ++i) { - auto lfo = absl::make_unique(resources.bufferPool, &resources.beatClock); + const NumericId id { static_cast(i) }; + auto lfo = absl::make_unique(id, resources.bufferPool, &resources.beatClock); lfo->setSampleRate(impl.sampleRate_); impl.lfos_[i] = std::move(lfo); } diff --git a/tests/LFOT.cpp b/tests/LFOT.cpp index e2a625f4..4f2b6a6d 100644 --- a/tests/LFOT.cpp +++ b/tests/LFOT.cpp @@ -26,7 +26,8 @@ static bool computeLFO(DataPoints& dp, const fs::path& sfzPath, double sampleRat std::vector> lfos(numLfos); for (size_t l = 0; l < numLfos; ++l) { - sfz::LFO* lfo = new sfz::LFO(resources.bufferPool); + const NumericId id { static_cast(l) }; + sfz::LFO* lfo = new sfz::LFO(id, resources.bufferPool); lfos[l].reset(lfo); lfo->setSampleRate(sampleRate); lfo->configure(&desc[l]);