Skip to content

Commit

Permalink
Merge pull request #94 from Laguna1989/refactor/changeKernelName
Browse files Browse the repository at this point in the history
Refactor kernel variable name
  • Loading branch information
Laguna1989 authored Feb 1, 2024
2 parents d1c1c81 + 64a0986 commit 1f18c00
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions impl/oalpp/effects/utility/convolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ std::vector<float> doFFT(std::vector<std::complex<float>> const& samples)
} // namespace

Convolution::Convolution(std::vector<float> const& kernel)
: m_kernel { doFFT(kernel) }
: m_kernelTransformed { doFFT(kernel) }
{
}

Expand All @@ -63,14 +63,14 @@ std::vector<float> Convolution::process(std::vector<float> const& input)
// perform fft on input
auto const inputTransformed = doFFT(input);
auto const biggerSize
= static_cast<std::size_t>(std::max(inputTransformed.size(), m_kernel.size()));
= static_cast<std::size_t>(std::max(inputTransformed.size(), m_kernelTransformed.size()));

// convolution in frequency space is just a pairwise multiplication
std::vector<std::complex<float>> multipliedTransformed;
multipliedTransformed.resize(biggerSize);

for (auto i = 0U; i != biggerSize; ++i) {
auto const kernelValue = i < m_kernel.size() ? m_kernel[i] : 0.0f;
auto const kernelValue = i < m_kernelTransformed.size() ? m_kernelTransformed[i] : 0.0f;
auto const inputValue = i < inputTransformed.size() ? inputTransformed[i] : 0.0f;
multipliedTransformed[i] = kernelValue * inputValue;
}
Expand Down
2 changes: 1 addition & 1 deletion impl/oalpp/effects/utility/convolution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Convolution : public MonoEffectInterface {
std::vector<float> process(std::vector<float> const& input) override;

private:
std::vector<std::complex<float>> m_kernel {};
std::vector<std::complex<float>> m_kernelTransformed {};
};

} // namespace utility
Expand Down

0 comments on commit 1f18c00

Please sign in to comment.