From 0e76a673682c15097a91d4a90959113eb920c769 Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Sun, 5 Jan 2020 10:09:39 +0100 Subject: [PATCH] Changed loops to `size_t` --- benchmarks/BM_resample.cpp | 6 +++--- src/sfizz/Oversampler.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/benchmarks/BM_resample.cpp b/benchmarks/BM_resample.cpp index dbb7c39a..86499690 100644 --- a/benchmarks/BM_resample.cpp +++ b/benchmarks/BM_resample.cpp @@ -170,7 +170,7 @@ std::unique_ptr> upsample2x(const sfz::AudioBuffer& buffe { // auto tempBuffer = std::make_unique>(buffer.getNumFrames() * 2); auto outputBuffer = std::make_unique>(buffer.getNumChannels(), buffer.getNumFrames() * 2); - for (int channelIdx = 0; channelIdx < buffer.getNumChannels(); channelIdx++) { + for (size_t channelIdx = 0; channelIdx < buffer.getNumChannels(); channelIdx++) { upsample2xStage(buffer.getConstSpan(channelIdx), outputBuffer->getSpan(channelIdx)); } return outputBuffer; @@ -181,7 +181,7 @@ std::unique_ptr> upsample4x(const sfz::AudioBuffer& buffe { auto tempBuffer = std::make_unique>(buffer.getNumFrames() * 2); auto outputBuffer = std::make_unique>(buffer.getNumChannels(), buffer.getNumFrames() * 4); - for (int channelIdx = 0; channelIdx < buffer.getNumChannels(); channelIdx++) { + for (size_t channelIdx = 0; channelIdx < buffer.getNumChannels(); channelIdx++) { upsample2xStage(buffer.getConstSpan(channelIdx), absl::MakeSpan(*tempBuffer)); upsample4xStage(absl::MakeConstSpan(*tempBuffer), outputBuffer->getSpan(channelIdx)); } @@ -194,7 +194,7 @@ std::unique_ptr> upsample8x(const sfz::AudioBuffer& buffe auto tempBuffer2x = std::make_unique>(buffer.getNumFrames() * 2); auto tempBuffer4x = std::make_unique>(buffer.getNumFrames() * 4); auto outputBuffer = std::make_unique>(buffer.getNumChannels(), buffer.getNumFrames() * 8); - for (int channelIdx = 0; channelIdx < buffer.getNumChannels(); channelIdx++) { + for (size_t channelIdx = 0; channelIdx < buffer.getNumChannels(); channelIdx++) { upsample2xStage(buffer.getConstSpan(channelIdx), absl::MakeSpan(*tempBuffer2x)); upsample4xStage(absl::MakeConstSpan(*tempBuffer2x), absl::MakeSpan(*tempBuffer4x)); upsample8xStage(absl::MakeConstSpan(*tempBuffer4x), outputBuffer->getSpan(channelIdx)); diff --git a/src/sfizz/Oversampler.cpp b/src/sfizz/Oversampler.cpp index 62624fbf..6cf1597c 100644 --- a/src/sfizz/Oversampler.cpp +++ b/src/sfizz/Oversampler.cpp @@ -104,7 +104,7 @@ void sfz::Oversampler::stream(const sfz::AudioBuffer& input, sfz::AudioBu upsampler.set_coefs(coeffsStage2x.data()); break; case Oversampling::x1: - for (int i = 0; i < numChannels; ++i) + for (size_t i = 0; i < numChannels; ++i) copy(input.getConstSpan(i), output.getSpan(i)); return; } @@ -122,7 +122,7 @@ void sfz::Oversampler::stream(const sfz::AudioBuffer& input, sfz::AudioBu // std::cout << "Input frames: " << inputFrameCounter << "/" << numFrames << '\n'; const auto thisChunkSize = std::min(chunkSize, numFrames - inputFrameCounter); const auto outputChunkSize { thisChunkSize * static_cast(factor) }; - for (int chanIdx = 0; chanIdx < numChannels; chanIdx++) { + for (size_t chanIdx = 0; chanIdx < numChannels; chanIdx++) { const auto inputChunk = input.getSpan(chanIdx).subspan(inputFrameCounter, thisChunkSize); const auto outputChunk = output.getSpan(chanIdx).subspan(outputFrameCounter, outputChunkSize); if (factor == Oversampling::x2) {