Skip to content

Commit

Permalink
Move FFT to signalsmith::fft::
Browse files Browse the repository at this point in the history
  • Loading branch information
geraintluff committed Jan 9, 2022
1 parent 70baeec commit dd15211
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion delay.h
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ namespace delay {
}

if (minimumPhase) {
signalsmith::FFT<Sample> fft(windowedSinc.size()*2, 1);
signalsmith::fft::FFT<Sample> fft(windowedSinc.size()*2, 1);
windowedSinc.resize(fft.size(), 0);
std::vector<std::complex<Sample>> spectrum(fft.size());
std::vector<std::complex<Sample>> cepstrum(fft.size());
Expand Down
17 changes: 7 additions & 10 deletions fft.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
#include <complex>
#include <cmath>

namespace signalsmith {
namespace signalsmith { namespace fft {

#ifndef DOXYGEN_SHOULD_SKIP_THIS
namespace _fft_impl {

template <typename V>
Expand Down Expand Up @@ -63,7 +62,6 @@ namespace signalsmith {
}
};
}
#endif

template<typename V>
class FFT {
Expand Down Expand Up @@ -119,8 +117,8 @@ namespace signalsmith {
if (!foundStep) {
for (size_t i = 0; i < subLength; ++i) {
for (size_t f = 0; f < factor; ++f) {
V phase = 2*M_PI*i*f/length;
complex twiddle = {std::cos(phase), -std::sin(phase)};
double phase = 2*M_PI*i*f/length;
complex twiddle = {V(std::cos(phase)), V(-std::sin(phase))};
twiddleVector.push_back(twiddle);
}
}
Expand Down Expand Up @@ -200,8 +198,8 @@ namespace signalsmith {
for (size_t f = 0; f < factor; ++f) {
complex sum = working[0];
for (size_t i = 1; i < factor; ++i) {
V phase = 2*M_PI*f*i/factor;
complex twiddle = {std::cos(phase), -std::sin(phase)};
double phase = 2*M_PI*f*i/factor;
complex twiddle = {V(std::cos(phase)), V(-std::sin(phase))};
sum += _fft_impl::complexMul<inverse>(working[i], twiddle);
}
data[f*stride] = sum;
Expand Down Expand Up @@ -505,7 +503,6 @@ namespace signalsmith {
struct ModifiedRealFFT : public RealFFT<V, FFTOptions::halfFreqShift> {
using RealFFT<V, FFTOptions::halfFreqShift>::RealFFT;
};
}

#undef SIGNALSMITH_FFT_NAMESPACE
#endif // SIGNALSMITH_FFT_V5
}} // namespace
#endif // include guard
2 changes: 1 addition & 1 deletion spectral.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace spectral {
*/
template<typename Sample>
class WindowedFFT {
using MRFFT = signalsmith::ModifiedRealFFT<Sample>;
using MRFFT = signalsmith::fft::ModifiedRealFFT<Sample>;
using Complex = std::complex<Sample>;
MRFFT mrfft{2};

Expand Down

0 comments on commit dd15211

Please sign in to comment.