From ef3311ea98ff0ad0689c8becd7c956620830bd27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Hock?= Date: Tue, 28 Nov 2023 22:36:30 +0100 Subject: [PATCH] Use const span to indicate the read-only input #39 --- cpp/StftPitchShift/Dump.h | 2 +- cpp/StftPitchShift/FFT.h | 8 ++++---- cpp/StftPitchShift/Normalizer.h | 4 ++-- cpp/StftPitchShift/RFFT.h | 12 ++++++------ cpp/StftPitchShift/Resampler.h | 14 +++++++------- cpp/StftPitchShift/STFT.h | 10 +++++----- cpp/StftPitchShift/StftPitchShift.cpp | 8 ++++---- cpp/StftPitchShift/StftPitchShift.h | 8 ++++---- 8 files changed, 33 insertions(+), 33 deletions(-) diff --git a/cpp/StftPitchShift/Dump.h b/cpp/StftPitchShift/Dump.h index e52dae7..a4bdfb6 100755 --- a/cpp/StftPitchShift/Dump.h +++ b/cpp/StftPitchShift/Dump.h @@ -22,7 +22,7 @@ namespace stftpitchshift } template - void operator()(const std::span data) + void operator()(const std::span data) { if (fileindex < minindex) { diff --git a/cpp/StftPitchShift/FFT.h b/cpp/StftPitchShift/FFT.h index 226218d..f27731d 100755 --- a/cpp/StftPitchShift/FFT.h +++ b/cpp/StftPitchShift/FFT.h @@ -12,11 +12,11 @@ namespace stftpitchshift virtual ~FFT() {} - virtual void fft(const std::span frame, const std::span> dft) = 0; - virtual void fft(const std::span frame, const std::span> dft) = 0; + virtual void fft(const std::span frame, const std::span> dft) = 0; + virtual void fft(const std::span frame, const std::span> dft) = 0; - virtual void ifft(const std::span> dft, const std::span frame) = 0; - virtual void ifft(const std::span> dft, const std::span frame) = 0; + virtual void ifft(const std::span> dft, const std::span frame) = 0; + virtual void ifft(const std::span> dft, const std::span frame) = 0; }; } diff --git a/cpp/StftPitchShift/Normalizer.h b/cpp/StftPitchShift/Normalizer.h index 177c27f..6e8ca49 100755 --- a/cpp/StftPitchShift/Normalizer.h +++ b/cpp/StftPitchShift/Normalizer.h @@ -15,7 +15,7 @@ class Normalizer { } - void calibrate(const std::span> data) + void calibrate(const std::span> data) { target = rms(data); } @@ -42,7 +42,7 @@ class Normalizer T target; - static T rms(const std::span> data) + static T rms(const std::span> data) { // without 1/N and sqrt diff --git a/cpp/StftPitchShift/RFFT.h b/cpp/StftPitchShift/RFFT.h index e1f9023..ccc144f 100755 --- a/cpp/StftPitchShift/RFFT.h +++ b/cpp/StftPitchShift/RFFT.h @@ -119,7 +119,7 @@ namespace stftpitchshift public: - void fft(const std::span frame, const std::span> dft) + void fft(const std::span frame, const std::span> dft) { assert(dft.size() == frame.size() / 2 + 1); @@ -147,7 +147,7 @@ namespace stftpitchshift } } - void ifft(const std::span> dft, const std::span frame) + void ifft(const std::span> dft, const std::span frame) { assert(dft.size() == frame.size() / 2 + 1); @@ -237,22 +237,22 @@ namespace stftpitchshift public: - void fft(const std::span frame, const std::span> dft) override + void fft(const std::span frame, const std::span> dft) override { precision.f.fft(frame, dft); } - void fft(const std::span frame, const std::span> dft) override + void fft(const std::span frame, const std::span> dft) override { precision.d.fft(frame, dft); } - void ifft(const std::span> dft, const std::span frame) override + void ifft(const std::span> dft, const std::span frame) override { precision.f.ifft(dft, frame); } - void ifft(const std::span> dft, const std::span frame) override + void ifft(const std::span> dft, const std::span frame) override { precision.d.ifft(dft, frame); } diff --git a/cpp/StftPitchShift/Resampler.h b/cpp/StftPitchShift/Resampler.h index b808f9a..e8d336b 100755 --- a/cpp/StftPitchShift/Resampler.h +++ b/cpp/StftPitchShift/Resampler.h @@ -35,7 +35,7 @@ namespace stftpitchshift linear(x, x); } - void linear(const std::span x, + void linear(const std::span x, const std::span y) const { linear(x, y); @@ -46,14 +46,14 @@ namespace stftpitchshift linear>(x, x); } - void linear(const std::span> x, + void linear(const std::span> x, const std::span> y) const { linear>(x, y); } - void bilinear(const std::span x0, - const std::span x1, + void bilinear(const std::span x0, + const std::span x1, const std::span y) const { assert(x0.size() == y.size()); @@ -71,8 +71,8 @@ namespace stftpitchshift } } - void bilinear(const std::span> x0, - const std::span> x1, + void bilinear(const std::span> x0, + const std::span> x1, const std::span> y) const { assert(x0.size() == y.size()); @@ -95,7 +95,7 @@ namespace stftpitchshift double value; template - void linear(const std::span x, + void linear(const std::span x, const std::span y) const { assert(x.size() == y.size()); diff --git a/cpp/StftPitchShift/STFT.h b/cpp/StftPitchShift/STFT.h index 704e8ca..4432cdb 100755 --- a/cpp/StftPitchShift/STFT.h +++ b/cpp/StftPitchShift/STFT.h @@ -78,7 +78,7 @@ namespace stftpitchshift buffer.freq.resize(buffer.size / 2 + 1); } - void operator()(const std::span input, const std::span output, const std::function> dft)> callback) + void operator()(const std::span input, const std::span output, const std::function> dft)> callback) { const size_t samples = (std::min)(input.size(), output.size()); @@ -96,7 +96,7 @@ namespace stftpitchshift timers.loop.tic(); for (size_t hop = 0; (hop + buffer.size) < samples; hop += hopsize) { - const std::span src = input.subspan(hop, buffer.size); + const std::span src = input.subspan(hop, buffer.size); const std::span dst = output.subspan(hop, buffer.size); timers.analysis.tic(); @@ -124,7 +124,7 @@ namespace stftpitchshift { for (size_t hop = 0; (hop + buffer.size) < samples; hop += hopsize) { - const std::span src = input.subspan(hop, buffer.size); + const std::span src = input.subspan(hop, buffer.size); const std::span dst = output.subspan(hop, buffer.size); reject(src, buffer.time, window.analysis); @@ -182,7 +182,7 @@ namespace stftpitchshift fft->ifft(dft, frame); } - inline void reject(const std::span input, const std::span frame, const std::span window) const + inline void reject(const std::span input, const std::span frame, const std::span window) const { for (size_t i = 0; i < window.size(); ++i) { @@ -190,7 +190,7 @@ namespace stftpitchshift } } - inline void inject(const std::span output, const std::span frame, const std::span window) const + inline void inject(const std::span output, const std::span frame, const std::span window) const { for (size_t i = 0; i < window.size(); ++i) { diff --git a/cpp/StftPitchShift/StftPitchShift.cpp b/cpp/StftPitchShift/StftPitchShift.cpp index cc0ac8d..c9d193f 100755 --- a/cpp/StftPitchShift/StftPitchShift.cpp +++ b/cpp/StftPitchShift/StftPitchShift.cpp @@ -74,7 +74,7 @@ StftPitchShift::StftPitchShift( } void StftPitchShift::shiftpitch( - const std::span input, + const std::span input, const std::span output, const double factor, const double quefrency, @@ -91,7 +91,7 @@ void StftPitchShift::shiftpitch( } void StftPitchShift::shiftpitch( - const std::span input, + const std::span input, const std::span output, const double factor, const double quefrency, @@ -108,7 +108,7 @@ void StftPitchShift::shiftpitch( } void StftPitchShift::shiftpitch( - const std::span input, + const std::span input, const std::span output, const std::vector& factors, const double quefrency, @@ -133,7 +133,7 @@ void StftPitchShift::shiftpitch( } void StftPitchShift::shiftpitch( - const std::span input, + const std::span input, const std::span output, const std::vector& factors, const double quefrency, diff --git a/cpp/StftPitchShift/StftPitchShift.h b/cpp/StftPitchShift/StftPitchShift.h index 18571ed..10495b4 100755 --- a/cpp/StftPitchShift/StftPitchShift.h +++ b/cpp/StftPitchShift/StftPitchShift.h @@ -85,7 +85,7 @@ namespace stftpitchshift * @param distortion The fractional timbre shifting factor. */ void shiftpitch( - const std::span input, + const std::span input, const std::span output, const double factor = 1, const double quefrency = 0, @@ -99,7 +99,7 @@ namespace stftpitchshift * @param distortion The fractional timbre shifting factor. */ void shiftpitch( - const std::span input, + const std::span input, const std::span output, const double factor = 1, const double quefrency = 0, @@ -113,7 +113,7 @@ namespace stftpitchshift * @param distortion The fractional timbre shifting factor. */ void shiftpitch( - const std::span input, + const std::span input, const std::span output, const std::vector& factors, const double quefrency = 0, @@ -127,7 +127,7 @@ namespace stftpitchshift * @param distortion The fractional timbre shifting factor. */ void shiftpitch( - const std::span input, + const std::span input, const std::span output, const std::vector& factors, const double quefrency = 0,