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] Bars phrases and variable bpm in beats class #2512

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 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
58be257
Merge remote-tracking branch 'upstream/master' into
JaviVilarroig Apr 21, 2020
0532956
Improve variable names for Track pointers.
JaviVilarroig Apr 21, 2020
9a31a12
Improve variable names for Track pointers (2)
JaviVilarroig Apr 21, 2020
3837563
Document Beats class for Doxygen
JaviVilarroig Apr 21, 2020
18c8e9b
Fix if's without closing brackets.
JaviVilarroig Apr 21, 2020
ef8df26
Ads operator<< to Beats and cleanup of misc malformed make_shared
JaviVilarroig Apr 22, 2020
8930f78
Improvements in Timesignature
JaviVilarroig Apr 22, 2020
41477ec
Use mixxx::kEngineChannelCount for consistency
JaviVilarroig Apr 22, 2020
41eec7d
Rename Beats::setBar to Beats::setDownBeat
JaviVilarroig Apr 22, 2020
f5b1890
Rename Beats::setBar to Beats::setDownBeat and some adpaters
JaviVilarroig Apr 22, 2020
ca36f47
Remove ascii art from Beats header
JaviVilarroig Apr 22, 2020
4102b23
Merge branch 'bars_phrases_and_variable_BPM_in_beats_class' of github…
JaviVilarroig Apr 22, 2020
5abf85b
Replace BeatsPointer constructor by make_shared
JaviVilarroig Apr 22, 2020
89cf63c
Adapt comment to clang-format
JaviVilarroig Apr 22, 2020
a0e828f
Fix BeatsFactory method signatures to use references.
JaviVilarroig Apr 22, 2020
b3d3701
Remove anonymous namespace from beats.h
JaviVilarroig Apr 22, 2020
15626d9
Remove spurious property from Beats
JaviVilarroig Apr 22, 2020
8abb3fb
Fixes in BeatIterator
JaviVilarroig May 4, 2020
dec4d31
Remove obsolete tests
JaviVilarroig May 4, 2020
679de45
Waveformrenderbeat to interact with beats using frames
JaviVilarroig May 5, 2020
d0e4b12
pre-commit configuration taken from master
JaviVilarroig May 6, 2020
0f1848a
Small general fixes in BeatFactory.
JaviVilarroig May 6, 2020
bd57568
Comments added to const_cas in BeatIterator
JaviVilarroig May 7, 2020
9ed4081
Change name of method toByteArray to toProtobuff
JaviVilarroig May 7, 2020
12cd34c
Fix in indentation
JaviVilarroig May 7, 2020
784e646
Add comments to clearly mark temporary methods
JaviVilarroig May 7, 2020
1851baf
Merge remote-tracking branch 'upstream/master' into
JaviVilarroig May 8, 2020
d5f73c4
BeatTrtanslateTest is now OK.
JaviVilarroig May 10, 2020
920d1c6
This makes beatmap behaves like a beatgrid when constant tempo prefer…
crisclacerda May 13, 2020
b6be4dd
Revert "This makes beatmap behaves like a beatgrid when constant temp…
JaviVilarroig May 17, 2020
bfe8ab8
Beats to use Bpm type
JaviVilarroig May 21, 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
5 changes: 1 addition & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -544,8 +544,6 @@ add_library(mixxx-lib STATIC EXCLUDE_FROM_ALL
src/sources/soundsourcesndfile.cpp
src/track/albuminfo.cpp
src/track/beatfactory.cpp
src/track/beatgrid.cpp
src/track/beatmap.cpp
src/track/beats.cpp
src/track/beatutils.cpp
src/track/bpm.cpp
Expand Down Expand Up @@ -1035,8 +1033,7 @@ add_executable(mixxx-test
src/test/audiotaperpot_test.cpp
src/test/autodjprocessor_test.cpp
src/test/baseeffecttest.cpp
src/test/beatgridtest.cpp
src/test/beatmaptest.cpp
src/test/beatstest.cpp
src/test/beatstranslatetest.cpp
src/test/bpmcontrol_test.cpp
src/test/broadcastprofile_test.cpp
Expand Down
7 changes: 6 additions & 1 deletion res/skins/Tango/buttons/btn_beats_curpos.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions res/skins/Tango/buttons/btn_beats_set_bar_beat.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 7 additions & 2 deletions res/skins/Tango/style.qss
Original file line number Diff line number Diff line change
Expand Up @@ -457,19 +457,24 @@ WWidgetGroup {
#BeatgridSlower,
#BeatgridFaster,
#BeatgridEarlier,
#BeatgridLater {
#BeatgridLater,
#BeatgridSetBarBeat {
background-color: #333;
}
#BeatgridCurpos:hover,
#BeatgridSlower:hover,
#BeatgridFaster:hover,
#BeatgridEarlier:hover,
#BeatgridLater:hover {
#BeatgridLater:hover,
#BeatgridSetBarBeat:hover {
background-color: #0f0f0f;
}
#BeatgridCurpos {
image: url(skin:/buttons/btn_beats_curpos.svg) no-repeat center center;
}
#BeatgridSetBarBeat {
image: url(skin:/buttons/btn_beats_set_bar_beat.svg) no-repeat center center;
}
#BeatgridSlower {
image: url(skin:/buttons/btn_beats_slower.svg) no-repeat center center;
}
Expand Down
25 changes: 24 additions & 1 deletion res/skins/Tango/waveform.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Variables:
<SignalRGBMidColor><Variable name="SignalRGBMidColor"/></SignalRGBMidColor>
<SignalRGBHighColor><Variable name="SignalRGBHighColor"/></SignalRGBHighColor>
<BeatColor>#ffffff</BeatColor>
<BarColor>#ffff00</BarColor>
<PlayPosColor>#FF4300</PlayPosColor>
<EndOfTrackColor><Variable name="EndOfTrackColor"/></EndOfTrackColor>
<DefaultMark>
Expand Down Expand Up @@ -131,7 +132,7 @@ Variables:
<Layout>vertical</Layout>
<!-- Horizontal size is 82px and we'll add the WaveformContainer's negative margin
(shifts waveform center mark) so that all buttons are visible -->
<Size>82f,50me</Size>
<Size>107f,50me</Size>
<Children>
<WidgetGroup><Size>1me,0me</Size></WidgetGroup>
<WidgetGroup><Size>1me,1f</Size></WidgetGroup>
Expand All @@ -149,6 +150,28 @@ Variables:
<SetVariable name="ConfigKeyRight"><Variable name="group"/>,beats_translate_match_alignment</SetVariable>
</Template>

<WidgetGroup><!-- Set Bar and Phrase beat -->
<Layout>vertical</Layout>
<SizePolicy>f,f</SizePolicy>
<Children>
<Template src="skin:button_1state.xml">
<SetVariable name="TooltipId">beats_set_bar_beat</SetVariable>
<SetVariable name="ObjectName">BeatgridSetBarBeat</SetVariable>
<SetVariable name="Size">28f,24f</SetVariable>
<SetVariable name="ConfigKey"><Variable name="group"/>,beats_set_bar_beat</SetVariable>
</Template>

<WidgetGroup><Size>1min,1f</Size></WidgetGroup>

<Template src="skin:button_1state.xml">
<SetVariable name="TooltipId">beats_adjust_faster</SetVariable>
<SetVariable name="ObjectName">BeatgridFaster</SetVariable>
<SetVariable name="Size">28f,24f</SetVariable>
<SetVariable name="ConfigKey"><Variable name="group"/>,beats_adjust_faster</SetVariable>
</Template>
</Children>
</WidgetGroup><!-- Set Bar and Phrase beat -->

<WidgetGroup><Size>1min,1f</Size></WidgetGroup>

<WidgetGroup><!-- beats earlier & faster -->
Expand Down
9 changes: 5 additions & 4 deletions src/analyzer/analyzerbeats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "analyzer/plugins/analyzerqueenmarybeats.h"
#include "analyzer/plugins/analyzersoundtouchbeats.h"
#include "track/beatfactory.h"
#include "track/beatmap.h"
#include "track/beats.h"
#include "track/beatutils.h"
#include "track/track.h"

Expand Down Expand Up @@ -97,7 +97,6 @@ bool AnalyzerBeats::initialize(TrackPointer tio, int sampleRate, int totalSample
// if we can load a stored track don't reanalyze it
bool bShouldAnalyze = shouldAnalyze(tio);


DEBUG_ASSERT(!m_pPlugin);
if (bShouldAnalyze) {
if (m_pluginId == mixxx::AnalyzerQueenMaryBeats::pluginInfo().id) {
Expand Down Expand Up @@ -211,7 +210,7 @@ void AnalyzerBeats::storeResults(TrackPointer tio) {
QHash<QString, QString> extraVersionInfo = getExtraVersionInfo(
m_pluginId, m_bPreferencesFastAnalysis);
pBeats = BeatFactory::makePreferredBeats(
*tio,
tio,
daschuer marked this conversation as resolved.
Show resolved Hide resolved
beats,
extraVersionInfo,
m_bPreferencesFixedTempo,
JaviVilarroig marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -225,7 +224,9 @@ void AnalyzerBeats::storeResults(TrackPointer tio) {
} else {
float bpm = m_pPlugin->getBpm();
qDebug() << "AnalyzerBeats plugin detected constant BPM: " << bpm;
pBeats = BeatFactory::makeBeatGrid(*tio, bpm, 0.0f);
pBeats = std::make_shared<mixxx::Beats>(tio.get());
pBeats->setGrid(bpm);
tio->setBeats(pBeats);
}

mixxx::BeatsPointer pCurrentBeats = tio->getBeats();
Expand Down
2 changes: 2 additions & 0 deletions src/controllers/controlpickermenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ ControlPickerMenu::ControlPickerMenu(QWidget* pParent)
addDeckControl("beats_translate_match_alignment", tr("Adjust Beatgrid - Match Alignment"),
tr("Adjust beatgrid to match another playing deck."), bpmMenu);
addDeckAndSamplerControl("quantize", tr("Quantize Mode"), tr("Toggle quantize mode"), bpmMenu);
addDeckAndSamplerControl("beats_set_bar_beat", tr("Set Bar Beat"),
tr("Make the current beat a Bar beat"), bpmMenu);

QMenu* syncMenu = addSubmenu(tr("Sync"));
addDeckAndSamplerControl("sync_enabled", tr("Sync Mode"),
Expand Down
34 changes: 23 additions & 11 deletions src/engine/controls/bpmcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ BpmControl::BpmControl(QString group,
m_dSyncTargetBeatDistance.setValue(0.0);
m_dUserOffset.setValue(0.0);

m_pPlayButton = new ControlProxy(group, "play", this);
m_pReverseButton = new ControlProxy(group, "reverse", this);
m_pRateRatio = new ControlProxy(group, "rate_ratio", this);
m_pPlayButton = std::make_unique<ControlProxy>(group, "play", this);
daschuer marked this conversation as resolved.
Show resolved Hide resolved
m_pReverseButton = std::make_unique<ControlProxy>(group, "reverse", this);
m_pRateRatio = std::make_unique<ControlProxy>(group, "rate_ratio", this);
m_pRateRatio->connectValueChanged(this, &BpmControl::slotUpdateEngineBpm,
Qt::DirectConnection);

Expand All @@ -59,9 +59,9 @@ BpmControl::BpmControl(QString group,
m_pPrevBeat.reset(new ControlProxy(group, "beat_prev"));
m_pNextBeat.reset(new ControlProxy(group, "beat_next"));

m_pLoopEnabled = new ControlProxy(group, "loop_enabled", this);
m_pLoopStartPosition = new ControlProxy(group, "loop_start_position", this);
m_pLoopEndPosition = new ControlProxy(group, "loop_end_position", this);
m_pLoopEnabled = std::make_unique<ControlProxy>(group, "loop_enabled", this);
m_pLoopStartPosition = std::make_unique<ControlProxy>(group, "loop_start_position", this);
m_pLoopEndPosition = std::make_unique<ControlProxy>(group, "loop_end_position", this);

m_pLocalBpm = new ControlObject(ConfigKey(group, "local_bpm"));
m_pAdjustBeatsFaster = new ControlPushButton(ConfigKey(group, "beats_adjust_faster"), false);
Expand All @@ -80,6 +80,10 @@ BpmControl::BpmControl(QString group,
connect(m_pTranslateBeatsLater, &ControlObject::valueChanged,
this, &BpmControl::slotTranslateBeatsLater,
Qt::DirectConnection);
m_pBeatsSetBarBeat = new ControlPushButton(ConfigKey(group, "beats_set_bar_beat"));
Copy link
Member

Choose a reason for hiding this comment

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

This can be a unique_ptr, because it has no parent.

connect(m_pBeatsSetBarBeat, &ControlObject::valueChanged,
this, &BpmControl::slotSetDownbeatOnClosestBeat,
Qt::DirectConnection);

// Pick a wide range (kBpmRangeMin to kBpmRangeMax) and allow out of bounds sets. This lets you
// map a soft-takeover MIDI knob to the BPM. This also creates bpm_up and
Expand Down Expand Up @@ -134,8 +138,8 @@ BpmControl::BpmControl(QString group,
Qt::DirectConnection);

// Measures distance from last beat in percentage: 0.5 = half-beat away.
m_pThisBeatDistance = new ControlProxy(group, "beat_distance", this);
m_pSyncMode = new ControlProxy(group, "sync_mode", this);
m_pThisBeatDistance = std::make_unique<ControlProxy>(group, "beat_distance", this);
m_pSyncMode = std::make_unique<ControlProxy>(group, "sync_mode", this);
}

BpmControl::~BpmControl() {
Expand All @@ -151,6 +155,7 @@ BpmControl::~BpmControl() {
delete m_pTranslateBeatsLater;
delete m_pAdjustBeatsFaster;
delete m_pAdjustBeatsSlower;
delete m_pBeatsSetBarBeat;
}

double BpmControl::getBpm() const {
Expand Down Expand Up @@ -194,6 +199,12 @@ void BpmControl::slotTranslateBeatsLater(double v) {
}
}

void BpmControl::slotSetDownbeatOnClosestBeat(double v) {
if (v > 0 && m_pBeats) {
Copy link
Member

Choose a reason for hiding this comment

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

Please copy the beats pointer to stack to ensure it does not become null

m_pBeats->setDownBeat(getSampleOfTrack().current);
}
}

void BpmControl::slotBpmTap(double v) {
if (v > 0) {
m_tapFilter.tap();
Expand Down Expand Up @@ -221,7 +232,7 @@ void BpmControl::slotTapFilter(double averageLength, int numSamples) {
// (60 seconds per minute) * (1000 milliseconds per second) / (X millis per
// beat) = Y beats/minute
double averageBpm = 60.0 * 1000.0 / averageLength / rateRatio;
pBeats->setBpm(averageBpm);
m_pBeats->setBpm(averageBpm);
}

void BpmControl::slotControlBeatSyncPhase(double v) {
Expand Down Expand Up @@ -432,7 +443,8 @@ double BpmControl::calcSyncAdjustment(bool userTweakingSync) {
kLogger.trace() << m_group << "****************";
kLogger.trace() << "master beat distance:" << syncTargetBeatDistance;
kLogger.trace() << "my beat distance:" << thisBeatDistance;
kLogger.trace() << "error :" << (shortest_distance - m_dUserOffset.getValue());
kLogger.trace() << "error :"
<< (shortest_distance - m_dUserOffset.getValue());
kLogger.trace() << "user offset :" << m_dUserOffset.getValue();
}

Expand Down Expand Up @@ -1025,7 +1037,7 @@ void BpmControl::collectFeatures(GroupFeatureState* pGroupFeatures) const {
if (sotPerSec != 0.0) {
pGroupFeatures->beat_length_sec = dThisBeatLength / sotPerSec;
pGroupFeatures->has_beat_length_sec = true;
} else {
} else {
pGroupFeatures->has_beat_length_sec = false;
}

Expand Down
24 changes: 14 additions & 10 deletions src/engine/controls/bpmcontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class BpmControl : public EngineControl {
void slotUpdateEngineBpm(double v = 0.0);
void slotBeatsTranslate(double);
void slotBeatsTranslateMatchAlignment(double);
void slotSetDownbeatOnClosestBeat(double);

private:
SyncMode getSyncMode() const {
Expand All @@ -107,20 +108,21 @@ class BpmControl : public EngineControl {
friend class SyncControl;

// ControlObjects that come from EngineBuffer
ControlProxy* m_pPlayButton;
std::unique_ptr<ControlProxy> m_pPlayButton;
QAtomicInt m_oldPlayButton;
ControlProxy* m_pReverseButton;
ControlProxy* m_pRateRatio;
std::unique_ptr<ControlProxy> m_pReverseButton;
std::unique_ptr<ControlProxy> m_pRateRatio;
ControlObject* m_pQuantize;

// ControlObjects that come from QuantizeControl
QScopedPointer<ControlProxy> m_pNextBeat;
QScopedPointer<ControlProxy> m_pPrevBeat;
std::unique_ptr<ControlProxy> m_pNextBeat;
std::unique_ptr<ControlProxy> m_pPrevBeat;
std::unique_ptr<ControlProxy> m_pClosestBeat;

// ControlObjects that come from LoopingControl
ControlProxy* m_pLoopEnabled;
ControlProxy* m_pLoopStartPosition;
ControlProxy* m_pLoopEndPosition;
std::unique_ptr<ControlProxy> m_pLoopEnabled;
std::unique_ptr<ControlProxy> m_pLoopStartPosition;
std::unique_ptr<ControlProxy> m_pLoopEndPosition;

// The average bpm around the current playposition;
ControlObject* m_pLocalBpm;
Expand All @@ -145,12 +147,14 @@ class BpmControl : public EngineControl {
ControlPushButton* m_pTranslateBeats;
// Button that translates beats to match another playing deck
ControlPushButton* m_pBeatsTranslateMatchAlignment;
// Button to set the nearest beat as a bar beat
ControlPushButton* m_pBeatsSetBarBeat;

ControlProxy* m_pThisBeatDistance;
std::unique_ptr<ControlProxy> m_pThisBeatDistance;
ControlValueAtomic<double> m_dSyncTargetBeatDistance;
ControlValueAtomic<double> m_dUserOffset;
QAtomicInt m_resetSyncAdjustment;
ControlProxy* m_pSyncMode;
std::unique_ptr<ControlProxy> m_pSyncMode;

TapFilter m_tapFilter; // threadsafe

Expand Down
2 changes: 1 addition & 1 deletion src/engine/controls/quantizecontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void QuantizeControl::trackLoaded(TrackPointer pNewTrack) {
lookupBeatPositions(0.0);
updateClosestBeat(0.0);
} else {
m_pBeats.clear();
m_pBeats.reset();
m_pCOPrevBeat->set(-1);
m_pCONextBeat->set(-1);
m_pCOClosestBeat->set(-1);
Expand Down
3 changes: 2 additions & 1 deletion src/library/banshee/bansheeplaylistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,8 @@ TrackPointer BansheePlaylistModel::getTrack(const QModelIndex& index) const {
pTrack->setComposer(getFieldString(index, CLM_COMPOSER));
// If the track has a BPM, then give it a static beatgrid.
if (bpm > 0) {
mixxx::BeatsPointer pBeats = BeatFactory::makeBeatGrid(*pTrack, bpm, 0.0);
mixxx::BeatsPointer pBeats = std::make_shared<mixxx::Beats>(mixxx::Beats(pTrack.get()));
pBeats->setGrid(bpm);
pTrack->setBeats(pBeats);
}

Expand Down
Loading