-
-
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
Changing tempos support #2930
Draft
crisclacerda
wants to merge
29
commits into
mixxxdj:main
Choose a base branch
from
crisclacerda:transition-tracks
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changing tempos support #2930
Changes from 2 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
4236315
Changing tempos support
crisclacerda 21adb5b
better styling
crisclacerda 4b60566
better comments and names
crisclacerda 8cd56e6
Remove Small Arrhythmic regions of tracks that have const tempo
crisclacerda 22119d1
ironing code improvements
crisclacerda 50e4afc
no spikes on ironing...
crisclacerda 47a2298
fix iron code bug, better names and coments
crisclacerda 9928587
more names and comments improvements
crisclacerda b7b0b31
add wraper to silince qt range constructor warning
crisclacerda 2cc53e5
implemented Daniel's red ironing algorithm
crisclacerda 35236ac
start investigating the dip problem near tempo changes
crisclacerda 289ac87
add preferences and subversioning for new features
crisclacerda 74a95a7
failed to add beatfactory.h on previous commit
crisclacerda fb2b6ba
Merge branch 'master' of https://github.com/mixxxdj/mixxx into transi…
crisclacerda f712f66
decouple statistics classes from beats, use circular buffer, other st…
crisclacerda 4c1ed3c
change build files
crisclacerda 43f19a0
fix CMakeList.txt
crisclacerda 879603f
fix formating issues with git-clang-format
crisclacerda 9031aff
add analyzer debug mode
crisclacerda 74cfc23
move debugBeats to beatFactory, structure output, add help info and t…
crisclacerda e144e92
should fix fast msvc build
crisclacerda e838292
fix dip add extra condition for remove arrythmic
crisclacerda 266eade
style fixes on statistics files
crisclacerda da6d275
Apply suggestions from code review
crisclacerda 7f4f0df
switch to const refs when possible, added \n before eof, use Sample r…
crisclacerda 9dfb9a0
Apply suggestions from code review
crisclacerda ea016e0
use the beat lenght instead of bpm for processing
crisclacerda 583cbaa
failed to add windowedstatistics.h on previous commit
crisclacerda 1aa3fbc
add todo to remove new preferences before 2.4
crisclacerda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include <QList> | ||
crisclacerda marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#include <QMap> | ||
|
||
#include <algorithm> | ||
#include <cmath> | ||
|
||
#include "track/beatstats.h" | ||
#include "util/fpclassify.h" | ||
|
||
void MovingMedian::update(double newValue, double oldValue) { | ||
auto insertPosition = std::lower_bound(m_sortedValues.begin(), m_sortedValues.end(), newValue); | ||
m_sortedValues.insert(insertPosition, newValue); | ||
if (!util_isnan(oldValue)) { | ||
m_sortedValues.removeAt(m_sortedValues.indexOf(oldValue)); | ||
} | ||
} | ||
|
||
double MovingMedian::compute() { | ||
return BeatStatistics::median(m_sortedValues); | ||
} | ||
|
||
double BeatStatistics::median(QList<double> sortedItems) { | ||
if (sortedItems.empty()) { | ||
return 0.0; | ||
} | ||
// When there are an even number of elements, the sample median is the mean | ||
// of the middle 2 elements. | ||
if (sortedItems.size() % 2 == 0) { | ||
int item_position = sortedItems.size() / 2; | ||
double item_value1 = sortedItems.at(item_position - 1); | ||
double item_value2 = sortedItems.at(item_position); | ||
return (item_value1 + item_value2) / 2.0; | ||
} | ||
// When there are an odd number of elements, find the {(n+1)/2}th item in | ||
// the sorted list. | ||
int item_position = (sortedItems.size() + 1) / 2; | ||
return sortedItems.at(item_position - 1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#pragma once | ||
|
||
#include <QQueue> | ||
#include "util/assert.h" | ||
|
||
/// These classes are used to compute statistics descriptors | ||
/// of a series of tempo values and are called from beatutils | ||
|
||
class WindowedStatistics { | ||
|
||
public: | ||
|
||
WindowedStatistics(int period) { | ||
DEBUG_ASSERT(period > 0); | ||
m_period = period; | ||
} | ||
virtual ~WindowedStatistics() = default; | ||
|
||
double operator()(double newValue) { | ||
crisclacerda marked this conversation as resolved.
Show resolved
Hide resolved
|
||
double oldValue = updateWindow(newValue); | ||
update(newValue, oldValue); | ||
return compute(); | ||
} | ||
double operator()(void) { | ||
crisclacerda marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return compute(); | ||
} | ||
int lag() { | ||
// expected latency | ||
return (m_window.size() - 1)/2; | ||
} | ||
|
||
private: | ||
|
||
double updateWindow(double newValue) { | ||
m_window.enqueue(newValue); | ||
crisclacerda marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (m_window.count() > m_period) { | ||
return m_window.dequeue(); | ||
} else { | ||
return std::nan(""); | ||
} | ||
} | ||
virtual double compute() = 0; | ||
virtual void update(double newValue, double oldValue) = 0; | ||
QQueue<double> m_window; | ||
crisclacerda marked this conversation as resolved.
Show resolved
Hide resolved
|
||
int m_period; | ||
}; | ||
|
||
class BeatStatistics { | ||
Holzhaus marked this conversation as resolved.
Show resolved
Hide resolved
|
||
public: | ||
static double median(QList<double> sortedItems); | ||
crisclacerda marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
|
||
class MovingMedian : public WindowedStatistics { | ||
QList<double> m_sortedValues; | ||
void update(double, double) override; | ||
double compute() override; | ||
public: | ||
MovingMedian(int period) | ||
: WindowedStatistics(period) {}; | ||
~MovingMedian() = default; | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Legacy issue:
I think we should immediately hand over the raw pointer after construction to clarify the ownership.
subVersion can also be set during the constructor.
The same above.
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.
No constructor of beatmap receives subversion as parameter, since we are getting rid of that anyways I think it's not worth the trouble, right?