Skip to content

Commit

Permalink
Merge pull request #11 from uklotzde/new-signals-slots-syntax-library
Browse files Browse the repository at this point in the history
Merge master + fix include directives
  • Loading branch information
ferranpujolcamins authored Sep 29, 2019
2 parents a1fdea2 + 29ed622 commit 8599945
Show file tree
Hide file tree
Showing 68 changed files with 1,743 additions and 401 deletions.
1 change: 1 addition & 0 deletions build/depends.py
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,7 @@ def sources(self, build):
"src/database/schemamanager.cpp",

"src/library/trackcollection.cpp",
"src/library/externaltrackcollection.cpp",
"src/library/basesqltablemodel.cpp",
"src/library/basetrackcache.cpp",
"src/library/columncache.cpp",
Expand Down
16 changes: 12 additions & 4 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{ nixroot ? (import <nixpkgs> {}) }:
{ nixroot ? (import <nixpkgs> {})
, defaultLv2Plugins ? false
, lv2Plugins ? []
}:
let inherit (nixroot) stdenv pkgs lib
chromaprint fftw flac libid3tag libmad libopus libshout libsndfile lilv
libusb1 libvorbis libebur128 pkgconfig portaudio portmidi protobuf qt5 glib
Expand Down Expand Up @@ -42,14 +45,19 @@ let inherit (nixroot) stdenv pkgs lib

shell-run = nixroot.writeShellScriptBin "run" ''
BUILDDIR=$(ls -1 -d -t lin64_build lin_build | head -1)
$BUILDDIR/mixxx --settingsPath ./devsettings/ --resourcePath ./res "$@"
/usr/bin/env LV2_PATH=${lib.makeSearchPathOutput "lib" "lib/lv2" allLv2Plugins}:$LV2_PATH $BUILDDIR/mixxx --settingsPath ./devsettings/ --resourcePath ./res "$@"
'';

shell-debug = nixroot.writeShellScriptBin "debug" ''
BUILDDIR=$(ls -1 -d -t lin64_build lin_build | head -1)
gdb --args $BUILDDIR/mixxx --settingsPath ./devsettings/ --resourcePath ./res "$@"
'';

allLv2Plugins = lv2Plugins ++ (if defaultLv2Plugins then [
nixroot.x42-plugins nixroot.zam-plugins nixroot.rkrlv2 nixroot.mod-distortion
nixroot.infamousPlugins nixroot.artyFX
] else []);

in stdenv.mkDerivation rec {
name = "mixxx-${version}";
# reading the version from git output is very hard to do without wasting lots of diskspace and runtime
Expand Down Expand Up @@ -83,7 +91,7 @@ in stdenv.mkDerivation rec {
libusb1 libvorbis libebur128 pkgconfig portaudio portmidi protobuf qt5.full
rubberband scons sqlite taglib soundtouch vamp.vampSDK opusfile upower hidapi
ccache git glib x11 libGLU lilv lame lv2 makeWrapper qt5.qtbase
];
] ++ allLv2Plugins;

sconsFlags = [
"build=debug"
Expand All @@ -102,7 +110,7 @@ in stdenv.mkDerivation rec {
installPhase = ''
runHook preInstall
scons $sconsFlags "prefix=$out" install
wrapProgram $out/bin/mixxx --suffix QT_PLUGIN_PATH : ${qt5.qtbase}/${qt5.qtbase.qtPluginPrefix} --set QTDIR ${qt5.full}
wrapProgram $out/bin/mixxx --suffix QT_PLUGIN_PATH : ${qt5.qtbase}/${qt5.qtbase.qtPluginPrefix} --set QTDIR ${qt5.full} --prefix LV2_PATH : ${lib.makeSearchPath "lib/lv2" allLv2Plugins}
runHook postInstall
'';

Expand Down
54 changes: 48 additions & 6 deletions res/controllers/midi-components-0.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,34 @@
}
}
},
forEachComponentContainer: function (operation, recursive) {
if (typeof operation !== 'function') {
print('ERROR: ComponentContainer.forEachComponentContainer requires a function argument');
return;
}
if (recursive === undefined) { recursive = true; }

var that = this;
var applyOperationTo = function (obj) {
if (obj instanceof ComponentContainer) {
operation.call(that, obj);

if (recursive) {
obj.forEachComponentContainer(operation);
}
} else if (Array.isArray(obj)) {
obj.forEach(function (element) {
applyOperationTo(element);
});
}
};

for (var memberName in this) {
if (this.hasOwnProperty(memberName)) {
applyOperationTo(this[memberName]);
}
}
},
reconnectComponents: function (operation, recursive) {
this.forEachComponent(function (component) {
component.disconnect();
Expand All @@ -545,6 +573,7 @@
},
isShifted: false,
shift: function () {
// Shift direct child Components
this.forEachComponent(function (component) {
// Controls for push type Buttons depend on getting reset to 0 when the
// Button is released for correct behavior. If there is a skin button
Expand All @@ -568,11 +597,18 @@
}
component.shift();
}
// Set isShifted for child ComponentContainers forEachComponent is iterating through recursively
this.isShifted = true;
});
}, false);

// Shift child ComponentContainers
this.forEachComponentContainer(function (container) {
container.shift();
}, false);

// Set isShifted for each ComponentContainer recursively
this.isShifted = true;
},
unshift: function () {
// Unshift direct child Components
this.forEachComponent(function (component) {
// Refer to comment in ComponentContainer.shift() above for explanation
if (typeof component.unshift === 'function') {
Expand All @@ -588,9 +624,15 @@
}
component.unshift();
}
// Set isShifted for child ComponentContainers forEachComponent is iterating through recursively
this.isShifted = false;
});
}, false);

// Unshift child ComponentContainers
this.forEachComponentContainer(function (container) {
container.unshift();
}, false);

// Unset isShifted for each ComponentContainer recursively
this.isShifted = false;
},
applyLayer: function (newLayer, reconnectComponents) {
if (reconnectComponents !== false) {
Expand Down
45 changes: 33 additions & 12 deletions src/engine/controls/loopingcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ LoopingControl::LoopingControl(QString group,
m_loopSamples.setValue(m_oldLoopSamples);
m_currentSample.setValue(0.0);
m_pActiveBeatLoop = NULL;

m_pRateControl = NULL;
//Create loop-in, loop-out, loop-exit, and reloop/exit ControlObjects
m_pLoopInButton = new ControlPushButton(ConfigKey(group, "loop_in"));
connect(m_pLoopInButton, &ControlObject::valueChanged,
Expand Down Expand Up @@ -682,6 +682,10 @@ void LoopingControl::setLoopOutToCurrentPosition() {
m_loopSamples.setValue(loopSamples);
}

void LoopingControl::setRateControl(RateControl* rateControl) {
m_pRateControl = rateControl;
}

void LoopingControl::slotLoopOut(double pressed) {
if (m_pTrack == nullptr) {
return;
Expand Down Expand Up @@ -1060,16 +1064,19 @@ void LoopingControl::slotBeatLoop(double beats, bool keepStartPoint, bool enable
newloopSamples.start = currentSample;
}
} else {
// loop_in is set to the previous beat if quantize is on. The
// closest beat might be ahead of play position which would cause a seek.
// TODO: If in reverse, should probably choose nextBeat.
// loop_in is set to the closest beat if quantize is on and the loop size is >= 1 beat.
// The closest beat might be ahead of play position and will cause a catching loop.
double prevBeat;
double nextBeat;
pBeats->findPrevNextBeats(currentSample, &prevBeat, &nextBeat);

if (m_pQuantizeEnabled->toBool() && prevBeat != -1) {
double beatLength = nextBeat - prevBeat;
double loopLength = beatLength * beats;

double closestBeat = pBeats->findClosestBeat(currentSample);
if (beats >= 1.0) {
newloopSamples.start = prevBeat;
newloopSamples.start = closestBeat;
} else {
// In case of beat length less then 1 beat:
// (| - beats, ^ - current track's position):
Expand All @@ -1078,15 +1085,29 @@ void LoopingControl::slotBeatLoop(double beats, bool keepStartPoint, bool enable
//
// If we press 1/2 beatloop we want loop from 50% to 100%,
// If I press 1/4 beatloop, we want loop from 50% to 75% etc
double beat_len = nextBeat - prevBeat;
double loops_per_beat = 1.0 / beats;
double beat_pos = currentSample - prevBeat;
int beat_frac =
static_cast<int>(floor((beat_pos / beat_len) *
loops_per_beat));
newloopSamples.start = prevBeat + beat_len / loops_per_beat * beat_frac;
double samplesSinceLastBeat = currentSample - prevBeat;

// find the previous beat fraction and check if the current position is closer to this or the next one
// place the new loop start to the closer one
double previousFractionBeat = prevBeat + floor(samplesSinceLastBeat / loopLength) * loopLength;
double samplesSinceLastFractionBeat = currentSample - previousFractionBeat;

if (samplesSinceLastFractionBeat <= (loopLength / 2.0)) {
newloopSamples.start = previousFractionBeat;
} else {
newloopSamples.start = previousFractionBeat + loopLength;
}
}

// If running reverse, move the loop one loop size to the left.
// Thus, the loops end will be closest to the current position
bool reverse = false;
if (m_pRateControl != NULL) {
reverse = m_pRateControl->isReverseButtonPressed();
}
if (reverse) {
newloopSamples.start -= loopLength;
}
} else {
newloopSamples.start = currentSample;
}
Expand Down
10 changes: 6 additions & 4 deletions src/engine/controls/loopingcontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
#include <QObject>
#include <QStack>

#include "preferences/usersettings.h"
#include "control/controlvalue.h"
#include "engine/controls/enginecontrol.h"
#include "track/track.h"
#include "engine/controls/ratecontrol.h"
#include "preferences/usersettings.h"
#include "track/beats.h"
#include "control/controlvalue.h"
#include "track/track.h"

#define MINIMUM_AUDIBLE_LOOP_SIZE 300 // In samples

Expand Down Expand Up @@ -50,7 +51,7 @@ class LoopingControl : public EngineControl {
double getSyncPositionInsideLoop(double dRequestedPlaypos, double dSyncedPlayPos);

void notifySeek(double dNewPlaypos) override;

void setRateControl(RateControl* rateControl);
bool isLoopingEnabled();

public slots:
Expand Down Expand Up @@ -129,6 +130,7 @@ class LoopingControl : public EngineControl {
ControlPushButton* m_pLoopHalveButton;
ControlPushButton* m_pLoopDoubleButton;
ControlObject* m_pSlipEnabled;
RateControl* m_pRateControl;
ControlObject* m_pPlayButton;

bool m_bLoopingEnabled;
Expand Down
7 changes: 7 additions & 0 deletions src/engine/controls/ratecontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,3 +556,10 @@ void RateControl::resetRateTemp(void)
void RateControl::notifySeek(double playPos) {
m_pScratchController->notifySeek(playPos);
}

bool RateControl::isReverseButtonPressed() {
if (m_pReverseButton) {
return m_pReverseButton->toBool();
}
return false;
}
1 change: 1 addition & 0 deletions src/engine/controls/ratecontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class RateControl : public EngineControl {
static void setRateRampSensitivity(int);
static int getRateRampSensitivity();
void notifySeek(double dNewPlaypos) override;
bool isReverseButtonPressed();

public slots:
void slotReverseRollActivate(double);
Expand Down
12 changes: 9 additions & 3 deletions src/engine/enginebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,13 @@ EngineBuffer::EngineBuffer(const QString& group, UserSettingsPointer pConfig,
// quantization (alignment) of loop in/out positions and (hot)cues with
// beats.
QuantizeControl* quantize_control = new QuantizeControl(group, pConfig);
addControl(quantize_control);
m_pQuantize = ControlObject::getControl(ConfigKey(group, "quantize"));

// Create the Loop Controller
m_pLoopingControl = new LoopingControl(group, pConfig);
addControl(m_pLoopingControl);

addControl(quantize_control);
m_pQuantize = ControlObject::getControl(ConfigKey(group, "quantize"));

m_pEngineSync = pMixingEngine->getEngineSync();

m_pSyncControl = new SyncControl(group, pConfig, pChannel, m_pEngineSync);
Expand All @@ -198,9 +197,12 @@ EngineBuffer::EngineBuffer(const QString& group, UserSettingsPointer pConfig,
addControl(m_pVinylControlControl);
#endif

// Create the Rate Controller
m_pRateControl = new RateControl(group, pConfig);
// Add the Rate Controller
addControl(m_pRateControl);
// Looping Control needs Rate Control for Reverse Button
m_pLoopingControl->setRateControl(m_pRateControl);

// Create the BPM Controller
m_pBpmControl = new BpmControl(group, pConfig);
Expand Down Expand Up @@ -532,6 +534,10 @@ TrackPointer EngineBuffer::getLoadedTrack() const {
return m_pCurrentTrack;
}

bool EngineBuffer::isReverse() {
return m_reverse_old;
}

void EngineBuffer::ejectTrack() {
// clear track values in any case, this may fix Bug #1450424
//qDebug() << "EngineBuffer::ejectTrack()";
Expand Down
2 changes: 2 additions & 0 deletions src/engine/enginebuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ class EngineBuffer : public EngineObject {
bool getQueuedSeekPosition(double* pSeekPosition);
TrackPointer getLoadedTrack() const;

bool isReverse();

double getExactPlayPos();
double getVisualPlayPos();
double getTrackSamples();
Expand Down
4 changes: 2 additions & 2 deletions src/library/basesqltablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include <QtDebug>
#include <QUrl>
#include <QTableView>

#include "library/basesqltablemodel.h"

Expand All @@ -21,6 +20,7 @@
#include "util/duration.h"
#include "util/assert.h"
#include "util/performancetimer.h"
#include "widget/wlibrarytableview.h"

static const bool sDebug = false;

Expand Down Expand Up @@ -1113,7 +1113,7 @@ QMimeData* BaseSqlTableModel::mimeData(const QModelIndexList &indexes) const {
}

QAbstractItemDelegate* BaseSqlTableModel::delegateForColumn(const int i, QObject* pParent) {
WLibraryTableView* pTableView = qobject_cast<WLibraryTableView*>(pParent);
auto* pTableView = qobject_cast<WLibraryTableView*>(pParent);
DEBUG_ASSERT(pTableView);

if (i == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_RATING)) {
Expand Down
24 changes: 12 additions & 12 deletions src/library/coverartdelegate.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
#include <QTableView>
#include <QPainter>

#include "library/coverartdelegate.h"
#include "library/coverartcache.h"
#include "library/dao/trackschema.h"
#include "library/trackmodel.h"

#include "widget/wlibrarytableview.h"

#include "util/math.h"


CoverArtDelegate::CoverArtDelegate(WLibraryTableView* parent)
: TableItemDelegate(parent),
m_pTableView(parent),
Expand All @@ -25,16 +29,15 @@ CoverArtDelegate::CoverArtDelegate(WLibraryTableView* parent)

CoverArtCache* pCache = CoverArtCache::instance();
if (pCache) {
connect(pCache, SIGNAL(coverFound(const QObject*, const CoverInfoRelative&,
QPixmap, bool)),
this, SLOT(slotCoverFound(const QObject*, const CoverInfoRelative&,
QPixmap, bool)));
connect(pCache,
&CoverArtCache::coverFound,
this,
&CoverArtDelegate::slotCoverFound);
}

TrackModel* pTrackModel = NULL;
QTableView* pTableView = NULL;
if (QTableView *tableView = qobject_cast<QTableView*>(parent)) {
pTableView = tableView;
TrackModel* pTrackModel = nullptr;
QTableView* pTableView = qobject_cast<QTableView*>(parent);
if (pTableView) {
pTrackModel = dynamic_cast<TrackModel*>(pTableView->model());
}

Expand All @@ -56,9 +59,6 @@ CoverArtDelegate::CoverArtDelegate(WLibraryTableView* parent)
}
}

CoverArtDelegate::~CoverArtDelegate() {
}

void CoverArtDelegate::slotOnlyCachedCoverArt(bool b) {
m_bOnlyCachedCover = b;

Expand Down
Loading

0 comments on commit 8599945

Please sign in to comment.