From 7be734f75b80839dcdec209fa1449058392fc0ee Mon Sep 17 00:00:00 2001 From: Chris Cannam Date: Wed, 20 Oct 2021 13:35:06 +0100 Subject: [PATCH] Fix compiler warnings with VC++ --- src/StretcherProcess.cpp | 2 +- src/dsp/BQResampler.cpp | 24 +++++++++++++----------- src/dsp/BQResampler.h | 2 +- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/StretcherProcess.cpp b/src/StretcherProcess.cpp index cf6f545..337837e 100644 --- a/src/StretcherProcess.cpp +++ b/src/StretcherProcess.cpp @@ -784,7 +784,7 @@ RubberBandStretcher::Impl::modifyChunk(size_t channel, cerr << "phase reset: leaving phases unmodified" << endl; } - const process_t rate = m_sampleRate; + const process_t rate = process_t(m_sampleRate); const int count = m_fftSize / 2; bool unchanged = cd.unchanged && (outputIncrement == m_increment); diff --git a/src/dsp/BQResampler.cpp b/src/dsp/BQResampler.cpp index e4832b9..8b527c3 100644 --- a/src/dsp/BQResampler.cpp +++ b/src/dsp/BQResampler.cpp @@ -146,9 +146,9 @@ BQResampler::resampleInterleaved(float *const out, const float *const in, int incount, double ratio, - bool final) { - - int fade_length = round(m_initial_rate / 1000.0); + bool final) +{ + int fade_length = int(round(m_initial_rate / 1000.0)); if (fade_length < 6) { fade_length = 6; } @@ -282,9 +282,9 @@ BQResampler::kaiser_params(double attenuation, int &len) const { if (attenuation > 21.0) { - len = 1 + ceil((attenuation - 7.95) / (2.285 * transition)); + len = 1 + int(ceil((attenuation - 7.95) / (2.285 * transition))); } else { - len = 1 + ceil(5.79 / transition); + len = 1 + int(ceil(5.79 / transition)); } beta = 0.0; if (attenuation > 50.0) { @@ -343,8 +343,10 @@ BQResampler::sinc_multiply(double peak_to_zero, vector &buf) const } BQResampler::params -BQResampler::fill_params(double ratio, int num, int denom) const +BQResampler::fill_params(double ratio, double numd, double denomd) const { + int num = int(round(numd)); + int denom = int(round(denomd)); params p; int g = gcd (num, denom); p.ratio = ratio; @@ -420,8 +422,8 @@ BQResampler::phase_data_for(vector &target_phase_data, while (next_phase < 0) next_phase += input_spacing; next_phase %= input_spacing; double dspace = double(input_spacing); - int zip_length = ceil(double(filter_length - p) / dspace); - int drop = ceil(double(max(0, output_spacing - p)) / dspace); + int zip_length = int(ceil(double(filter_length - p) / dspace)); + int drop = int(ceil(double(max(0, output_spacing - p)) / dspace)); phase_rec phase; phase.next_phase = next_phase; phase.drop = drop; @@ -467,7 +469,7 @@ BQResampler::make_filter(int filter_length, double peak_to_zero) const double m = double(k_length - 1) / double(filter_length - 1); for (int i = 0; i < filter_length; ++i) { double ix = i * m; - int iix = floor(ix); + int iix = int(floor(ix)); double remainder = ix - iix; double value = 0.0; value += kaiser[iix] * (1.0 - remainder); @@ -575,7 +577,7 @@ BQResampler::state_for_ratio(BQResampler::state &target_state, int phases_then = int(prev_state.phase_info.size()); double distance_through = double(prev_state.current_phase) / double(phases_then); - target_state.current_phase = round(n_phases * distance_through); + target_state.current_phase = int(round(n_phases * distance_through)); if (target_state.current_phase >= n_phases) { target_state.current_phase = n_phases - 1; } @@ -616,7 +618,7 @@ BQResampler::reconstruct_one(state *s) const s->buffer[s->left + i * m_channels + s->current_channel]; int filter_index = i * s->parameters.numerator + s->current_phase; double proto_index = m * filter_index; - int iix = floor(proto_index); + int iix = int(floor(proto_index)); double remainder = proto_index - iix; double filter_value = m_prototype[iix] * (1.0 - remainder); filter_value += m_prototype[iix+1] * remainder; diff --git a/src/dsp/BQResampler.h b/src/dsp/BQResampler.h index 8a441f8..21fef43 100644 --- a/src/dsp/BQResampler.h +++ b/src/dsp/BQResampler.h @@ -139,7 +139,7 @@ private: int minlen, int maxlen) const; void sinc_multiply(double peak_to_zero, std::vector &buf) const; - params fill_params(double ratio, int num, int denom) const; + params fill_params(double ratio, double numd, double denomd) const; params pick_params(double ratio) const; std::vector make_filter(int filter_length,