From 09dadc239a9a7f593c705b954e90fdb7d4b43708 Mon Sep 17 00:00:00 2001 From: Chris Cannam Date: Tue, 27 Nov 2007 14:12:04 +0000 Subject: [PATCH] * Default to using double-precision FFTs only when linking against FFTW, to avoid having to -lfftw3 -lfftw3f --- Makefile.in | 39 ++-- configure | 286 ++++++++++++++------------ configure.ac | 5 +- src/FFT.cpp | 42 +++- src/ladspa/RubberBandPitchShifter.cpp | 7 + src/main.cpp | 8 +- 6 files changed, 227 insertions(+), 160 deletions(-) diff --git a/Makefile.in b/Makefile.in index e70cab4..9cd7ffc 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,23 +1,26 @@ -all: bin lib bin/rubberband lib/librubberband.a lib/vamp-rubberband.so lib/ladspa-rubberband.so +CXX := @CXX@ +CXXFLAGS := @CXXFLAGS@ @SRC_CFLAGS@ @SNDFILE_CFLAGS@ @FFTW_CFLAGS@ @Vamp_CFLAGS@ -Irubberband -Isrc $(CXXFLAGS) +LDFLAGS := @LDFLAGS@ -lpthread $(LDFLAGS) -CXX = @CXX@ -CXXFLAGS = @CXXFLAGS@ @SRC_CFLAGS@ @SNDFILE_CFLAGS@ @FFTW_CFLAGS@ @FFTWF_CFLAGS@ @Vamp_CFLAGS@ -Irubberband -Isrc -LDFLAGS = @LDFLAGS@ +LIBRARY_LIBS := @SRC_LIBS@ @FFTW_LIBS@ +PROGRAM_LIBS := @SNDFILE_LIBS@ $(LIBRARY_LIBS) +VAMP_PLUGIN_LIBS := @Vamp_LIBS@ $(LIBRARY_LIBS) +LADSPA_PLUGIN_LIBS := $(LIBRARY_LIBS) -LIBRARY_LIBS = @SRC_LIBS@ @FFTW_LIBS@ @FFTWF_LIBS@ -PROGRAM_LIBS = @SNDFILE_LIBS@ $(LIBRARY_LIBS) -VAMP_PLUGIN_LIBS = @Vamp_LIBS@ $(LIBRARY_LIBS) -LADSPA_PLUGIN_LIBS = $(LIBRARY_LIBS) +MKDIR := mkdir +AR := ar -MKDIR = mkdir -AR = ar +DYNAMIC_LDFLAGS := -shared -Wl,-Bsymbolic +DYNAMIC_EXTENSION := .so -PROGRAM_TARGET := bin/rubberband -STATIC_TARGET := lib/librubberband.a -DYNAMIC_TARGET := lib/librubberband.so -VAMP_TARGET := lib/vamp-rubberband.so -LADSPA_TARGET := lib/ladspa-rubberband.so +PROGRAM_TARGET := bin/rubberband +STATIC_TARGET := lib/librubberband.a +DYNAMIC_TARGET := lib/librubberband$(DYNAMIC_EXTENSION) +VAMP_TARGET := lib/vamp-rubberband$(DYNAMIC_EXTENSION) +LADSPA_TARGET := lib/ladspa-rubberband$(DYNAMIC_EXTENSION) + +all: bin lib $(PROGRAM_TARGET) $(STATIC_TARGET) $(DYNAMIC_TARGET) $(VAMP_TARGET) $(LADSPA_TARGET) PUBLIC_INCLUDES := \ rubberband/TimeStretcher.h \ @@ -83,13 +86,13 @@ $(STATIC_TARGET): $(LIBRARY_OBJECTS) $(AR) rsc $@ $^ $(DYNAMIC_TARGET): $(LIBRARY_OBJECTS) - $(CXX) -shared -Wl,-Bsymbolic $^ -o $@ $(LIBRARY_LIBS) $(LDFLAGS) + $(CXX) $(DYNAMIC_LDFLAGS) $^ -o $@ $(LIBRARY_LIBS) $(LDFLAGS) $(VAMP_TARGET): $(LIBRARY_OBJECTS) $(VAMP_OBJECTS) - $(CXX) -shared -Wl,-Bsymbolic -o $@ $^ $(VAMP_PLUGIN_LIBS) $(LDFLAGS) + $(CXX) $(DYNAMIC_LDFLAGS) -o $@ $^ $(VAMP_PLUGIN_LIBS) $(LDFLAGS) $(LADSPA_TARGET): $(LIBRARY_OBJECTS) $(LADSPA_OBJECTS) - $(CXX) -shared -Wl,-Bsymbolic -o $@ $^ $(LADSPA_PLUGIN_LIBS) $(LDFLAGS) + $(CXX) $(DYNAMIC_LDFLAGS) -o $@ $^ $(LADSPA_PLUGIN_LIBS) $(LDFLAGS) bin: $(MKDIR) $@ diff --git a/configure b/configure index d00ca2b..bf43e4c 100755 --- a/configure +++ b/configure @@ -670,8 +670,6 @@ SRC_CFLAGS SRC_LIBS SNDFILE_CFLAGS SNDFILE_LIBS -FFTWF_CFLAGS -FFTWF_LIBS FFTW_CFLAGS FFTW_LIBS Vamp_CFLAGS @@ -696,8 +694,6 @@ SRC_CFLAGS SRC_LIBS SNDFILE_CFLAGS SNDFILE_LIBS -FFTWF_CFLAGS -FFTWF_LIBS FFTW_CFLAGS FFTW_LIBS Vamp_CFLAGS @@ -1287,9 +1283,6 @@ Some influential environment variables: C compiler flags for SNDFILE, overriding pkg-config SNDFILE_LIBS linker flags for SNDFILE, overriding pkg-config - FFTWF_CFLAGS - C compiler flags for FFTWF, overriding pkg-config - FFTWF_LIBS linker flags for FFTWF, overriding pkg-config FFTW_CFLAGS C compiler flags for FFTW, overriding pkg-config FFTW_LIBS linker flags for FFTW, overriding pkg-config Vamp_CFLAGS C compiler flags for Vamp, overriding pkg-config @@ -4096,7 +4089,7 @@ Alternatively, you may set the environment variables SRC_CFLAGS and SRC_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. -To get pkg-config, see . +To get pkg-config, see . See \`config.log' for more details." >&5 echo "$as_me: error: The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full @@ -4106,7 +4099,7 @@ Alternatively, you may set the environment variables SRC_CFLAGS and SRC_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. -To get pkg-config, see . +To get pkg-config, see . See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } else @@ -4210,7 +4203,7 @@ Alternatively, you may set the environment variables SNDFILE_CFLAGS and SNDFILE_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. -To get pkg-config, see . +To get pkg-config, see . See \`config.log' for more details." >&5 echo "$as_me: error: The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full @@ -4220,7 +4213,7 @@ Alternatively, you may set the environment variables SNDFILE_CFLAGS and SNDFILE_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. -To get pkg-config, see . +To get pkg-config, see . See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } else @@ -4234,120 +4227,6 @@ fi -pkg_failed=no -{ echo "$as_me:$LINENO: checking for FFTWF" >&5 -echo $ECHO_N "checking for FFTWF... $ECHO_C" >&6; } - -if test -n "$PKG_CONFIG"; then - if test -n "$FFTWF_CFLAGS"; then - pkg_cv_FFTWF_CFLAGS="$FFTWF_CFLAGS" - else - if test -n "$PKG_CONFIG" && \ - { (echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"fftw3f\"") >&5 - ($PKG_CONFIG --exists --print-errors "fftw3f") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - pkg_cv_FFTWF_CFLAGS=`$PKG_CONFIG --cflags "fftw3f" 2>/dev/null` -else - pkg_failed=yes -fi - fi -else - pkg_failed=untried -fi -if test -n "$PKG_CONFIG"; then - if test -n "$FFTWF_LIBS"; then - pkg_cv_FFTWF_LIBS="$FFTWF_LIBS" - else - if test -n "$PKG_CONFIG" && \ - { (echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"fftw3f\"") >&5 - ($PKG_CONFIG --exists --print-errors "fftw3f") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - pkg_cv_FFTWF_LIBS=`$PKG_CONFIG --libs "fftw3f" 2>/dev/null` -else - pkg_failed=yes -fi - fi -else - pkg_failed=untried -fi - - - -if test $pkg_failed = yes; then - -if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then - _pkg_short_errors_supported=yes -else - _pkg_short_errors_supported=no -fi - if test $_pkg_short_errors_supported = yes; then - FFTWF_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "fftw3f"` - else - FFTWF_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "fftw3f"` - fi - # Put the nasty error message in config.log where it belongs - echo "$FFTWF_PKG_ERRORS" >&5 - - { { echo "$as_me:$LINENO: error: Package requirements (fftw3f) were not met: - -$FFTWF_PKG_ERRORS - -Consider adjusting the PKG_CONFIG_PATH environment variable if you -installed software in a non-standard prefix. - -Alternatively, you may set the environment variables FFTWF_CFLAGS -and FFTWF_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details. -" >&5 -echo "$as_me: error: Package requirements (fftw3f) were not met: - -$FFTWF_PKG_ERRORS - -Consider adjusting the PKG_CONFIG_PATH environment variable if you -installed software in a non-standard prefix. - -Alternatively, you may set the environment variables FFTWF_CFLAGS -and FFTWF_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details. -" >&2;} - { (exit 1); exit 1; }; } -elif test $pkg_failed = untried; then - { { echo "$as_me:$LINENO: error: The pkg-config script could not be found or is too old. Make sure it -is in your PATH or set the PKG_CONFIG environment variable to the full -path to pkg-config. - -Alternatively, you may set the environment variables FFTWF_CFLAGS -and FFTWF_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details. - -To get pkg-config, see . -See \`config.log' for more details." >&5 -echo "$as_me: error: The pkg-config script could not be found or is too old. Make sure it -is in your PATH or set the PKG_CONFIG environment variable to the full -path to pkg-config. - -Alternatively, you may set the environment variables FFTWF_CFLAGS -and FFTWF_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details. - -To get pkg-config, see . -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -else - FFTWF_CFLAGS=$pkg_cv_FFTWF_CFLAGS - FFTWF_LIBS=$pkg_cv_FFTWF_LIBS - { echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6; } - : -fi - - - - pkg_failed=no { echo "$as_me:$LINENO: checking for FFTW" >&5 echo $ECHO_N "checking for FFTW... $ECHO_C" >&6; } @@ -4438,7 +4317,7 @@ Alternatively, you may set the environment variables FFTW_CFLAGS and FFTW_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. -To get pkg-config, see . +To get pkg-config, see . See \`config.log' for more details." >&5 echo "$as_me: error: The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full @@ -4448,7 +4327,7 @@ Alternatively, you may set the environment variables FFTW_CFLAGS and FFTW_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. -To get pkg-config, see . +To get pkg-config, see . See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } else @@ -4607,6 +4486,151 @@ fi done +for ac_header in pthread.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( cat <<\_ASBOX +## ------------------------------------------- ## +## Report this to cannam@all-day-breakfast.com ## +## ------------------------------------------- ## +_ASBOX + ) | sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + pkg_failed=no { echo "$as_me:$LINENO: checking for Vamp" >&5 @@ -4698,7 +4722,7 @@ Alternatively, you may set the environment variables Vamp_CFLAGS and Vamp_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. -To get pkg-config, see . +To get pkg-config, see . See \`config.log' for more details." >&5 echo "$as_me: error: The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full @@ -4708,7 +4732,7 @@ Alternatively, you may set the environment variables Vamp_CFLAGS and Vamp_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. -To get pkg-config, see . +To get pkg-config, see . See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } else @@ -5413,8 +5437,6 @@ SRC_CFLAGS!$SRC_CFLAGS$ac_delim SRC_LIBS!$SRC_LIBS$ac_delim SNDFILE_CFLAGS!$SNDFILE_CFLAGS$ac_delim SNDFILE_LIBS!$SNDFILE_LIBS$ac_delim -FFTWF_CFLAGS!$FFTWF_CFLAGS$ac_delim -FFTWF_LIBS!$FFTWF_LIBS$ac_delim FFTW_CFLAGS!$FFTW_CFLAGS$ac_delim FFTW_LIBS!$FFTW_LIBS$ac_delim Vamp_CFLAGS!$Vamp_CFLAGS$ac_delim @@ -5423,7 +5445,7 @@ LIBOBJS!$LIBOBJS$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 63; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 61; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 diff --git a/configure.ac b/configure.ac index ff8fdff..83da151 100644 --- a/configure.ac +++ b/configure.ac @@ -14,15 +14,12 @@ PKG_CHECK_MODULES([SNDFILE],[sndfile]) AC_SUBST(SNDFILE_CFLAGS) AC_SUBST(SNDFILE_LIBS) -PKG_CHECK_MODULES([FFTWF],[fftw3f]) -AC_SUBST(FFTWF_CFLAGS) -AC_SUBST(FFTWF_LIBS) - PKG_CHECK_MODULES([FFTW],[fftw3]) AC_SUBST(FFTW_CFLAGS) AC_SUBST(FFTW_LIBS) AC_CHECK_HEADERS(ladspa.h) +AC_CHECK_HEADERS(pthread.h) PKG_CHECK_MODULES([Vamp],[vamp-sdk]) AC_SUBST(Vamp_CFLAGS) diff --git a/src/FFT.cpp b/src/FFT.cpp index 3594d4f..2f2cd58 100644 --- a/src/FFT.cpp +++ b/src/FFT.cpp @@ -52,6 +52,24 @@ public: +// Remove this define to make float FFTs be carried out using fftwf_* +// functions instead of converting to doubles and using fftw_*. +#define FFTW_DOUBLE_ONLY 1 + +#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 +#define fftwf_plan_dft_c2r_1d fftw_plan_dft_c2r_1d +#define fftwf_destroy_plan fftw_destroy_plan +#define fftwf_free fftw_free +#define fftwf_execute fftw_execute +#define atan2f atan2 +#define sqrtf sqrt +#define cosf cos +#define sinf sin +#endif + class D_FFTW : public FFTImpl { public: @@ -90,7 +108,11 @@ public: if (m_extantf++ == 0) load = true; m_extantMutex.unlock(); if (load) loadWisdom('f'); +#ifdef FFTW_DOUBLE_ONLY + m_fbuf = (double *)fftw_malloc(m_size * sizeof(double)); +#else m_fbuf = (float *)fftw_malloc(m_size * sizeof(float)); +#endif m_fpacked = (fftwf_complex *)fftw_malloc ((m_size/2 + 1) * sizeof(fftwf_complex)); m_fplanf = fftwf_plan_dft_r2c_1d @@ -120,6 +142,10 @@ public: void wisdom(bool save, char type) { +#ifdef FFTW_DOUBLE_ONLY + if (type == 'f') return; +#endif + const char *home = getenv("HOME"); if (!home) return; @@ -131,13 +157,18 @@ public: if (save) { switch (type) { +#ifndef FFTW_DOUBLE_ONLY case 'f': fftwf_export_wisdom_to_file(f); break; case 'd': fftw_export_wisdom_to_file(f); break; + default: break; } } else { switch (type) { +#ifndef FFTW_DOUBLE_ONLY case 'f': fftwf_import_wisdom_from_file(f); break; +#endif case 'd': fftw_import_wisdom_from_file(f); break; + default: break; } } @@ -283,15 +314,19 @@ public: } private: - unsigned int m_size; fftwf_plan m_fplanf; fftwf_plan m_fplani; +#ifdef FFTW_DOUBLE_ONLY + double *m_fbuf; +#else + float *m_fbuf; +#endif + fftwf_complex *m_fpacked; fftw_plan m_dplanf; fftw_plan m_dplani; - float *m_fbuf; - fftwf_complex *m_fpacked; double *m_dbuf; fftw_complex *m_dpacked; + unsigned int m_size; static unsigned int m_extantf; static unsigned int m_extantd; static Mutex m_extantMutex; @@ -306,6 +341,7 @@ D_FFTW::m_extantd = 0; Mutex D_FFTW::m_extantMutex; +#endif class D_Cross : public FFTImpl { diff --git a/src/ladspa/RubberBandPitchShifter.cpp b/src/ladspa/RubberBandPitchShifter.cpp index 8ab6e65..4e7f2f1 100644 --- a/src/ladspa/RubberBandPitchShifter.cpp +++ b/src/ladspa/RubberBandPitchShifter.cpp @@ -385,6 +385,13 @@ RubberBandPitchShifter::runImpl(unsigned long insamples) // std::cout << "out chunk: " << chunk << std::endl; m_outputBuffer[c]->read(m_output[c], chunk); } + + static int minr = -1; + int avail = m_outputBuffer[0]->getReadSpace(); + if (minr == -1 || (avail >= 0 && avail < minr)) { + std::cerr << "RubberBandPitchShifter::runImpl: new min remaining " << avail << " from " << minr << std::endl; + minr = avail; + } } void diff --git a/src/main.cpp b/src/main.cpp index f010abb..32da1a3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -268,6 +268,8 @@ int main(int argc, char **argv) int frame = 0; int percent = 0; + sf_seek(sndfile, 0, SEEK_SET); + if (!realtime) { if (!quiet) { @@ -278,7 +280,6 @@ int main(int argc, char **argv) int count = -1; - if (sf_seek(sndfile, frame, SEEK_SET) < 0) break; if ((count = sf_readf_float(sndfile, fbuf, ibs)) <= 0) break; for (size_t c = 0; c < channels; ++c) { @@ -306,6 +307,8 @@ int main(int argc, char **argv) if (!quiet) { cerr << "\rCalculating profile..." << endl; } + + sf_seek(sndfile, 0, SEEK_SET); } frame = 0; @@ -321,7 +324,6 @@ int main(int argc, char **argv) int count = -1; - if (sf_seek(sndfile, frame, SEEK_SET) < 0) break; if ((count = sf_readf_float(sndfile, fbuf, ibs)) < 0) break; countIn += count; @@ -446,7 +448,7 @@ int main(int argc, char **argv) struct timeval etv; (void)gettimeofday(&etv, 0); - + etv.tv_sec -= tv.tv_sec; if (etv.tv_usec < tv.tv_usec) { etv.tv_usec += 1000000;