From bc7190345dc43d618818c54b15459fd8e80e6f90 Mon Sep 17 00:00:00 2001 From: Veratil Date: Wed, 10 Apr 2024 16:32:08 -0500 Subject: [PATCH] Use std::for_each_n on supported versions, fall back to normal for loop otherwise --- plugins/GigPlayer/GigPlayer.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/GigPlayer/GigPlayer.cpp b/plugins/GigPlayer/GigPlayer.cpp index e9f2c7e946e..f597b9e19e9 100644 --- a/plugins/GigPlayer/GigPlayer.cpp +++ b/plugins/GigPlayer/GigPlayer.cpp @@ -441,10 +441,18 @@ void GigInstrument::play( sampleFrame * _working_buffer ) // resampling, the ADSR doesn't get messed up ADSR copy = sample.adsr; const auto amplitude = copy.value(); +#if ((_MSC_VER >= 1914) || (__GNUC__ >= 9 && __GNUC_MINOR__ >= 3) || (__clang__ && __clang_major__ >= 5)) std::for_each_n(sampleData.begin(), samples, [&](auto& frame) { frame[0] *= amplitude; frame[1] *= amplitude; }); +#else + // TODO: Ubuntu 20.04 CI change should be enough to remove this if/else + for (f_cnt_t i = 0; i < samples; ++i) { + sampleData[i][0] *= amplitude; + sampleData[i][1] *= amplitude; + } +#endif // Output the data resampling if needed // Only output if resampling is successful (note that "used" is output)