Skip to content

Commit

Permalink
Merge pull request #13545 from daschuer/gh13449
Browse files Browse the repository at this point in the history
Fix detection last sound if track does not end with silence.
  • Loading branch information
Swiftb0y authored Aug 8, 2024
2 parents 6fd42a0 + 7251d43 commit 14ce13d
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/analyzer/analyzersilence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ SINT AnalyzerSilence::findFirstSoundInChunk(std::span<const CSAMPLE> samples) {
SINT AnalyzerSilence::findLastSoundInChunk(std::span<const CSAMPLE> samples) {
// -1 is required, because the distance from the fist sample index (0) to crend() is 1,
SINT ret = std::distance(first_sound(samples.rbegin(), samples.rend()), samples.rend()) - 1;
if (ret == -1) {
ret = samples.size();
}
return ret;
}

Expand All @@ -93,7 +90,7 @@ bool AnalyzerSilence::processSamples(const CSAMPLE* pIn, SINT count) {
}
if (m_signalStart >= 0) {
const SINT lastSoundSample = findLastSoundInChunk(samples);
if (lastSoundSample < count - 1) { // not only sound or silence
if (lastSoundSample >= 0) {
m_signalEnd = m_framesProcessed + lastSoundSample / mixxx::kAnalysisChannels + 1;
}
}
Expand Down

0 comments on commit 14ce13d

Please sign in to comment.