Skip to content

Commit

Permalink
Use std::for_each_n on supported versions, fall back to normal for lo…
Browse files Browse the repository at this point in the history
…op otherwise
  • Loading branch information
Veratil committed Apr 10, 2024
1 parent b66740c commit bc71903
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions plugins/GigPlayer/GigPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit bc71903

Please sign in to comment.