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

Render bar and phrase marks and a menu option to enable / disable #2186

Closed
wants to merge 7 commits into from
Closed
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.cproject
.project
*.diff
*.log
*.o
Expand Down
2 changes: 2 additions & 0 deletions res/skins/Deere/deck_visual_row.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
<SignalRGBLowColor></SignalRGBLowColor>
<SignalColor><Variable name="DeckSignalColor"/></SignalColor>
<BeatColor>#ffffff</BeatColor>
<BarColor>#ccffff</BarColor>
<PhraseColor>#00ff00</PhraseColor>
<PlayPosColor>#00FF00</PlayPosColor>
<EndOfTrackColor>#EA0000</EndOfTrackColor>
<AxesColor></AxesColor>
Expand Down
2 changes: 2 additions & 0 deletions res/skins/LateNight/waveform.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
<SignalRGBMidColor><Variable name="SignalRGBMidColor"/></SignalRGBMidColor>
<SignalRGBHighColor><Variable name="SignalRGBHighColor"/></SignalRGBHighColor>
<BeatColor>#ffffff</BeatColor>
<BarColor>#ccffff</BarColor>
<PhraseColor>#00ff00</PhraseColor>
<BeatHighlightColor></BeatHighlightColor>
<PlayPosColor>#00FF00</PlayPosColor>
<EndOfTrackColor>#EA0000</EndOfTrackColor>
Expand Down
2 changes: 2 additions & 0 deletions res/skins/Shade/waveform.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<SignalLowColor></SignalLowColor>
<SignalColor>#191F24</SignalColor>
<BeatColor>#FFFFFF</BeatColor>
<BarColor>#CCFFFFF</BarColor>
<PhraseColor>#00FF00</PhraseColor>
<PlayPosColor>#00FF00</PlayPosColor>
<EndOfTrackColor>#EA0000</EndOfTrackColor>
<AxesColor>#00FF00</AxesColor>
Expand Down
2 changes: 2 additions & 0 deletions res/skins/Tango/waveform.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ Variables:
<SignalRGBMidColor><Variable name="SignalRGBMidColor"/></SignalRGBMidColor>
<SignalRGBHighColor><Variable name="SignalRGBHighColor"/></SignalRGBHighColor>
<BeatColor>#ffffff</BeatColor>
<BarColor>#00630e</BarColor>
<PhraseColor>#00ff00</PhraseColor>
<PlayPosColor>#FF4300</PlayPosColor>
<EndOfTrackColor><Variable name="EndOfTrackColor"/></EndOfTrackColor>
<DefaultMark>
Expand Down
7 changes: 7 additions & 0 deletions src/engine/controls/bpmcontrol.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include <QStringList>
#include <QtDebug>


#include "control/controlobject.h"
#include "control/controlpushbutton.h"
Expand Down Expand Up @@ -791,6 +793,11 @@ void BpmControl::slotBeatsTranslate(double v) {
delta--;
}
pBeats->translate(delta);

TrackPointer pTrack = m_pTrack;
if (pTrack) {
pTrack->setPhraseBegin(currentSample);
}
}
}

Expand Down
9 changes: 9 additions & 0 deletions src/preferences/dialog/dlgprefwaveform.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <QtDebug>

#include "preferences/dialog/dlgprefwaveform.h"

#include "mixxx.h"
Expand Down Expand Up @@ -73,6 +75,8 @@ DlgPrefWaveform::DlgPrefWaveform(QWidget* pParent, MixxxMainWindow* pMixxx,
this, SLOT(slotSetVisualGainHigh(double)));
connect(normalizeOverviewCheckBox, SIGNAL(toggled(bool)),
this, SLOT(slotSetNormalizeOverview(bool)));
connect(showBarAndPhraseMarksCheckBox, SIGNAL(toggled(bool)),
this, SLOT(slotSetBarAndPhrase(bool)));
connect(factory, SIGNAL(waveformMeasured(float,int)),
this, SLOT(slotWaveformMeasured(float,int)));
connect(waveformOverviewComboBox, SIGNAL(currentIndexChanged(int)),
Expand Down Expand Up @@ -111,6 +115,7 @@ void DlgPrefWaveform::slotUpdate() {
midVisualGain->setValue(factory->getVisualGain(WaveformWidgetFactory::Mid));
highVisualGain->setValue(factory->getVisualGain(WaveformWidgetFactory::High));
normalizeOverviewCheckBox->setChecked(factory->isOverviewNormalized());
showBarAndPhraseMarksCheckBox->setChecked(factory->getShowBarAndPhrase());
// Round zoom to int to get a default zoom index.
defaultZoomComboBox->setCurrentIndex(static_cast<int>(factory->getDefaultZoom()) - 1);
playMarkerPositionSlider->setValue(factory->getPlayMarkerPosition() * 100);
Expand Down Expand Up @@ -231,6 +236,10 @@ void DlgPrefWaveform::slotSetNormalizeOverview(bool normalize) {
WaveformWidgetFactory::instance()->setOverviewNormalized(normalize);
}

void DlgPrefWaveform::slotSetBarAndPhrase(bool showBarAndPhrase) {
WaveformWidgetFactory::instance()->setShowBarAndPhrase(showBarAndPhrase);
}

void DlgPrefWaveform::slotWaveformMeasured(float frameRate, int droppedFrames) {
frameRateAverage->setText(
QString::number((double)frameRate, 'f', 2) + " : " +
Expand Down
1 change: 1 addition & 0 deletions src/preferences/dialog/dlgprefwaveform.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class DlgPrefWaveform : public DlgPreferencePage, public Ui::DlgPrefWaveformDlg
void slotSetVisualGainMid(double gain);
void slotSetVisualGainHigh(double gain);
void slotSetNormalizeOverview(bool normalize);
void slotSetBarAndPhrase(bool barAndPhrase);
void slotWaveformMeasured(float frameRate, int droppedFrames);
void slotClearCachedWaveforms();
void slotSetBeatGridAlpha(int alpha);
Expand Down
21 changes: 14 additions & 7 deletions src/preferences/dialog/dlgprefwaveformdlg.ui
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_2">
<item row="10" column="0">
<item row="12" column="0">
<widget class="QLabel" name="visualGainLabel">
<property name="text">
<string>Visual gain</string>
Expand Down Expand Up @@ -64,7 +64,14 @@
</property>
</widget>
</item>
<item row="13" column="1">
<item row="10" column="1">
<widget class="QCheckBox" name="showBarAndPhraseMarksCheckBox">
<property name="text">
<string>Show bar and phrase marks</string>
</property>
</widget>
</item>
<item row="14" column="1">
<widget class="QLabel" name="openGlStatusIcon">
<property name="toolTip">
<string>Displays which OpenGL version is supported by the current platform.</string>
Expand Down Expand Up @@ -93,7 +100,7 @@
</property>
</widget>
</item>
<item row="14" column="0">
<item row="15" column="0">
<widget class="QLabel" name="openGlStatusLabel_2">
<property name="toolTip">
<string/>
Expand Down Expand Up @@ -123,14 +130,14 @@
<widget class="QComboBox" name="defaultZoomComboBox"/>
</item>

<item row="12" column="0" colspan="4">
<item row="13" column="0" colspan="4">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="13" column="0">
<item row="14" column="0">
<widget class="QLabel" name="openGlStatusLabel">
<property name="toolTip">
<string/>
Expand Down Expand Up @@ -165,7 +172,7 @@
</property>
</widget>
</item>
<item row="10" column="1" colspan="3">
<item row="12" column="1" colspan="3">
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="2">
<widget class="QDoubleSpinBox" name="midVisualGain">
Expand Down Expand Up @@ -323,7 +330,7 @@ Select from different types of displays for the waveform, which differ primarily
</property>
</widget>
</item>
<item row="14" column="1">
<item row="16" column="1">
<widget class="QLabel" name="frameRateAverage">
<property name="toolTip">
<string>Displays the actual frame rate.</string>
Expand Down
1 change: 1 addition & 0 deletions src/proto/beats.proto
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ message BeatMap {
message BeatGrid {
optional Bpm bpm = 1;
optional Beat first_beat = 2;
optional Beat first_phrase = 3;
}
44 changes: 22 additions & 22 deletions src/test/beatgridtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ TEST(BeatGridTest, TestNthBeatWhenOnBeat) {
TrackPointer pTrack(Track::newTemporary());

int sampleRate = 44100;
double bpm = 60.0;
double bpm = 60.1;
const int kFrameSize = 2;
pTrack->setBpm(bpm);
pTrack->setSampleRate(sampleRate);
Expand All @@ -58,26 +58,26 @@ TEST(BeatGridTest, TestNthBeatWhenOnBeat) {
// findNthBeat should return exactly the current beat if we ask for 1 or
// -1. For all other values, it should return n times the beat length.
for (int i = 1; i < 20; ++i) {
EXPECT_EQ(position + beatLength*(i-1), pGrid->findNthBeat(position, i));
EXPECT_EQ(position + beatLength*(-i+1), pGrid->findNthBeat(position, -i));
EXPECT_DOUBLE_EQ(position + beatLength*(i-1), pGrid->findNthBeat(position, i));
EXPECT_DOUBLE_EQ(position + beatLength*(-i+1), pGrid->findNthBeat(position, -i));
}

// Also test prev/next beat calculation.
double prevBeat, nextBeat;
pGrid->findPrevNextBeats(position, &prevBeat, &nextBeat);
EXPECT_EQ(position, prevBeat);
EXPECT_EQ(position + beatLength, nextBeat);
EXPECT_DOUBLE_EQ(position, prevBeat);
EXPECT_DOUBLE_EQ(position + beatLength, nextBeat);

// Both previous and next beat should return the current position.
EXPECT_EQ(position, pGrid->findNextBeat(position));
EXPECT_EQ(position, pGrid->findPrevBeat(position));
EXPECT_DOUBLE_EQ(position, pGrid->findNextBeat(position));
EXPECT_DOUBLE_EQ(position, pGrid->findPrevBeat(position));
}

TEST(BeatGridTest, TestNthBeatWhenOnBeat_BeforeEpsilon) {
TrackPointer pTrack(Track::newTemporary());

int sampleRate = 44100;
double bpm = 60.0;
double bpm = 60.1;
const int kFrameSize = 2;
pTrack->setBpm(bpm);
pTrack->setSampleRate(sampleRate);
Expand All @@ -96,26 +96,26 @@ TEST(BeatGridTest, TestNthBeatWhenOnBeat_BeforeEpsilon) {
// findNthBeat should return exactly the current beat if we ask for 1 or
// -1. For all other values, it should return n times the beat length.
for (int i = 1; i < 20; ++i) {
EXPECT_EQ(kClosestBeat + beatLength*(i-1), pGrid->findNthBeat(position, i));
EXPECT_EQ(kClosestBeat + beatLength*(-i+1), pGrid->findNthBeat(position, -i));
EXPECT_DOUBLE_EQ(kClosestBeat + beatLength*(i-1), pGrid->findNthBeat(position, i));
EXPECT_DOUBLE_EQ(kClosestBeat + beatLength*(-i+1), pGrid->findNthBeat(position, -i));
}

// Also test prev/next beat calculation.
double prevBeat, nextBeat;
pGrid->findPrevNextBeats(position, &prevBeat, &nextBeat);
EXPECT_EQ(kClosestBeat, prevBeat);
EXPECT_EQ(kClosestBeat + beatLength, nextBeat);
EXPECT_DOUBLE_EQ(kClosestBeat, prevBeat);
EXPECT_DOUBLE_EQ(kClosestBeat + beatLength, nextBeat);

// Both previous and next beat should return the closest beat.
EXPECT_EQ(kClosestBeat, pGrid->findNextBeat(position));
EXPECT_EQ(kClosestBeat, pGrid->findPrevBeat(position));
EXPECT_DOUBLE_EQ(kClosestBeat, pGrid->findNextBeat(position));
EXPECT_DOUBLE_EQ(kClosestBeat, pGrid->findPrevBeat(position));
}

TEST(BeatGridTest, TestNthBeatWhenOnBeat_AfterEpsilon) {
TrackPointer pTrack(Track::newTemporary());

int sampleRate = 44100;
double bpm = 60.0;
double bpm = 60.1;
const int kFrameSize = 2;
pTrack->setBpm(bpm);
pTrack->setSampleRate(sampleRate);
Expand All @@ -134,25 +134,25 @@ TEST(BeatGridTest, TestNthBeatWhenOnBeat_AfterEpsilon) {
// findNthBeat should return exactly the current beat if we ask for 1 or
// -1. For all other values, it should return n times the beat length.
for (int i = 1; i < 20; ++i) {
EXPECT_EQ(kClosestBeat + beatLength*(i-1), pGrid->findNthBeat(position, i));
EXPECT_EQ(kClosestBeat + beatLength*(-i+1), pGrid->findNthBeat(position, -i));
EXPECT_DOUBLE_EQ(kClosestBeat + beatLength*(i-1), pGrid->findNthBeat(position, i));
EXPECT_DOUBLE_EQ(kClosestBeat + beatLength*(-i+1), pGrid->findNthBeat(position, -i));
}

// Also test prev/next beat calculation.
double prevBeat, nextBeat;
pGrid->findPrevNextBeats(position, &prevBeat, &nextBeat);
EXPECT_EQ(kClosestBeat, prevBeat);
EXPECT_EQ(kClosestBeat + beatLength, nextBeat);
EXPECT_DOUBLE_EQ(kClosestBeat, prevBeat);
EXPECT_DOUBLE_EQ(kClosestBeat + beatLength, nextBeat);

// Both previous and next beat should return the closest beat.
EXPECT_EQ(kClosestBeat, pGrid->findNextBeat(position));
EXPECT_EQ(kClosestBeat, pGrid->findPrevBeat(position));
EXPECT_DOUBLE_EQ(kClosestBeat, pGrid->findNextBeat(position));
EXPECT_DOUBLE_EQ(kClosestBeat, pGrid->findPrevBeat(position));
}

TEST(BeatGridTest, TestNthBeatWhenNotOnBeat) {
TrackPointer pTrack(Track::newTemporary());
int sampleRate = 44100;
double bpm = 60.0;
double bpm = 60.1;
const int kFrameSize = 2;
pTrack->setBpm(bpm);
pTrack->setSampleRate(sampleRate);
Expand Down
Loading