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

[WIP] Remove beatmap and beatgrid #2861

Closed
wants to merge 162 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
162 commits
Select commit Hold shift + click to select a range
148e216
Improvement in proto for beats blob
JaviVilarroig Aug 21, 2019
39a90b4
Added Signature class for storing track time signature information
JaviVilarroig Nov 20, 2019
dc8fbe7
Added Signature class
JaviVilarroig Dec 9, 2019
9ee4695
Added Beats::getSignature
JaviVilarroig Dec 16, 2019
05a4720
Merge branch 'bars_phrases_and_variable_BPM_in_beats_class' of https:…
JaviVilarroig Dec 17, 2019
2d38e75
Fix repo
JaviVilarroig Dec 17, 2019
c1428f0
Merge remote-tracking branch 'upstream/master' into bars_phrases_and_…
JaviVilarroig Dec 19, 2019
590be5d
Added Signature manipulation to BeatGrid.
JaviVilarroig Jan 13, 2020
b2c9eca
BeatGrid/BeatMap Signature support
JaviVilarroig Jan 16, 2020
0084ddc
Removed forgotten qDebug unneeded trace
JaviVilarroig Jan 16, 2020
c8b8ae4
- Added button in Tango skin for setting bar beat
JaviVilarroig Feb 17, 2020
fa68e2d
Presentaion of Bar beats in Waveform for BeatMap.
JaviVilarroig Feb 22, 2020
87cc607
Merge remote-tracking branch 'upstream/master' into bars_phrases_and_…
JaviVilarroig Feb 22, 2020
01583e8
Adds null_signature and default_signature constants.
JaviVilarroig Feb 25, 2020
b533ac4
Rename Signature to TimeSignature in protobuff and wrapper class.
JaviVilarroig Feb 25, 2020
72e030a
Fixes in TimeSignature class.
JaviVilarroig Feb 26, 2020
9d652ca
Protect naked pointers in BpmControl.
JaviVilarroig Feb 28, 2020
91c9930
BeatMap::SetBar to use the real Signature of the track to calculate the
JaviVilarroig Feb 28, 2020
df0f083
Fix issue with set bar button nor properly reacting to press an hover.
JaviVilarroig Mar 4, 2020
26b358f
Multiple small fixes on Beats. Added default value to TimeSignature
JaviVilarroig Mar 5, 2020
f97cd1e
BeatGrid removal and BeatMap consolidation into Beats
JaviVilarroig Apr 19, 2020
48ec71b
Forgoten update on cmake list for previous commit
JaviVilarroig Apr 19, 2020
1b4a0d8
Merge commit 'f1e13f93ad35dc1de34a6e8741f369cbb95bc71e' into bars_phr…
daschuer Jun 13, 2020
769e922
Improve variable names for Track pointers.
JaviVilarroig Apr 21, 2020
3647af9
Improve variable names for Track pointers (2)
JaviVilarroig Apr 21, 2020
fcdc116
Document Beats class for Doxygen
JaviVilarroig Apr 21, 2020
4c54b7c
Fix if's without closing brackets.
JaviVilarroig Apr 21, 2020
dccf044
Ads operator<< to Beats and cleanup of misc malformed make_shared
JaviVilarroig Apr 22, 2020
331ef5a
Improvements in Timesignature
JaviVilarroig Apr 22, 2020
0a7baad
Use mixxx::kEngineChannelCount for consistency
JaviVilarroig Apr 22, 2020
04d89ea
Rename Beats::setBar to Beats::setDownBeat
JaviVilarroig Apr 22, 2020
800adf6
Rename Beats::setBar to Beats::setDownBeat and some adpaters
JaviVilarroig Apr 22, 2020
a7cf0d0
Remove ascii art from Beats header
JaviVilarroig Apr 22, 2020
865caf5
Replace BeatsPointer constructor by make_shared
JaviVilarroig Apr 22, 2020
730abaa
Adapt comment to clang-format
JaviVilarroig Apr 22, 2020
7f857a6
Fix BeatsFactory method signatures to use references.
JaviVilarroig Apr 22, 2020
9f1039d
Remove anonymous namespace from beats.h
JaviVilarroig Apr 22, 2020
b3ecb4e
Remove spurious property from Beats
JaviVilarroig Apr 22, 2020
1485e8a
Fixes in BeatIterator
JaviVilarroig May 4, 2020
58dbf80
Waveformrenderbeat to interact with beats using frames
JaviVilarroig May 5, 2020
49e3d09
pre-commit configuration taken from master
JaviVilarroig May 6, 2020
c628235
Small general fixes in BeatFactory.
JaviVilarroig May 6, 2020
1b90cc3
Comments added to const_cas in BeatIterator
JaviVilarroig May 7, 2020
3512947
Change name of method toByteArray to toProtobuff
JaviVilarroig May 7, 2020
20cd34c
Fix in indentation
JaviVilarroig May 7, 2020
d663f04
Add comments to clearly mark temporary methods
JaviVilarroig May 7, 2020
cbdba12
BeatTrtanslateTest is now OK.
JaviVilarroig May 10, 2020
22d6d19
Beats to use Bpm type
JaviVilarroig May 21, 2020
f81f1fd
Merge commit '18e6e1ed60af1fc9a39bda7302f48743085d8844' into bars_phr…
daschuer Jun 14, 2020
b7c8f7b
Fix segfault during tests
daschuer Jun 14, 2020
dde8b8f
fix some tests
daschuer Jun 14, 2020
85c85f5
Use double precision for beat positions
daschuer Jun 14, 2020
10715cd
Beats: Fix build
uklotzde Jun 13, 2020
0ef78f3
Fix dependency ordering issues
uklotzde Jun 15, 2020
03afb56
beats.proto: rename beats to beats_per_bar
hacksdump Jun 12, 2020
f432e59
beats.h: make class final
hacksdump Jun 13, 2020
0dc057d
beats.h: remove version names from macros
hacksdump Jun 13, 2020
51fdd42
remove adapter for calculateBpm
hacksdump Jun 13, 2020
0f8009b
remove adapter for setGrid
hacksdump Jun 13, 2020
2a4bffb
add frame class to avoid sample/frame ambiguity
hacksdump Jun 13, 2020
56e9051
use single f in protobuf
hacksdump Jun 13, 2020
8e6625a
remove all adapters from main source
hacksdump Jun 15, 2020
ec62228
adapt tests to frame class
hacksdump Jun 16, 2020
91eb3d8
remove residual beats subclasses and corresponding tests
hacksdump Jun 16, 2020
f9fd333
add channel count to beatstest
hacksdump Jun 16, 2020
9b962d7
frame: add multiply and divide operations
hacksdump Jun 16, 2020
480f7f7
beats: use Frame vector in constructor
hacksdump Jun 16, 2020
65a0d84
beatfactory: write adapter to store beatgrid in beats
hacksdump Jun 16, 2020
a49ebe0
beatfactory: use common serialized data for all beatgrid version
hacksdump Jun 16, 2020
3e4664e
beats: remove unused code | rename proto
hacksdump Jun 16, 2020
a7b6d01
beats: remove unused function getMaxBpm
hacksdump Jun 16, 2020
919e1b9
beats: remove extraneous helper functions
hacksdump Jun 16, 2020
84d689c
beats: remove derivable state variable
hacksdump Jun 16, 2020
fe7fd32
beats: remove capability flags
hacksdump Jun 17, 2020
8957a08
beats:doc: describe source of data in constructor
hacksdump Jun 18, 2020
e6b0383
beats: remove optional sample rate parameter
hacksdump Jun 18, 2020
b156cd5
bpm: remove redundant parantheses
hacksdump Jun 18, 2020
e67686f
Merge branch 'ambigous-sample-rate' into remove-beatmap-beatgrid
hacksdump Jun 18, 2020
eab8bb0
beats: simplify bpm scale function
hacksdump Jun 18, 2020
43acd8f
timesignature: modify getters setters
hacksdump Jun 18, 2020
df01cce
beats: remove test logic from main source
hacksdump Jun 18, 2020
bff9917
fix typo
hacksdump Jun 18, 2020
754ecfe
beatutils: don't use framerate for audio
hacksdump Jun 18, 2020
4b515f2
beats: use double instead of rounding
hacksdump Jun 18, 2020
a1dc778
beats: define iterator
hacksdump Jun 18, 2020
e32a19c
timesignature: move symmetrical operations outside class
hacksdump Jun 18, 2020
454ba2c
remove redundant copying of member variable
hacksdump Jun 18, 2020
7eb655c
timesignature: use protobuf object to store signature
hacksdump Jun 19, 2020
9c981fb
beats: enable setBpm for all Beat detection modes
hacksdump Jun 20, 2020
4329021
frame: replace forward declaration with include
hacksdump Jun 20, 2020
1356ccb
frame.h refactor: use FramePos and FrameDiff_t
hacksdump Jun 21, 2020
9e04891
beats: update outdated constructor documentation
hacksdump Jun 21, 2020
43e16c1
bpmcontrol: use parented pointers
hacksdump Jun 21, 2020
f46860f
bpmcontrol: use unique pointers
hacksdump Jun 21, 2020
ea4447a
beatiterator: pointer comparison and exclude end
hacksdump Jun 21, 2020
33b6a4f
change control name
hacksdump Jun 21, 2020
79ecd2a
bpm: pass trivially copyable types by value
hacksdump Jun 21, 2020
c013576
bpm:use double for multiple and divide operations
hacksdump Jun 21, 2020
0576be8
beatiterator: remove destructor
hacksdump Jun 21, 2020
cbc7977
beats.proto: make fields required
hacksdump Jun 21, 2020
d255364
beatutils: remove unnecessary const
hacksdump Jun 21, 2020
397b338
beatutils: remove rounding for frame sample conversion
hacksdump Jun 21, 2020
a0ff6d9
beats: use correct range while returning iterator
hacksdump Jun 21, 2020
cf75244
beatstest: fix time signature test
hacksdump Jun 21, 2020
074a921
beatstest: remove redundant state variable
hacksdump Jun 21, 2020
136060b
waveformrenderbeat: enable beat pen
hacksdump Jun 21, 2020
86b834a
beatstest: fix NthBeatWhenNotOnBeat
hacksdump Jun 21, 2020
cab96a2
track: remove obsolete comments and debug info
hacksdump Jun 22, 2020
be68912
bpmcontrol_test: fix BeatContext_BeatGrid
hacksdump Jun 22, 2020
a9707f8
beatstest: fix BpmAround
hacksdump Jun 24, 2020
33bf4c9
searchqueryparsertest: fuzzy comparison to fix tests
hacksdump Jun 24, 2020
34c35d7
bpm: pass qstring by reference
hacksdump Jun 24, 2020
fe266d0
beats: cleaner debug output
hacksdump Jun 25, 2020
4d8f2f2
engine: use inline functions for frame conversion
hacksdump Jun 25, 2020
0534db3
remove unnecessary frame quantization
hacksdump Jun 25, 2020
915a671
beats: rename method
hacksdump Jun 25, 2020
ca4425a
beats: remove copy to self
hacksdump Jun 25, 2020
540c749
engine: update function to use FramePos instead of samples
hacksdump Jun 25, 2020
c00da80
engine: refactor to use FramePos instead of sample
hacksdump Jun 26, 2020
5f0ce46
beats: don't delete beats on translate
hacksdump Jun 26, 2020
fa86f2a
frame: use constant for invalid frame instead of -1
hacksdump Jun 26, 2020
38555e0
beatstranslatetest: fix SimpleTranslateMatch
hacksdump Jun 26, 2020
7f89649
frame: use C++ style limits
hacksdump Jun 26, 2020
68a1949
use inline functions for sample frame conversion
hacksdump Jun 28, 2020
c19d2f2
fix wrong assignment to beats
hacksdump Jun 29, 2020
55d7784
loopingcontrol: use inline functions for sample frame conversion
hacksdump Jun 29, 2020
1fff80c
Merge branch 'master' into remove-beatmap-beatgrid
hacksdump Jun 29, 2020
4f28348
loopingcontroltest: beat size within track duration
hacksdump Jun 30, 2020
8506d0b
use correct epsilon for finding nearby beat
hacksdump Jun 30, 2020
71bf183
fix enginesynctest failing due to typo
hacksdump Jun 30, 2020
3933e76
fix searchqueryparser test by reducing double precision
hacksdump Jun 30, 2020
85e75c9
remove unused functions
hacksdump Jul 1, 2020
425c7fd
remove unnecesary debug function
hacksdump Jul 2, 2020
2ca2be4
searchquery: improve comment on precision downgrading
hacksdump Jul 2, 2020
0710437
beats: use namespaced constants
hacksdump Jul 2, 2020
006cd74
factor out frame sample adapter functions
hacksdump Jul 2, 2020
cd80c28
loopingcontol: replace wrong variable
hacksdump Jul 2, 2020
bcd32c1
move frameadapter to util
hacksdump Jul 2, 2020
a7a7edd
use frameadapter in track
hacksdump Jul 2, 2020
6268b30
fix scons build
hacksdump Jul 2, 2020
b2a9bcf
frameadapter: change comment
hacksdump Jul 2, 2020
792c682
beats: temporary dirty workaround for copy constructor
hacksdump Jul 2, 2020
8452657
beatsproto: make all fields optional
hacksdump Jul 2, 2020
8134eae
create new internal beats class independent of QObject
hacksdump Jul 7, 2020
a60beee
simplify copy constructor
hacksdump Jul 7, 2020
9a08d05
beats: move findNthBeat to plain class
hacksdump Jul 7, 2020
13538d3
beats: move more code to plain class
hacksdump Jul 7, 2020
0a5fba3
beats: move scale functions to plain class
hacksdump Jul 8, 2020
274c9fa
beats: move all implementation to plain class
hacksdump Jul 8, 2020
49686eb
beats: use function to calculate beat length
hacksdump Jul 11, 2020
eb3b6c9
beats: add back old protobuf types for backwards compatibility
hacksdump Jul 12, 2020
d3b7a5a
beats: add version to distinguish from earlier versions
hacksdump Jul 13, 2020
79f5b2a
beats: add migration code
hacksdump Jul 14, 2020
6a52cab
merge from master and resolve conflicts
hacksdump Jul 14, 2020
abf9694
update comments
hacksdump Jul 14, 2020
7302922
revert all UI changes
hacksdump Jul 14, 2020
77c8d82
use beat indices as marker basis
hacksdump Jul 16, 2020
1e2565a
change section message
hacksdump Jul 16, 2020
cc0d8ef
remove redundant ctor initializer
hacksdump Jul 16, 2020
de26dd4
remove legacy name from comment
hacksdump Jul 16, 2020
e76bfc3
add debug asserts
hacksdump Jul 16, 2020
1967c0f
add placeholder parameters
hacksdump Jul 16, 2020
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
Prev Previous commit
Next Next commit
Document Beats class for Doxygen
  • Loading branch information
JaviVilarroig authored and daschuer committed Jun 13, 2020
commit fcdc11619240e48d26b1c15c7721d9ac74aa0072
136 changes: 65 additions & 71 deletions src/track/beats.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,25 @@ double kMaxBpm = 500;
}

namespace mixxx {
// Beats is a pure abstract base class for BPM and beat management classes. It
// provides a specification of all methods a beat-manager class must provide, as
// well as a capability model for representing optional features.
/// Beats is a class for BPM and beat management classes.
/// It stores beats information including beats position, down beats position,
/// phrase beat position and changes in tempo.
// TODO(JVC) To make it final
class Beats : public QObject {
Q_OBJECT
public:
// Construct a BeatMap. iSampleRate may be provided if a more accurate
// sample rate is known than the one associated with the Track.
// TODO(JVC) The samplerate in the track must be enough so the second parameter can be removed.
/// Construct a BeatMap. iSampleRate may be provided if a more accurate
/// sample rate is known than the one associated with the Track.
Beats(const Track* track, SINT iSampleRate = 0);
// Construct a BeatMap. iSampleRate may be provided if a more accurate
// sample rate is known than the one associated with the Track. If it is
// zero then the track's sample rate will be used. The BeatMap will be
// deserialized from the byte array.
// TODO(JVC) The samplerate in the track must be enough so the second parameter can be removed.
/// Construct a BeatMap. iSampleRate may be provided if a more accurate
/// sample rate is known than the one associated with the Track. If it is
/// zero then the track's sample rate will be used. The BeatMap will be
/// deserialized from the byte array.
Beats(const Track* track, const QByteArray& byteArray, SINT iSampleRate = 0);
// Construct a BeatMap. iSampleRate may be provided if a more accurate
// sample rate is known than the one associated with the Track. If it is
// zero then the track's sample rate will be used. A list of beat locations
// in audio frames may be provided.
// TODO(JVC) The samplerate in the track must be enough so the second parameter can be removed.
/// Construct a BeatMap. iSampleRate may be provided if a more accurate
/// sample rate is known than the one associated with the Track. If it is
/// zero then the track's sample rate will be used. A list of beat locations
/// in audio frames may be provided.
Beats(const Track* track, const QVector<double>& beats, SINT iSampleRate = 0);

virtual ~Beats() {
Expand All @@ -63,6 +60,7 @@ class Beats : public QObject {
// TODO(JVC) Is a copy constructor needed? of we can force a move logic??
Beats(const Beats&);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A QObject is not copy-able. I am unsure how this works for inherited classes. At least this has some code smell.
So we should either remove to QObject parent or the copy constructor.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's why I mentioned that we need to break up this class into an inner functional class that doesn't inherit from QObject and an outer QObject wrapper.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@uklotzde How do I proceed with this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Rename Beats to BeatsObject
  2. Move all required members into a plain, copyable, moveable C++ object Beats
  • m_subVersion
  • m_sampleRate
  • m_duration
  • m_bpm (not "m_dCachedBpm", this name is misleading)
  • m_beatList

Storing a pointer to the Track object should not be necessary. Instead the track should actively take control of the BeatsObject.

Storing the plain Track pointer is unsafe and may cause crashes. The only valid option would be to store a weak pointer if necessary. But try to avoid those cyclic dependencies in the first place.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename Beats to BeatsObject

Appending "Object" to a class name says nothing about what the class does. I am still in favor of "BeatVector", but I'm open to other ideas for the class name.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer BeatVectorWrapper or BeatVectorQObject.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to introduce another confusing and meaningless term, then just "...QObject".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran into a few problems while trying to remove the track member pointer from the Beats class.

The track pointer is currently used to dynamically find the track duration (since it can be updated later, which is a common scenario in tests)

Resolution:

  1. Use TrackWeakPointer in Beats
    This is semantically not wrong and could possibly work but in Track::setBpm a new Beats object is created and the constructor needs a shared pointer to Track itself. So weak pointer can't be used. An outer agent would need to setup the ownership between track and beats which is not doable.

  2. Entirely remove track member pointer.
    This would need the creation of new signals in the track class and connections would need to be established on construction to update data in Beats that can change with track.

  3. Keep the current configuration
    We are storing a plain pointer to track in Beats class. This means there is no ownership per se. So we don't really run into a cyclic dependency here. Track has active control of Beats and in addition to that, Beats stores a plain pointer to the track.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am leaning towards option 2, but I'd like to hear @uklotzde's opinion.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I get the issue with option 1 with transforming this into a smart pointer. Ruled out.

Let's stick to option 3. Extending Track could prove difficult, because it is a very central place with lots of dependencies. Don't open the Pandora's box now ;) Later we can decide about how to move on. This does not only affect the beat grid class.

The Track* should only be stored in the upper level QObject derived class. If you need the duration or sample rate in the plain C++ class either store them as members or pass them as parameters only when needed. If they are only needed for certain operations pass them as parameters. They don't really belong to the basic concept of a beat grid and maintaining less state avoids potential inconsistencies.


/// Populate a Beats with a vector of beat positions.
void createFromBeatVector(const QVector<double>& beats);
// TODO(JVC) Not needed
enum Capabilities {
Expand Down Expand Up @@ -90,25 +88,26 @@ class Beats : public QObject {
return BEATSCAP_TRANSLATE | BEATSCAP_SCALE | BEATSCAP_ADDREMOVE |
BEATSCAP_MOVEBEAT | BEATSCAP_HASBAR;
}
// Serialization
/// Serializes into a protobuff.
virtual QByteArray toByteArray() const;
virtual BeatsPointer clone() const;

// A string representing the version of the beat-processing code that
// produced this Beats instance. Used by BeatsFactory for associating a
// given serialization with the version that produced it.
/// Returns a string representing the version of the beat-processing code that
/// produced this Beats instance. Used by BeatsFactory for associating a
/// given serialization with the version that produced it.
virtual QString getVersion() const;
// A sub-version can be used to represent the preferences used to generate
// the beats object.
/// Return a string that represent the preferences used to generate
/// the beats object.
virtual QString getSubVersion() const;
virtual void setSubVersion(QString subVersion);
bool isValid() const;
/// Calculates the BPM between two beat positions.
double calculateBpm(const track::io::Beat& startBeat,
const track::io::Beat& stopBeat) const;

// Initializes the BeatGrid to have a BPM of dBpm and the first beat offset
// of dFirstBeatSample. Does not generate an updated() signal, since it is
// meant for initialization.
/// Initializes the BeatGrid to have a BPM of dBpm and the first beat offset
/// of dFirstBeatSample. Does not generate an updated() signal, since it is
/// meant for initialization.
void setGrid(double dBpm, double sample = 0) {
setGridNew(dBpm, sample / 2.0);
}
Expand All @@ -121,28 +120,28 @@ class Beats : public QObject {
// TODO: We may want to implement these with common code that returns
// the triple of closest, next, and prev.

// Starting from frame, return the frame number of the next beat
// in the track, or -1 if none exists. If frame refers to the location
// of a beat, frame is returned.
/// Starting from frame, return the frame number of the next beat
/// in the track, or -1 if none exists. If frame refers to the location
/// of a beat, frame is returned.
virtual double findNextBeat(double sample) const {
return findNextBeatNew(sample / 2.0) * 2.0;
}
virtual FrameNum findNextBeatNew(FrameNum frame) const;

// Starting from frame frame, return the frame number of the previous
// beat in the track, or -1 if none exists. If frame refers to the
// location of beat, frame is returned.
/// Starting from frame frame, return the frame number of the previous
/// beat in the track, or -1 if none exists. If frame refers to the
/// location of beat, frame is returned.
virtual double findPrevBeat(FrameNum frame) const {
return findPrevBeatNew(frame / 2.0) * 2.0;
}
virtual FrameNum findPrevBeatNew(FrameNum frame) const;

// Starting from frame, fill the frame numbers of the previous beat
// and next beat. Either can be -1 if none exists. If frame refers
// to the location of the beat, the first value is frame, and the second
// value is the next beat position. Non- -1 values are guaranteed to be
// even. Returns false if *at least one* sample is -1. (Can return false
// with one beat successfully filled)
/// Starting from frame, fill the frame numbers of the previous beat
/// and next beat. Either can be -1 if none exists. If frame refers
/// to the location of the beat, the first value is frame, and the second
/// value is the next beat position. Non- -1 values are guaranteed to be
/// even. Returns false if *at least one* sample is -1. (Can return false
/// with one beat successfully filled)
virtual bool findPrevNextBeats(double sample,
double* pPrevSample,
double* pNextSample) const {
Expand All @@ -158,17 +157,17 @@ class Beats : public QObject {
FrameNum* pPrevBeatFrame,
FrameNum* pNextBeatFrame) const;

// Starting from frame, return the frame number of the closest beat
// in the track, or -1 if none exists. Non- -1 values are guaranteed to be
// even.
/// Starting from frame, return the frame number of the closest beat
/// in the track, or -1 if none exists. Non- -1 values are guaranteed to be
/// even.
virtual double findClosestBeat(double sample) const {
return findClosestBeatNew(sample / 2.0) * 2.0;
}
virtual FrameNum findClosestBeatNew(FrameNum frame) const;

// Find the Nth beat from frame. Works with both positive and
// negative values of n. If frame refers to the location of a beat,
// then frame is returned. If no beat can be found, returns -1.
/// Find the Nth beat from frame. Works with both positive and
/// negative values of n. If frame refers to the location of a beat,
/// then frame is returned. If no beat can be found, returns -1.
virtual double findNthBeat(double sample, int offset) const {
return findNthBeatNew(sample / 2.0, offset) * 2.0;
}
Expand All @@ -179,56 +178,51 @@ class Beats : public QObject {
}
int numBeatsInRangeNew(FrameNum startFrameNum, FrameNum endFrameNum);

// Find the frame N beats away from frame. The number of beats may be
// negative and does not need to be an integer.
/// Find the frame N beats away from frame. The number of beats may be
/// negative and does not need to be an integer.
double findNBeatsFromSample(double sample, double beats) const {
return findNBeatsFromSampleNew(sample / 2.0, beats) * 2.0;
}
FrameNum findNBeatsFromSampleNew(FrameNum frame, double beats) const;

// Adds to pBeatsList the position in samples of every beat occurring between
// startPosition and endPosition. BeatIterator must be iterated while
// holding a strong references to the Beats object to ensure that the Beats
// object is not deleted. Caller takes ownership of the returned BeatIterator;
// TODO (JVC) New description to be checked
// Return an iterator to a container of Beats containing the Beats
// between startFrameNum and endFrameNum. THe BeatIterator must be iterated
// while a strong reference to the Beats object to ensure that the Beats
// object is not deleted. Caller takes ownership of the returned BeatsIterator
/// Return an iterator to a container of Beats containing the Beats
/// between startFrameNum and endFrameNum. THe BeatIterator must be iterated
/// while a strong reference to the Beats object to ensure that the Beats
/// object is not deleted. Caller takes ownership of the returned BeatsIterator
virtual std::unique_ptr<BeatIterator> findBeats(double startSampleNum,
double stopSampleNum) const {
return findBeatsNew(startSampleNum / 2.0, stopSampleNum / 2.0);
}
virtual std::unique_ptr<BeatIterator> findBeatsNew(FrameNum startFrameNum,
FrameNum stopFrameNum) const;

// Return whether or not a Beat lies between startFrameNum and endFrameNum
/// Return whether or not a Beat lies between startFrameNum and endFrameNum
virtual bool hasBeatInRange(double startSampleNum,
double stopSampleNum) const {
return hasBeatInRangeNew(startSampleNum / 2.0, stopSampleNum / 2.0);
}
virtual bool hasBeatInRangeNew(FrameNum startFrameNum,
FrameNum stopFrameNum) const;

// Return the average BPM over the entire track if the BPM is
// valid, otherwise returns -1
/// Return the average BPM over the entire track if the BPM is
/// valid, otherwise returns -1
virtual double getBpm() const {
return getBpmNew();
}
virtual double getBpmNew() const;

// Return the average BPM over the range from startFrameNum to endFrameNum,
// specified in frames if the BPM is valid, otherwise returns -1
/// Return the average BPM over the range from startFrameNum to endFrameNum,
/// specified in frames if the BPM is valid, otherwise returns -1
virtual double getBpmRange(double startSampleNum,
FrameNum stopSampleNum) const {
return getBpmRangeNew(startSampleNum / 2.0, stopSampleNum / 2.0);
}
virtual double getBpmRangeNew(FrameNum startFrameNum,
FrameNum stopFrameNum) const;

// Return the average BPM over the range of n*2 beats centered around
// curFrameNum. (An n of 4 results in an averaging of 8 beats). Invalid
// BPM returns -1.
/// Return the average BPM over the range of n*2 beats centered around
/// curFrameNum. (An n of 4 results in an averaging of 8 beats). Invalid
/// BPM returns -1.
virtual double getBpmAroundPosition(double curSampleNum, int n) const {
return getBpmAroundPositionNew(curSampleNum / 2.0, n);
}
Expand Down Expand Up @@ -263,25 +257,25 @@ class Beats : public QObject {
}
virtual void addBeatNew(FrameNum frame);

// Remove a beat at location frame. Beats instance must have the
// capability BEATSCAP_ADDREMOVE.
/// Remove a beat at location frame. Beats instance must have the
/// capability BEATSCAP_ADDREMOVE.
virtual void removeBeat(double sample) {
removeBeatNew(sample / 2.0);
}
virtual void removeBeatNew(FrameNum frame);

// TODO(JVC) Do we want to move the beats a number of frames??
// Translate all beats in the song by dNumSamples samples. Beats that lie
// before the start of the track or after the end of the track are not
// removed. Beats instance must have the capability BEATSCAP_TRANSLATE.
/// Translate all beats in the song by dNumSamples samples. Beats that lie
/// before the start of the track or after the end of the track are not
/// removed. Beats instance must have the capability BEATSCAP_TRANSLATE.
virtual void translate(double dNumSamples);

// Scale the position of every beat in the song by dScalePercentage. Beats
// class must have the capability BEATSCAP_SCALE.
/// Scale the position of every beat in the song by dScalePercentage. Beats
/// class must have the capability BEATSCAP_SCALE.
virtual void scale(enum BPMScale scale);

// Adjust the beats so the global average BPM matches dBpm. Beats class must
// have the capability BEATSCAP_SET.
/// Adjust the beats so the global average BPM matches dBpm. Beats class must
/// have the capability BEATSCAP_SET.
virtual void setBpm(double dBpm);

/// Returns the number of beats
Expand Down