Skip to content

Commit

Permalink
Simplify nested for loop
Browse files Browse the repository at this point in the history
No need for AudioEngine::clip since PortAudio already clips the signal for us.
  • Loading branch information
sakertooth committed Aug 12, 2024
1 parent 4ff2725 commit 333c081
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/core/audio/AudioPortAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,9 @@ int AudioPortAudio::processCallback(const float* inputBuffer, float* outputBuffe
}

const auto minLen = std::min(framesPerBuffer, m_outBufSize - m_outBufPos);
for (fpp_t frame = 0; frame < minLen; ++frame)
for (auto sample = 0; sample < framesPerBuffer * channels(); ++sample)
{
for( ch_cnt_t chnl = 0; chnl < channels(); ++chnl )
{
(outputBuffer + frame * channels())[chnl] = AudioEngine::clip(m_outBuf[frame][chnl]);
}
outputBuffer[sample] = m_outBuf[sample / channels()][sample % channels()];
}

outputBuffer += minLen * channels();
Expand Down

0 comments on commit 333c081

Please sign in to comment.