Assign LFOs their respective ID numbers
This commit is contained in:
parent
d8dcb2e56f
commit
04ff815cab
5 changed files with 21 additions and 7 deletions
|
|
@ -114,7 +114,8 @@ int main(int argc, char* argv[])
|
|||
std::vector<std::unique_ptr<sfz::LFO>> lfos(numLfos);
|
||||
|
||||
for (size_t l = 0; l < numLfos; ++l) {
|
||||
sfz::LFO* lfo = new sfz::LFO(bufferPool);
|
||||
const NumericId<sfz::LFO> id { static_cast<int>(l) };
|
||||
sfz::LFO* lfo = new sfz::LFO(id, bufferPool);
|
||||
lfos[l].reset(lfo);
|
||||
lfo->setSampleRate(sampleRate);
|
||||
lfo->configure(&desc[l]);
|
||||
|
|
|
|||
|
|
@ -18,14 +18,16 @@
|
|||
namespace sfz {
|
||||
|
||||
struct LFO::Impl {
|
||||
explicit Impl(BufferPool& bufferPool, BeatClock* beatClock)
|
||||
: bufferPool_(bufferPool),
|
||||
explicit Impl(NumericId<LFO> id, BufferPool& bufferPool, BeatClock* beatClock)
|
||||
: id_(id),
|
||||
bufferPool_(bufferPool),
|
||||
beatClock_(beatClock),
|
||||
sampleRate_(config::defaultSampleRate),
|
||||
desc_(&LFODescription::getDefault())
|
||||
{
|
||||
}
|
||||
|
||||
NumericId<LFO> id_;
|
||||
BufferPool& bufferPool_;
|
||||
BeatClock* beatClock_ = nullptr;
|
||||
float sampleRate_ = 0;
|
||||
|
|
@ -41,8 +43,8 @@ struct LFO::Impl {
|
|||
std::array<int, config::maxLFOSubs> sampleHoldState_ {{}};
|
||||
};
|
||||
|
||||
LFO::LFO(BufferPool& bufferPool, BeatClock* beatClock)
|
||||
: impl_(new Impl(bufferPool, beatClock))
|
||||
LFO::LFO(NumericId<LFO> id, BufferPool& bufferPool, BeatClock* beatClock)
|
||||
: impl_(new Impl(id, bufferPool, beatClock))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -50,6 +52,11 @@ LFO::~LFO()
|
|||
{
|
||||
}
|
||||
|
||||
NumericId<LFO> LFO::getId() const noexcept
|
||||
{
|
||||
return impl_->id_;
|
||||
}
|
||||
|
||||
void LFO::setSampleRate(double sampleRate)
|
||||
{
|
||||
impl_->sampleRate_ = sampleRate;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
|
||||
|
||||
#pragma once
|
||||
#include "utility/NumericId.h"
|
||||
#include <absl/types/span.h>
|
||||
#include <memory>
|
||||
|
||||
|
|
@ -52,10 +53,13 @@ struct LFODescription;
|
|||
class LFO {
|
||||
public:
|
||||
explicit LFO(
|
||||
NumericId<LFO> id,
|
||||
BufferPool& bufferPool,
|
||||
BeatClock* beatClock = nullptr);
|
||||
~LFO();
|
||||
|
||||
NumericId<LFO> getId() const noexcept;
|
||||
|
||||
/**
|
||||
Sets the sample rate.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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<LFO>(resources.bufferPool, &resources.beatClock);
|
||||
const NumericId<LFO> id { static_cast<int>(i) };
|
||||
auto lfo = absl::make_unique<LFO>(id, resources.bufferPool, &resources.beatClock);
|
||||
lfo->setSampleRate(impl.sampleRate_);
|
||||
impl.lfos_[i] = std::move(lfo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ static bool computeLFO(DataPoints& dp, const fs::path& sfzPath, double sampleRat
|
|||
std::vector<std::unique_ptr<sfz::LFO>> lfos(numLfos);
|
||||
|
||||
for (size_t l = 0; l < numLfos; ++l) {
|
||||
sfz::LFO* lfo = new sfz::LFO(resources.bufferPool);
|
||||
const NumericId<sfz::LFO> id { static_cast<int>(l) };
|
||||
sfz::LFO* lfo = new sfz::LFO(id, resources.bufferPool);
|
||||
lfos[l].reset(lfo);
|
||||
lfo->setSampleRate(sampleRate);
|
||||
lfo->configure(&desc[l]);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue