Skip to content

Commit

Permalink
Report effect delay #2
Browse files Browse the repository at this point in the history
  • Loading branch information
jurihock committed Dec 8, 2023
1 parent 552cdd5 commit f31a28b
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/StftPitchShiftPlugin/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Core
void timbre(double value);
void pitch(std::vector<double> values);

virtual int latency() const = 0;
virtual bool compatible(const int blocksize) const = 0;
virtual void process(const std::span<const float> input, const std::span<float> output) = 0;

Expand Down
5 changes: 5 additions & 0 deletions src/StftPitchShiftPlugin/Core/DelayedCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ DelayedCore::~DelayedCore()
{
}

int DelayedCore::latency() const
{
return get_synthesis_window_size() + InstantCore::latency();
}

bool DelayedCore::compatible(const int blocksize) const
{
return static_cast<size_t>(blocksize) <= get_synthesis_window_size();
Expand Down
1 change: 1 addition & 0 deletions src/StftPitchShiftPlugin/Core/DelayedCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class DelayedCore : public InstantCore
DelayedCore(const double samplerate, const int blocksize, const int dftsize, const int overlap);
~DelayedCore();

int latency() const override;
bool compatible(const int blocksize) const override;
void process(const std::span<const float> input, const std::span<float> output) override;

Expand Down
5 changes: 5 additions & 0 deletions src/StftPitchShiftPlugin/Core/InstantCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ InstantCore::~InstantCore()
{
}

int InstantCore::latency() const
{
return get_synthesis_window_size();
}

bool InstantCore::compatible(const int blocksize) const
{
return static_cast<size_t>(blocksize) == get_synthesis_window_size();
Expand Down
1 change: 1 addition & 0 deletions src/StftPitchShiftPlugin/Core/InstantCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class InstantCore : public Core
InstantCore(const double samplerate, const int blocksize, const int dftsize, const int overlap);
~InstantCore();

int latency() const override;
bool compatible(const int blocksize) const override;
void process(const std::span<const float> input, const std::span<float> output) override;

Expand Down
2 changes: 2 additions & 0 deletions src/StftPitchShiftPlugin/Processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ void Processor::resetCore(const State& state)
core->quefrency(parameters->quefrency());
core->timbre(parameters->timbre());
core->pitch(parameters->pitch());

setLatencySamples(core->latency());
}

juce::AudioProcessor* JUCE_CALLTYPE createPluginFilter() { return new Processor(); }

0 comments on commit f31a28b

Please sign in to comment.