Skip to content

Commit

Permalink
Rearrange code, to clarify that copySamples is allways <= numSamples
Browse files Browse the repository at this point in the history
  • Loading branch information
daschuer committed Apr 4, 2015
1 parent ecd3133 commit f40e5c1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
15 changes: 5 additions & 10 deletions src/effects/native/bessel4lvmixeqeffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,11 @@ void Bessel4LVMixEQEffect::processChannel(const ChannelHandle& handle,
}
}

if (pState->m_rampHoldOff >= static_cast<int>(numSamples)) {
// ramping is done in one of the following calls
copySamples = numSamples;
rampingSamples = 0;
} else {
// ramping in this call
copySamples = pState->m_rampHoldOff;
rampingSamples = numSamples - pState->m_rampHoldOff;
}
pState->m_rampHoldOff -= copySamples;
// ramping is done in one of the following calls if
// pState->m_rampHoldOff >= numSamples;
copySamples = math_min<int>(pState->m_rampHoldOff, numSamples);
pState->m_rampHoldOff -= copySamples;
rampingSamples = numSamples - copySamples;

SampleUtil::copy3WithGain(pOutput,
pState->m_pLowBuf, pState->old_low,
Expand Down
15 changes: 5 additions & 10 deletions src/effects/native/bessel8lvmixeqeffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,11 @@ void Bessel8LVMixEQEffect::processChannel(const ChannelHandle& handle,
}
}

if (pState->m_rampHoldOff >= static_cast<int>(numSamples)) {
// ramping is done in one of the following calls
copySamples = numSamples;
rampingSamples = 0;
} else {
// ramping in this call
copySamples = pState->m_rampHoldOff;
rampingSamples = numSamples - pState->m_rampHoldOff;
}
pState->m_rampHoldOff -= copySamples;
// ramping is done in one of the following calls if
// pState->m_rampHoldOff >= numSamples;
copySamples = math_min<int>(pState->m_rampHoldOff, numSamples);
pState->m_rampHoldOff -= copySamples;
rampingSamples = numSamples - copySamples;

SampleUtil::copy3WithGain(pOutput,
pState->m_pLowBuf, pState->old_low,
Expand Down

0 comments on commit f40e5c1

Please sign in to comment.