Mercurial > hg > vamp-plugin-sdk
diff src/vamp-sdk/FFT.cpp @ 501:90571dcc371a vamp-kiss-naming
Extensively rename things in the KissFFT headers to use a Vamp prefix. The motivation is not to change anything about the Vamp SDK library builds, but to avoid confusion in case any other code (for example that pulls in the Vamp SDK as part of a wider project definition) accidentally includes these headers instead of, or as well as, some other copy of KissFFT.
author | Chris Cannam |
---|---|
date | Tue, 30 Jan 2018 09:56:46 +0000 |
parents | d132b92ec65d |
children | df32b473b9b6 |
line wrap: on
line diff
--- a/src/vamp-sdk/FFT.cpp Mon Dec 11 13:22:11 2017 +0000 +++ b/src/vamp-sdk/FFT.cpp Tue Jan 30 09:56:46 2018 +0000 @@ -51,15 +51,17 @@ namespace Vamp { +using namespace Kiss; + void FFT::forward(unsigned int un, const double *ri, const double *ii, double *ro, double *io) { int n(un); - Kiss::kiss_fft_cfg c = Kiss::kiss_fft_alloc(n, false, 0, 0); - Kiss::kiss_fft_cpx *in = new Kiss::kiss_fft_cpx[n]; - Kiss::kiss_fft_cpx *out = new Kiss::kiss_fft_cpx[n]; + vamp_kiss_fft_cfg c = vamp_kiss_fft_alloc(n, false, 0, 0); + vamp_kiss_fft_cpx *in = new vamp_kiss_fft_cpx[n]; + vamp_kiss_fft_cpx *out = new vamp_kiss_fft_cpx[n]; for (int i = 0; i < n; ++i) { in[i].r = ri[i]; in[i].i = 0; @@ -69,12 +71,12 @@ in[i].i = ii[i]; } } - kiss_fft(c, in, out); + vamp_kiss_fft(c, in, out); for (int i = 0; i < n; ++i) { ro[i] = out[i].r; io[i] = out[i].i; } - Kiss::kiss_fft_free(c); + vamp_kiss_fft_free(c); delete[] in; delete[] out; } @@ -85,9 +87,9 @@ double *ro, double *io) { int n(un); - Kiss::kiss_fft_cfg c = Kiss::kiss_fft_alloc(n, true, 0, 0); - Kiss::kiss_fft_cpx *in = new Kiss::kiss_fft_cpx[n]; - Kiss::kiss_fft_cpx *out = new Kiss::kiss_fft_cpx[n]; + vamp_kiss_fft_cfg c = vamp_kiss_fft_alloc(n, true, 0, 0); + vamp_kiss_fft_cpx *in = new vamp_kiss_fft_cpx[n]; + vamp_kiss_fft_cpx *out = new vamp_kiss_fft_cpx[n]; for (int i = 0; i < n; ++i) { in[i].r = ri[i]; in[i].i = 0; @@ -97,13 +99,13 @@ in[i].i = ii[i]; } } - kiss_fft(c, in, out); + vamp_kiss_fft(c, in, out); double scale = 1.0 / double(n); for (int i = 0; i < n; ++i) { ro[i] = out[i].r * scale; io[i] = out[i].i * scale; } - Kiss::kiss_fft_free(c); + vamp_kiss_fft_free(c); delete[] in; delete[] out; } @@ -113,14 +115,14 @@ public: D(int n) : m_n(n), - m_fconf(Kiss::kiss_fft_alloc(n, false, 0, 0)), - m_iconf(Kiss::kiss_fft_alloc(n, true, 0, 0)), - m_ci(new Kiss::kiss_fft_cpx[m_n]), - m_co(new Kiss::kiss_fft_cpx[m_n]) { } + m_fconf(vamp_kiss_fft_alloc(n, false, 0, 0)), + m_iconf(vamp_kiss_fft_alloc(n, true, 0, 0)), + m_ci(new vamp_kiss_fft_cpx[m_n]), + m_co(new vamp_kiss_fft_cpx[m_n]) { } ~D() { - Kiss::kiss_fftr_free(m_fconf); - Kiss::kiss_fftr_free(m_iconf); + vamp_kiss_fftr_free(m_fconf); + vamp_kiss_fftr_free(m_iconf); delete[] m_ci; delete[] m_co; } @@ -130,7 +132,7 @@ m_ci[i].r = ci[i*2]; m_ci[i].i = ci[i*2+1]; } - Kiss::kiss_fft(m_fconf, m_ci, m_co); + vamp_kiss_fft(m_fconf, m_ci, m_co); for (int i = 0; i < m_n; ++i) { co[i*2] = m_co[i].r; co[i*2+1] = m_co[i].i; @@ -142,7 +144,7 @@ m_ci[i].r = ci[i*2]; m_ci[i].i = ci[i*2+1]; } - Kiss::kiss_fft(m_iconf, m_ci, m_co); + vamp_kiss_fft(m_iconf, m_ci, m_co); double scale = 1.0 / double(m_n); for (int i = 0; i < m_n; ++i) { co[i*2] = m_co[i].r * scale; @@ -152,10 +154,10 @@ private: int m_n; - Kiss::kiss_fft_cfg m_fconf; - Kiss::kiss_fft_cfg m_iconf; - Kiss::kiss_fft_cpx *m_ci; - Kiss::kiss_fft_cpx *m_co; + vamp_kiss_fft_cfg m_fconf; + vamp_kiss_fft_cfg m_iconf; + vamp_kiss_fft_cpx *m_ci; + vamp_kiss_fft_cpx *m_co; }; FFTComplex::FFTComplex(unsigned int n) : @@ -185,15 +187,15 @@ public: D(int n) : m_n(n), - m_fconf(Kiss::kiss_fftr_alloc(n, false, 0, 0)), - m_iconf(Kiss::kiss_fftr_alloc(n, true, 0, 0)), - m_ri(new Kiss::kiss_fft_scalar[m_n]), - m_ro(new Kiss::kiss_fft_scalar[m_n]), - m_freq(new Kiss::kiss_fft_cpx[n/2+1]) { } + m_fconf(vamp_kiss_fftr_alloc(n, false, 0, 0)), + m_iconf(vamp_kiss_fftr_alloc(n, true, 0, 0)), + m_ri(new vamp_kiss_fft_scalar[m_n]), + m_ro(new vamp_kiss_fft_scalar[m_n]), + m_freq(new vamp_kiss_fft_cpx[n/2+1]) { } ~D() { - Kiss::kiss_fftr_free(m_fconf); - Kiss::kiss_fftr_free(m_iconf); + vamp_kiss_fftr_free(m_fconf); + vamp_kiss_fftr_free(m_iconf); delete[] m_ri; delete[] m_ro; delete[] m_freq; @@ -201,10 +203,10 @@ void forward(const double *ri, double *co) { for (int i = 0; i < m_n; ++i) { - // in case kiss_fft_scalar is float + // in case vamp_kiss_fft_scalar is float m_ri[i] = ri[i]; } - Kiss::kiss_fftr(m_fconf, m_ri, m_freq); + vamp_kiss_fftr(m_fconf, m_ri, m_freq); int hs = m_n/2 + 1; for (int i = 0; i < hs; ++i) { co[i*2] = m_freq[i].r; @@ -218,7 +220,7 @@ m_freq[i].r = ci[i*2]; m_freq[i].i = ci[i*2+1]; } - Kiss::kiss_fftri(m_iconf, m_freq, m_ro); + vamp_kiss_fftri(m_iconf, m_freq, m_ro); double scale = 1.0 / double(m_n); for (int i = 0; i < m_n; ++i) { ro[i] = m_ro[i] * scale; @@ -227,11 +229,11 @@ private: int m_n; - Kiss::kiss_fftr_cfg m_fconf; - Kiss::kiss_fftr_cfg m_iconf; - Kiss::kiss_fft_scalar *m_ri; - Kiss::kiss_fft_scalar *m_ro; - Kiss::kiss_fft_cpx *m_freq; + vamp_kiss_fftr_cfg m_fconf; + vamp_kiss_fftr_cfg m_iconf; + vamp_kiss_fft_scalar *m_ri; + vamp_kiss_fft_scalar *m_ro; + vamp_kiss_fft_cpx *m_freq; }; FFTReal::FFTReal(unsigned int n) :