Skip to content

Commit

Permalink
MidiController: Add way to get the syncable from a controller
Browse files Browse the repository at this point in the history
  • Loading branch information
Holzhaus committed Mar 14, 2021
1 parent 5af29b3 commit 4ae9c5c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/controllers/controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

#include <QElapsedTimer>
#include <QTimerEvent>
#include <memory>

#include "controllers/controllermappinginfo.h"
#include "controllers/legacycontrollermapping.h"
#include "controllers/legacycontrollermappingfilehandler.h"
#include "controllers/scripting/legacy/controllerscriptenginelegacy.h"
#include "engine/sync/syncable.h"
#include "util/duration.h"

class ControllerJSProxy;
Expand Down Expand Up @@ -116,6 +118,10 @@ class Controller : public QObject {
// polling/processing but before closing the device.
virtual void stopEngine();

virtual std::shared_ptr<Syncable> syncable() const {
return nullptr;
}

// To be called when receiving events
void triggerActivity();

Expand Down
6 changes: 3 additions & 3 deletions src/controllers/midi/midicontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

MidiController::MidiController(const QString& group)
: Controller(group),
m_beatClock(group) {
m_pBeatClock(std::make_shared<mixxx::MidiBeatClock>(group)) {
setDeviceCategory(tr("MIDI Controller"));
}

Expand Down Expand Up @@ -215,8 +215,8 @@ void MidiController::receivedShortMessage(unsigned char status,
unsigned char channel = MidiUtils::channelFromStatus(status);
unsigned char opCode = MidiUtils::opCodeFromStatus(status);

if (m_beatClock.canReceiveMidiStatus(status)) {
m_beatClock.receive(status, timestamp);
if (m_pBeatClock->canReceiveMidiStatus(status)) {
m_pBeatClock->receive(status, timestamp);
}

// Ignore MIDI beat clock messages (0xF8) until we have proper MIDI sync in
Expand Down
6 changes: 5 additions & 1 deletion src/controllers/midi/midicontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ class MidiController : public Controller {

bool matchMapping(const MappingInfo& mapping) override;

std::shared_ptr<Syncable> syncable() const override {
return m_pBeatClock;
}

signals:
void messageReceived(unsigned char status, unsigned char control, unsigned char value);

Expand Down Expand Up @@ -93,7 +97,7 @@ class MidiController : public Controller {
std::shared_ptr<LegacyMidiControllerMapping> m_pMapping;
SoftTakeoverCtrl m_st;
QList<QPair<MidiInputMapping, unsigned char> > m_fourteen_bit_queued_mappings;
mixxx::MidiBeatClock m_beatClock;
std::shared_ptr<mixxx::MidiBeatClock> m_pBeatClock;

// So it can access sendShortMsg()
friend class MidiOutputHandler;
Expand Down

0 comments on commit 4ae9c5c

Please sign in to comment.