From 308e2ad6325ae2a902c8fea04aa14bfe0399265e Mon Sep 17 00:00:00 2001 From: Chris Cannam Date: Thu, 13 Dec 2007 17:59:21 +0000 Subject: [PATCH] * Fix incorrect option parsing (-T not recognised, pitch shift mishandled) * Fix incorrect #ifdef nesting in FFT.cpp * Ensure pkg-config directory is created on make install if necessary --- Makefile.in | 3 ++- src/FFT.cpp | 10 +++++----- src/main.cpp | 11 ++++++++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Makefile.in b/Makefile.in index 9d4666f..eef0d93 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,6 +1,6 @@ CXX := @CXX@ -CXXFLAGS := -DUSE_PTHREADS -DHAVE_LIBSAMPLERATE -DHAVE_FFTW3 -DFFTW_DOUBLE_ONLY @CXXFLAGS@ @SRC_CFLAGS@ @SNDFILE_CFLAGS@ @FFTW_CFLAGS@ @Vamp_CFLAGS@ -Irubberband -Isrc $(OPTFLAGS) +CXXFLAGS := -DFFTW_DOUBLE_ONLY @CXXFLAGS@ @SRC_CFLAGS@ @SNDFILE_CFLAGS@ @FFTW_CFLAGS@ @Vamp_CFLAGS@ -Irubberband -Isrc $(OPTFLAGS) LDFLAGS := @LDFLAGS@ -lpthread $(LDFLAGS) LIBRARY_LIBS := @SRC_LIBS@ @FFTW_LIBS@ @@ -114,6 +114,7 @@ install: all $(MKDIR) -p $(INSTALL_LIBDIR) $(MKDIR) -p $(INSTALL_VAMPDIR) $(MKDIR) -p $(INSTALL_LADSPADIR) + $(MKDIR) -p $(INSTALL_PKGDIR) cp $(PROGRAM_TARGET) $(INSTALL_BINDIR) cp $(PUBLIC_INCLUDES) $(INSTALL_INCDIR) cp $(STATIC_TARGET) $(INSTALL_LIBDIR) diff --git a/src/FFT.cpp b/src/FFT.cpp index 8347e09..a252c69 100644 --- a/src/FFT.cpp +++ b/src/FFT.cpp @@ -72,12 +72,13 @@ public: //#define FFTW_DOUBLE_ONLY 1 //#define FFTW_FLOAT_ONLY 1 -#ifdef FFTW_DOUBLE_ONLY -#ifdef FFTW_FLOAT_ONLY +#if defined(FFTW_DOUBLE_ONLY) && defined(FFTW_FLOAT_ONLY) // Can't meaningfully define both #undef FFTW_DOUBLE_ONLY #undef FFTW_FLOAT_ONLY -#else /* !FFTW_FLOAT_ONLY */ +#endif + +#ifdef FFTW_DOUBLE_ONLY #define fftwf_complex fftw_complex #define fftwf_plan fftw_plan #define fftwf_plan_dft_r2c_1d fftw_plan_dft_r2c_1d @@ -90,7 +91,7 @@ public: #define sqrtf sqrt #define cosf cos #define sinf sin -#endif /* !FFTW_FLOAT_ONLY */ +#endif /* FFTW_DOUBLE_ONLY */ #ifdef FFTW_FLOAT_ONLY #define fftw_complex fftwf_complex @@ -475,7 +476,6 @@ D_FFTW::m_extantd = 0; Mutex D_FFTW::m_extantMutex; -#endif class D_Cross : public FFTImpl { diff --git a/src/main.cpp b/src/main.cpp index c4f9259..db5a218 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -39,7 +39,7 @@ int main(int argc, char **argv) int c; double ratio = 1.0; - double pitchshift = 1.0; + double pitchshift = 0.0; double frequencyshift = 1.0; int debug = 0; bool realtime = false; @@ -94,7 +94,7 @@ int main(int argc, char **argv) { 0, 0, 0 } }; - c = getopt_long(argc, argv, "t:p:d:RPc:f:qh", longOpts, &optionIndex); + c = getopt_long(argc, argv, "t:p:d:RPc:f:T:qh", longOpts, &optionIndex); if (c == -1) break; switch (c) { @@ -266,10 +266,15 @@ int main(int argc, char **argv) break; } - if (pitchshift != 1.0) { + if (pitchshift != 0.0) { frequencyshift *= pow(2.0, pitchshift / 12); } + if (debug > 0) { + cerr << "Time ratio: " << ratio << endl; + cerr << "Frequency ratio: " << frequencyshift << endl; + } + #ifdef _WIN32 RubberBand:: #endif