Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix time offset in key and beat analysis #2152

Merged
merged 14 commits into from
Aug 8, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 9 additions & 14 deletions src/analyzer/analyzerthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ AnalyzerThread::AnalysisResult AnalyzerThread::analyzeAudioSource(
}

// 2nd: step: Analyze chunk of decoded audio data
if (readableSampleFrames.frameLength() == mixxx::kAnalysisFramesPerBlock) {
if (readableSampleFrames.frameLength() == mixxx::kAnalysisFramesPerBlock ||
remainingFrames.empty()) {
// Complete chunk of audio samples has been read for analysis
for (auto&& analyzer : m_analyzers) {
analyzer.processSamples(
Expand All @@ -267,19 +268,13 @@ AnalyzerThread::AnalysisResult AnalyzerThread::analyzeAudioSource(
result = AnalysisResult::Complete;
}
} else {
// Partial chunk of audio samples has been read.
// This should only happen at the end of an audio stream,
// otherwise a decoding error must have occurred.
if (remainingFrames.empty()) {
result = AnalysisResult::Complete;
} else {
// EOF not reached -> Maybe a corrupt file?
kLogger.warning()
<< "Aborting analysis after failure to read sample data:"
<< "expected frames =" << inputFrameIndexRange
<< ", actual frames =" << readableSampleFrames.frameIndexRange();
result = AnalysisResult::Partial;
}
// Partial chunk of audio samples has been read, but not the final.
// A decoding error must have occurred, maybe a corrupt file?
kLogger.warning()
<< "Aborting analysis after failure to read sample data:"
<< "expected frames =" << inputFrameIndexRange
<< ", actual frames =" << readableSampleFrames.frameIndexRange();
result = AnalysisResult::Partial;
}

// Don't check again for paused/stopped and simply finish the
Expand Down
1 change: 0 additions & 1 deletion src/analyzer/plugins/analyzerqueenmarybeats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ bool AnalyzerQueenMaryBeats::initialize(int samplerate) {
}

bool AnalyzerQueenMaryBeats::processSamples(const CSAMPLE* pIn, const int iLen) {
DEBUG_ASSERT(iLen == kAnalysisSamplesPerBlock);
DEBUG_ASSERT(iLen % kAnalysisChannels == 0);
if (!m_pDetectionFunction) {
return false;
Expand Down
2 changes: 0 additions & 2 deletions src/analyzer/plugins/analyzerqueenmarykey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ bool AnalyzerQueenMaryKey::initialize(int samplerate) {
}

bool AnalyzerQueenMaryKey::processSamples(const CSAMPLE* pIn, const int iLen) {
DEBUG_ASSERT(iLen == kAnalysisSamplesPerBlock);
uklotzde marked this conversation as resolved.
Show resolved Hide resolved
DEBUG_ASSERT(iLen % kAnalysisChannels == 0);

if (!m_pKeyMode) {
return false;
}
Expand Down
1 change: 0 additions & 1 deletion src/analyzer/plugins/analyzersoundtouchbeats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ bool AnalyzerSoundTouchBeats::processSamples(const CSAMPLE* pIn, const int iLen)
if (!m_pSoundTouch) {
return false;
}
DEBUG_ASSERT(iLen == kAnalysisSamplesPerBlock);
DEBUG_ASSERT(iLen % kAnalysisChannels == 0);
// We analyze a mono mixdown of the signal since we don't think stereo does
// us any good.
Expand Down