-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Changes from 1 commit
169ca80
1ce3e74
ca7055a
1c0a248
6ec246f
67d8ecc
9939dbd
0af3ddd
0d3ca5f
b099b7a
944702c
e5f7548
e1351b7
a84bfc2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,8 +85,29 @@ bool AnalyzerQueenMaryBeats::finalize() { | |
std::vector<double> beats; | ||
tt.calculateBeats(df, beatPeriod, beats); | ||
|
||
// In some tracks a beat at 0:00 is detected when a noise floor starts. | ||
// Here we check the level and the position for plausibility and remove | ||
// the beat if this is the case. | ||
size_t firstBeat = 0; | ||
if (beats.size() >= 3) { | ||
if (m_detectionResults.at(beats.at(0)) < | ||
(m_detectionResults.at(beats.at(0)) + | ||
m_detectionResults.at(beats.at(0))) / 4) { | ||
// the beat is not half es high than the average of the two | ||
// following beats. Skip it. | ||
firstBeat = 1; | ||
} else { | ||
int diff = (beats.at(1) - beats.at(0)) - (beats.at(2) - beats.at(1)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why in the else part? Shouldn't this be applied regardless if firstBeat = 0 or 1, i.e. after shifting the index of the first beat? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ...but then we would shift the first beat once more. Not sure what the intention was here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The issue I am trying to solve is that the fist beat is often off. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not familiar with the details of beat detection algorithm and would follow your recommendation. Just tried to verify the code and check for inconsistencies or unintended behaviour. |
||
// we don't allow a signifcant tempo change after the first beat | ||
if (diff > 2 || diff < -2) { | ||
// firt beat is off grid. Skip it. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ping |
||
firstBeat = 1; | ||
} | ||
} | ||
} | ||
|
||
m_resultBeats.reserve(beats.size()); | ||
for (size_t i = 0; i < beats.size(); ++i) { | ||
for (size_t i = firstBeat; i < beats.size(); ++i) { | ||
double result = beats[i] * kStepSize; | ||
m_resultBeats.push_back(result); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 times beats.at(0)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ping