From d6d4af153960a5f9bbb449141f1ef04d494af53d Mon Sep 17 00:00:00 2001 From: Chris Cannam Date: Mon, 7 Jul 2008 18:54:18 +0000 Subject: [PATCH] * Add warning if -c option and something conflicting with it are both given * Fixes for mingw32 compile * Fix a couple of compiler warnings --- src/AudioCurve.cpp | 2 +- src/StretcherImpl.cpp | 4 ++-- src/StretcherProcess.cpp | 8 ++++---- src/bsd-3rdparty/getopt/getopt.c | 10 ---------- src/main.cpp | 18 ++++++++++++------ src/sysutils.h | 27 ++++++++++++++++++--------- src/vamp/RubberBandVampPlugin.cpp | 5 +---- 7 files changed, 38 insertions(+), 36 deletions(-) diff --git a/src/AudioCurve.cpp b/src/AudioCurve.cpp index e7bb1ec..118caf4 100644 --- a/src/AudioCurve.cpp +++ b/src/AudioCurve.cpp @@ -35,7 +35,7 @@ AudioCurve::process(const double *R__ mag, size_t increment) { cerr << "WARNING: Using inefficient AudioCurve::process(double)" << endl; float *tmp = new float[m_windowSize]; - for (int i = 0; i < m_windowSize; ++i) tmp[i] = float(mag[i]); + for (int i = 0; i < int(m_windowSize); ++i) tmp[i] = float(mag[i]); float df = process(tmp, increment); delete[] tmp; return df; diff --git a/src/StretcherImpl.cpp b/src/StretcherImpl.cpp index 799f533..da359f2 100644 --- a/src/StretcherImpl.cpp +++ b/src/StretcherImpl.cpp @@ -249,7 +249,7 @@ RubberBandStretcher::Impl::setPitchScale(double fs) m_pitchScale != 1.f) { // resampling mode has changed - for (int c = 0; c < m_channels; ++c) { + for (int c = 0; c < int(m_channels); ++c) { if (m_channelData[c]->resampler) { m_channelData[c]->resampler->reset(); } @@ -932,7 +932,7 @@ RubberBandStretcher::Impl::calculateStretch() if (i >= m_silence.size()) break; if (m_silence[i]) ++history; else history = 0; - if (history >= (m_windowSize / m_increment) && increments[i] >= 0) { + if (history >= int(m_windowSize / m_increment) && increments[i] >= 0) { increments[i] = -increments[i]; if (m_debugLevel > 1) { std::cerr << "phase reset on silence (silent history == " diff --git a/src/StretcherProcess.cpp b/src/StretcherProcess.cpp index 9ff6bee..7f14005 100644 --- a/src/StretcherProcess.cpp +++ b/src/StretcherProcess.cpp @@ -504,11 +504,11 @@ RubberBandStretcher::Impl::calculateIncrements(size_t &phaseIncrementRtn, if (silent) ++m_silentHistory; else m_silentHistory = 0; - if (m_silentHistory >= (m_windowSize / m_increment) && !phaseReset) { + if (m_silentHistory >= int(m_windowSize / m_increment) && !phaseReset) { phaseReset = true; if (m_debugLevel > 1) { - std::cerr << "calculateIncrements: phase reset on silence (silent history == " - << m_silentHistory << ")" << std::endl; + cerr << "calculateIncrements: phase reset on silence (silent history == " + << m_silentHistory << ")" << endl; } } } @@ -1067,7 +1067,7 @@ RubberBandStretcher::Impl::writeChunk(size_t channel, size_t shiftIncrement, boo windowAccumulator[i] = 0.0f; } - if (cd.accumulatorFill > si) { + if (int(cd.accumulatorFill) > si) { cd.accumulatorFill -= si; } else { cd.accumulatorFill = 0; diff --git a/src/bsd-3rdparty/getopt/getopt.c b/src/bsd-3rdparty/getopt/getopt.c index 4cfe746..ce9abb3 100644 --- a/src/bsd-3rdparty/getopt/getopt.c +++ b/src/bsd-3rdparty/getopt/getopt.c @@ -31,19 +31,9 @@ * SUCH DAMAGE. */ -/*#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95"; -#endif /* LIBC_SCCS and not lint -#include -//__FBSDID("$FreeBSD: src/lib/libc/stdlib/getopt.c,v 1.6 2002/03/29 22:43:42 markm Exp $"); - -#include "namespace.h"*/ #include #include #include -/*#include "un-namespace.h"*/ - -/*#include "libc_private.h"*/ int opterr = 1, /* if error message should be printed */ optind = 1, /* index into parent argv vector */ diff --git a/src/main.cpp b/src/main.cpp index 8672a55..6938b22 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -22,7 +22,7 @@ #include #include "sysutils.h" -#ifdef _WIN32 +#ifdef __MSVC__ #include "bsd-3rdparty/getopt/getopt.h" #else #include @@ -78,6 +78,7 @@ int main(int argc, char **argv) bool hqpitch = false; bool softening = true; bool formant = false; + bool crispchanged = false; int crispness = -1; bool help = false; bool version = false; @@ -138,11 +139,11 @@ int main(int argc, char **argv) case 'F': formant = true; break; case '0': threading = 1; break; case '@': threading = 2; break; - case '1': transients = NoTransients; break; - case '2': peaklock = false; break; - case '3': longwin = true; break; - case '4': shortwin = true; break; - case '8': transients = BandLimitedTransients; break; + case '1': transients = NoTransients; crispchanged = true; break; + case '2': peaklock = false; crispchanged = true; break; + case '3': longwin = true; crispchanged = true; break; + case '4': shortwin = true; crispchanged = true; break; + case '8': transients = BandLimitedTransients; crispchanged = true; break; case '9': softening = false; break; case '%': hqpitch = true; break; case 'c': crispness = atoi(optarg); break; @@ -215,6 +216,11 @@ int main(int argc, char **argv) return 2; } + if (crispness >= 0 && crispchanged) { + cerr << "WARNING: Both crispness option and transients, peaklock or window options" << endl; + cerr << " provided -- crispness will override these other options" << endl; + } + switch (crispness) { case -1: crispness = 4; break; case 0: transients = NoTransients; peaklock = false; longwin = true; shortwin = false; break; diff --git a/src/sysutils.h b/src/sysutils.h index f7a1bfe..1c441d6 100644 --- a/src/sysutils.h +++ b/src/sysutils.h @@ -15,8 +15,25 @@ #ifndef _RUBBERBAND_SYSINFO_H_ #define _RUBBERBAND_SYSINFO_H_ -#ifdef _WIN32 +#ifdef __MSVC__ #include "bsd-3rdparty/float_cast/float_cast.h" +#define R__ __restrict +#endif + +#ifdef __GNUC__ +#define R__ __restrict__ +#endif + +#ifndef R__ +#define R__ +#endif + +#ifdef __MINGW32__ +#include +#endif + +#ifdef __MSVC__ +#define alloca _alloca #endif namespace RubberBand { @@ -25,19 +42,11 @@ extern bool system_is_multiprocessor(); #ifdef _WIN32 -#define R__ __restrict - struct timeval { long tv_sec; long tv_usec; }; int gettimeofday(struct timeval *p, void *tz); void usleep(unsigned long); -#define alloca _alloca - -#else - -#define R__ __restrict__ - #endif } diff --git a/src/vamp/RubberBandVampPlugin.cpp b/src/vamp/RubberBandVampPlugin.cpp index 12486ca..9dfe4ff 100644 --- a/src/vamp/RubberBandVampPlugin.cpp +++ b/src/vamp/RubberBandVampPlugin.cpp @@ -15,13 +15,10 @@ #include "RubberBandVampPlugin.h" #include "StretchCalculator.h" +#include "sysutils.h" #include -#ifdef _WIN32 -#include "bsd-3rdparty/float_cast/float_cast.h" -#endif - using std::string; using std::vector; using std::cerr;