From 75d6dd24f4886bea9e268b07e48f22fb5afeb19c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Hock?= Date: Sat, 30 Dec 2023 10:06:54 +0100 Subject: [PATCH] Rename --- .../{Core.cpp => Effect.cpp} | 16 +++--- src/StftPitchShiftPlugin/{Core.h => Effect.h} | 6 +-- .../DelayedEffect.cpp} | 22 ++++---- .../DelayedCore.h => Effect/DelayedEffect.h} | 8 +-- .../InstantEffect.cpp} | 18 +++---- .../InstantCore.h => Effect/InstantEffect.h} | 8 +-- src/StftPitchShiftPlugin/Processor.cpp | 50 +++++++++---------- src/StftPitchShiftPlugin/Processor.h | 6 +-- 8 files changed, 67 insertions(+), 67 deletions(-) rename src/StftPitchShiftPlugin/{Core.cpp => Effect.cpp} (66%) rename src/StftPitchShiftPlugin/{Core.h => Effect.h} (88%) rename src/StftPitchShiftPlugin/{Core/DelayedCore.cpp => Effect/DelayedEffect.cpp} (68%) rename src/StftPitchShiftPlugin/{Core/DelayedCore.h => Effect/DelayedEffect.h} (72%) rename src/StftPitchShiftPlugin/{Core/InstantCore.cpp => Effect/InstantEffect.cpp} (70%) rename src/StftPitchShiftPlugin/{Core/InstantCore.h => Effect/InstantEffect.h} (76%) diff --git a/src/StftPitchShiftPlugin/Core.cpp b/src/StftPitchShiftPlugin/Effect.cpp similarity index 66% rename from src/StftPitchShiftPlugin/Core.cpp rename to src/StftPitchShiftPlugin/Effect.cpp index ce08937..f6281bb 100644 --- a/src/StftPitchShiftPlugin/Core.cpp +++ b/src/StftPitchShiftPlugin/Effect.cpp @@ -1,6 +1,6 @@ -#include +#include -Core::Core(const double samplerate, const int blocksize, const int dftsize, const int overlap) : +Effect::Effect(const double samplerate, const int blocksize, const int dftsize, const int overlap) : samplerate(samplerate), blocksize(blocksize), dftsize(dftsize), overlap(overlap), analysis_window_size(static_cast(dftsize + dftsize)), synthesis_window_size(static_cast(blocksize)) @@ -14,31 +14,31 @@ Core::Core(const double samplerate, const int blocksize, const int dftsize, cons core = std::make_unique>(fft, winsize, hopsize, samplerate); } -Core::~Core() +Effect::~Effect() { } -void Core::normalize(bool value) +void Effect::normalize(bool value) { core->normalization(value); } -void Core::quefrency(double value) +void Effect::quefrency(double value) { core->quefrency(value); } -void Core::timbre(double value) +void Effect::timbre(double value) { core->distortion(value); } -void Core::pitch(std::vector values) +void Effect::pitch(std::vector values) { core->factors(values); } -void Core::stft_pitch_shift(const std::span input, const std::span output) const +void Effect::stft_pitch_shift(const std::span input, const std::span output) const { (*stft)(input, output, [&](std::span> dft) { diff --git a/src/StftPitchShiftPlugin/Core.h b/src/StftPitchShiftPlugin/Effect.h similarity index 88% rename from src/StftPitchShiftPlugin/Core.h rename to src/StftPitchShiftPlugin/Effect.h index 5399c05..ecb217e 100644 --- a/src/StftPitchShiftPlugin/Core.h +++ b/src/StftPitchShiftPlugin/Effect.h @@ -5,13 +5,13 @@ #include #include -class Core +class Effect { public: - Core(const double samplerate, const int blocksize, const int dftsize, const int overlap); - virtual ~Core(); + Effect(const double samplerate, const int blocksize, const int dftsize, const int overlap); + virtual ~Effect(); void normalize(bool value); void quefrency(double value); diff --git a/src/StftPitchShiftPlugin/Core/DelayedCore.cpp b/src/StftPitchShiftPlugin/Effect/DelayedEffect.cpp similarity index 68% rename from src/StftPitchShiftPlugin/Core/DelayedCore.cpp rename to src/StftPitchShiftPlugin/Effect/DelayedEffect.cpp index a43cfbb..c0b2ceb 100644 --- a/src/StftPitchShiftPlugin/Core/DelayedCore.cpp +++ b/src/StftPitchShiftPlugin/Effect/DelayedEffect.cpp @@ -1,7 +1,7 @@ -#include +#include -DelayedCore::DelayedCore(const double samplerate, const int blocksize, const int dftsize, const int overlap) : - InstantCore(samplerate, dftsize + dftsize, dftsize, overlap), host_block_size(blocksize) +DelayedEffect::DelayedEffect(const double samplerate, const int blocksize, const int dftsize, const int overlap) : + InstantEffect(samplerate, dftsize + dftsize, dftsize, overlap), host_block_size(blocksize) { const auto total_buffer_size = analysis_window_size + synthesis_window_size; @@ -11,37 +11,37 @@ DelayedCore::DelayedCore(const double samplerate, const int blocksize, const int samples = 0; } -DelayedCore::~DelayedCore() +DelayedEffect::~DelayedEffect() { } -int DelayedCore::latency() const +int DelayedEffect::latency() const { return 6 * dftsize - host_block_size; } -bool DelayedCore::compatible(const int blocksize) const +bool DelayedEffect::compatible(const int blocksize) const { return static_cast(blocksize) <= synthesis_window_size; } -void DelayedCore::dry(const std::span input, const std::span output) +void DelayedEffect::dry(const std::span input, const std::span output) { process(input, output, [&](std::span x, std::span y) { - InstantCore::dry(x, y); + InstantEffect::dry(x, y); }); } -void DelayedCore::wet(const std::span input, const std::span output) +void DelayedEffect::wet(const std::span input, const std::span output) { process(input, output, [&](std::span x, std::span y) { - InstantCore::wet(x, y); + InstantEffect::wet(x, y); }); } -void DelayedCore::process(const std::span input, const std::span output, +void DelayedEffect::process(const std::span input, const std::span output, std::function x, std::span y)> callback) { const auto minsamples = input.size(); diff --git a/src/StftPitchShiftPlugin/Core/DelayedCore.h b/src/StftPitchShiftPlugin/Effect/DelayedEffect.h similarity index 72% rename from src/StftPitchShiftPlugin/Core/DelayedCore.h rename to src/StftPitchShiftPlugin/Effect/DelayedEffect.h index daa699d..ce805cc 100644 --- a/src/StftPitchShiftPlugin/Core/DelayedCore.h +++ b/src/StftPitchShiftPlugin/Effect/DelayedEffect.h @@ -1,14 +1,14 @@ #pragma once -#include +#include -class DelayedCore : public InstantCore +class DelayedEffect : public InstantEffect { public: - DelayedCore(const double samplerate, const int blocksize, const int dftsize, const int overlap); - ~DelayedCore(); + DelayedEffect(const double samplerate, const int blocksize, const int dftsize, const int overlap); + ~DelayedEffect(); int latency() const override; bool compatible(const int blocksize) const override; diff --git a/src/StftPitchShiftPlugin/Core/InstantCore.cpp b/src/StftPitchShiftPlugin/Effect/InstantEffect.cpp similarity index 70% rename from src/StftPitchShiftPlugin/Core/InstantCore.cpp rename to src/StftPitchShiftPlugin/Effect/InstantEffect.cpp index fb2039e..1da7741 100644 --- a/src/StftPitchShiftPlugin/Core/InstantCore.cpp +++ b/src/StftPitchShiftPlugin/Effect/InstantEffect.cpp @@ -1,7 +1,7 @@ -#include +#include -InstantCore::InstantCore(const double samplerate, const int blocksize, const int dftsize, const int overlap) : - Core(samplerate, blocksize, dftsize, overlap) +InstantEffect::InstantEffect(const double samplerate, const int blocksize, const int dftsize, const int overlap) : + Effect(samplerate, blocksize, dftsize, overlap) { const auto total_buffer_size = analysis_window_size + synthesis_window_size; @@ -9,21 +9,21 @@ InstantCore::InstantCore(const double samplerate, const int blocksize, const int buffer.output.resize(total_buffer_size); } -InstantCore::~InstantCore() +InstantEffect::~InstantEffect() { } -int InstantCore::latency() const +int InstantEffect::latency() const { return static_cast(synthesis_window_size); } -bool InstantCore::compatible(const int blocksize) const +bool InstantEffect::compatible(const int blocksize) const { return static_cast(blocksize) == synthesis_window_size; } -void InstantCore::dry(const std::span input, const std::span output) +void InstantEffect::dry(const std::span input, const std::span output) { process(input, output, [](std::span x, std::span y) { @@ -31,7 +31,7 @@ void InstantCore::dry(const std::span input, const std::span }); } -void InstantCore::wet(const std::span input, const std::span output) +void InstantEffect::wet(const std::span input, const std::span output) { process(input, output, [&](std::span x, std::span y) { @@ -39,7 +39,7 @@ void InstantCore::wet(const std::span input, const std::span }); } -void InstantCore::process(const std::span input, const std::span output, +void InstantEffect::process(const std::span input, const std::span output, std::function x, std::span y)> callback) { // shift input buffer diff --git a/src/StftPitchShiftPlugin/Core/InstantCore.h b/src/StftPitchShiftPlugin/Effect/InstantEffect.h similarity index 76% rename from src/StftPitchShiftPlugin/Core/InstantCore.h rename to src/StftPitchShiftPlugin/Effect/InstantEffect.h index c1ddee2..fba80fb 100644 --- a/src/StftPitchShiftPlugin/Core/InstantCore.h +++ b/src/StftPitchShiftPlugin/Effect/InstantEffect.h @@ -1,14 +1,14 @@ #pragma once -#include +#include -class InstantCore : public Core +class InstantEffect : public Effect { public: - InstantCore(const double samplerate, const int blocksize, const int dftsize, const int overlap); - ~InstantCore(); + InstantEffect(const double samplerate, const int blocksize, const int dftsize, const int overlap); + ~InstantEffect(); int latency() const override; bool compatible(const int blocksize) const override; diff --git a/src/StftPitchShiftPlugin/Processor.cpp b/src/StftPitchShiftPlugin/Processor.cpp index ef49ac7..da68b21 100644 --- a/src/StftPitchShiftPlugin/Processor.cpp +++ b/src/StftPitchShiftPlugin/Processor.cpp @@ -1,7 +1,7 @@ #include -#include -#include +#include +#include #include @@ -16,31 +16,31 @@ Processor::Processor() : parameters->onnormalize([&]() { std::lock_guard lock(mutex); - if (core) { core->normalize(parameters->normalize()); } + if (effect) { effect->normalize(parameters->normalize()); } }); parameters->onquefrency([&]() { std::lock_guard lock(mutex); - if (core) { core->quefrency(parameters->quefrency()); } + if (effect) { effect->quefrency(parameters->quefrency()); } }); parameters->ontimbre([&]() { std::lock_guard lock(mutex); - if (core) { core->timbre(parameters->timbre()); } + if (effect) { effect->timbre(parameters->timbre()); } }); parameters->onpitch([&]() { std::lock_guard lock(mutex); - if (core) { core->pitch(parameters->pitch()); } + if (effect) { effect->pitch(parameters->pitch()); } }); parameters->onreset([&]() { std::lock_guard lock(mutex); - if (state) { resetCore(state.value()); } + if (state) { resetEffect(state.value()); } }); } @@ -102,7 +102,7 @@ void Processor::prepareToPlay(double samplerate, int blocksize) std::lock_guard lock(mutex); state = std::nullopt; - core = nullptr; + effect = nullptr; if (samplerate < 1) { @@ -122,7 +122,7 @@ void Processor::prepareToPlay(double samplerate, int blocksize) try { - resetCore(state.value()); + resetEffect(state.value()); } catch(const std::exception& exception) { @@ -139,7 +139,7 @@ void Processor::releaseResources() LOG("Release resources"); state = std::nullopt; - core = nullptr; + effect = nullptr; } void Processor::processBlock(juce::AudioBuffer& audio, juce::MidiBuffer& midi) @@ -184,11 +184,11 @@ void Processor::processBlock(juce::AudioBuffer& audio, juce::MidiBuffer& if (parameters->bypass()) { - core->dry(input, output); + effect->dry(input, output); } else { - core->wet(input, output); + effect->wet(input, output); } }; @@ -211,11 +211,11 @@ void Processor::processBlock(juce::AudioBuffer& audio, juce::MidiBuffer& { process_stereo_output("state is not initialized"); } - else if (!core) + else if (!effect) { - process_stereo_output("core is not initialized"); + process_stereo_output("effect is not initialized"); } - else if (!core->compatible(channel_samples)) + else if (!effect->compatible(channel_samples)) { State oldstate = state.value(); State newstate = oldstate; @@ -226,7 +226,7 @@ void Processor::processBlock(juce::AudioBuffer& audio, juce::MidiBuffer& try { - resetCore(newstate); + resetEffect(newstate); state = newstate; @@ -264,7 +264,7 @@ void Processor::processBlock(juce::AudioBuffer& audio, juce::MidiBuffer& } } -void Processor::resetCore(const State& state) +void Processor::resetEffect(const State& state) { const bool lowlatency = parameters->lowlatency(); @@ -273,11 +273,11 @@ void Processor::resetCore(const State& state) const int dftsize = parameters->dftsize(blocksize); const int overlap = parameters->overlap(blocksize); - LOG("Reset core (dftsize %d, overlap %d)", dftsize, overlap); + LOG("Reset effect (dftsize %d, overlap %d)", dftsize, overlap); if (lowlatency) { - core = std::make_unique( + effect = std::make_unique( samplerate, blocksize, dftsize, @@ -285,19 +285,19 @@ void Processor::resetCore(const State& state) } else { - core = std::make_unique( + effect = std::make_unique( samplerate, blocksize, dftsize, overlap); } - core->normalize(parameters->normalize()); - core->quefrency(parameters->quefrency()); - core->timbre(parameters->timbre()); - core->pitch(parameters->pitch()); + effect->normalize(parameters->normalize()); + effect->quefrency(parameters->quefrency()); + effect->timbre(parameters->timbre()); + effect->pitch(parameters->pitch()); - const int latency = core->latency(); + const int latency = effect->latency(); LOG("Latency %d (%d ms)", latency, static_cast(1e+3 * latency / samplerate)); diff --git a/src/StftPitchShiftPlugin/Processor.h b/src/StftPitchShiftPlugin/Processor.h index 1dd437d..a77189f 100644 --- a/src/StftPitchShiftPlugin/Processor.h +++ b/src/StftPitchShiftPlugin/Processor.h @@ -3,8 +3,8 @@ #include #include -#include #include +#include #include class Processor final : public juce::AudioProcessor @@ -53,10 +53,10 @@ class Processor final : public juce::AudioProcessor std::mutex mutex; std::optional state; - std::unique_ptr core; + std::unique_ptr effect; std::shared_ptr parameters; - void resetCore(const State& state); + void resetEffect(const State& state); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Processor)