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

OSC in Mixxx (20241001) #13714

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
38 changes: 38 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,8 @@ add_library(mixxx-lib STATIC EXCLUDE_FROM_ALL
src/preferences/dialog/dlgpreflibrarydlg.ui
src/preferences/dialog/dlgprefmixer.cpp
src/preferences/dialog/dlgprefmixerdlg.ui
src/preferences/dialog/dlgprefosc.cpp
src/preferences/dialog/dlgprefoscdlg.ui
src/preferences/dialog/dlgprefrecord.cpp
src/preferences/dialog/dlgprefrecorddlg.ui
src/preferences/dialog/dlgprefreplaygain.cpp
Expand Down Expand Up @@ -2557,6 +2559,42 @@ add_library(rekordbox_metadata STATIC EXCLUDE_FROM_ALL
target_include_directories(rekordbox_metadata SYSTEM PUBLIC lib/rekordbox-metadata)
target_link_libraries(mixxx-lib PRIVATE rekordbox_metadata)

IF(WIN32)
set(IpSystemTypePath src/osc/ip/win32)
set(LIBS ${LIBS} Ws2_32 winmm)
ELSE(WIN32)
set(IpSystemTypePath src/osc/ip/posix)
ENDIF(WIN32)

#eve osc
ADD_LIBRARY(oscpack
src/osc/ip/IpEndpointName.cpp
src/osc/ip/IpEndpointName.h
src/osc/ip/NetworkingUtils.h
${IpSystemTypePath}/NetworkingUtils.cpp
src/osc/ip/PacketListener.h
src/osc/ip/TimerListener.h
src/osc/ip/UdpSocket.h
${IpSystemTypePath}/UdpSocket.cpp
src/osc/osc/MessageMappingOscPacketListener.h
src/osc/osc/OscException.h
src/osc/osc/OscHostEndianness.h
src/osc/osc/OscOutboundPacketStream.cpp
src/osc/osc/OscOutboundPacketStream.h
src/osc/osc/OscPacketListener.h
src/osc/osc/OscPrintReceivedElements.cpp
src/osc/osc/OscPrintReceivedElements.h
src/osc/osc/OscReceivedElements.cpp
src/osc/osc/OscReceivedElements.h
src/osc/osc/OscTypes.cpp
src/osc/osc/OscTypes.h
)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
#target_link_libraries(mixxx oscpack ${LIBS})
target_include_directories(mixxx-lib SYSTEM PRIVATE ip)
target_include_directories(mixxx-lib SYSTEM PRIVATE osc)
target_link_libraries(mixxx-lib PRIVATE oscpack)

#silence "enumeration values not handled in switch" in generated code
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
target_compile_options(rekordbox_metadata PRIVATE -Wno-switch)
Expand Down
Binary file added src/RCa13796
Binary file not shown.
Binary file added src/RCb13796
Binary file not shown.
29 changes: 29 additions & 0 deletions src/engine/enginebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ const QString kAppGroup = QStringLiteral("[App]");

} // anonymous namespace

// EveOSC
void OscTrackLoadedInGroup(UserSettingsPointer m_pConfig,
const QString& OscGroup,
const QString& TrackArtist,
const QString& TrackTitle,
float track_loaded,
float duration,
float playposition);
void OscNoTrackLoadedInGroup(UserSettingsPointer m_pConfig, const QString& OscGroup);
// EveOSC

EngineBuffer::EngineBuffer(const QString& group,
UserSettingsPointer pConfig,
EngineChannel* pChannel,
Expand Down Expand Up @@ -563,6 +574,18 @@ void EngineBuffer::slotTrackLoaded(TrackPointer pTrack,
m_pTrackSampleRate->set(trackSampleRate.toDouble());
m_pTrackLoaded->forceSet(1);

// EveOSC begin
if (m_pConfig->getValue<bool>(ConfigKey("[OSC]", "OscEnabled"))) {
OscTrackLoadedInGroup(m_pConfig,
getGroup(),
pTrack->getArtist().toLatin1(),
pTrack->getTitle().toLatin1(),
(float)1,
(float)pTrack->getDuration(),
(float)0);
}
// EveOSC end

// Reset slip mode
m_pSlipButton->set(0);
m_bSlipEnabledProcessing = false;
Expand Down Expand Up @@ -632,6 +655,12 @@ void EngineBuffer::ejectTrack() {
m_pTrackSampleRate->set(0);
m_pTrackLoaded->forceSet(0);

// EveOSC begin
if (m_pConfig->getValue<bool>(ConfigKey("[OSC]", "OscEnabled"))) {
OscNoTrackLoadedInGroup(m_pConfig, getGroup());
}
// EveOSC end

m_playButton->set(0.0);
m_playposSlider->set(0);
m_pCueControl->resetIndicators();
Expand Down
11 changes: 11 additions & 0 deletions src/mixer/basetrackplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ inline double trackColorToDouble(mixxx::RgbColor::optional_t color) {
}
} // namespace

// EveOSC
void OscChangedPlayState(UserSettingsPointer m_pConfig,
const QString& OscGroup,
float playstate);
// EveOSC

BaseTrackPlayer::BaseTrackPlayer(PlayerManager* pParent, const QString& group)
: BasePlayer(pParent, group) {
}
Expand Down Expand Up @@ -924,6 +930,11 @@ void BaseTrackPlayerImpl::slotPlayToggled(double value) {
if (value == 0 && m_replaygainPending) {
setReplayGain(m_pLoadedTrack->getReplayGain().getRatio());
}
// EveOSC begin
if (m_pConfig->getValue<bool>(ConfigKey("[OSC]", "OscEnabled"))) {
OscChangedPlayState(m_pConfig, getGroup(), (float)value);
}
// EveOSC endc
}

EngineDeck* BaseTrackPlayerImpl::getEngineDeck() const {
Expand Down
18 changes: 18 additions & 0 deletions src/mixxxmainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@
#include "vinylcontrol/vinylcontrolmanager.h"
#endif

// EveOSC
#include "osc/oscfunctions.h"
#include "osc/oscreceiver.cpp"
// EveOSC

namespace {
#ifdef __LINUX__
// Detect if the desktop supports a global menu to decide whether we need to rebuild
Expand Down Expand Up @@ -132,6 +137,9 @@ MixxxMainWindow::MixxxMainWindow(std::shared_ptr<mixxx::CoreServices> pCoreServi

m_pGuiTick = new GuiTick();
m_pVisualsManager = new VisualsManager();
// EveOSC
oscEnable();
// EveOSC
}

#ifdef MIXXX_USE_QOPENGL
Expand Down Expand Up @@ -1445,3 +1453,13 @@ void MixxxMainWindow::initializationProgressUpdate(int progress, const QString&
}
qApp->processEvents();
}

void MixxxMainWindow::oscEnable() {
UserSettingsPointer pConfig;
if (m_pCoreServices->getSettings()->getValue<bool>(ConfigKey("[OSC]", "OscEnabled"))) {
qDebug() << "Mixxx OSC Service Enabled";
OscReceiverMain(m_pCoreServices->getSettings());
} else {
qDebug() << "Mixxx OSC Service NOT Enabled";
}
}
3 changes: 3 additions & 0 deletions src/mixxxmainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ class MixxxMainWindow : public QMainWindow {
private:
void initializeWindow();
void checkDirectRendering();
// EveOSC
void oscEnable();
// EveOSC

/// Load skin to a QWidget that we set as the central widget.
bool loadConfiguredSkin();
Expand Down
110 changes: 110 additions & 0 deletions src/osc/ip/IpEndpointName.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/*
oscpack -- Open Sound Control (OSC) packet manipulation library
http://www.rossbencina.com/code/oscpack

Copyright (c) 2004-2013 Ross Bencina <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

/*
The text above constitutes the entire oscpack license; however,
the oscpack developer(s) also make the following non-binding requests:

Any person wishing to distribute modifications to the Software is
requested to send the modifications to the original developer so that
they can be incorporated into the canonical version. It is also
requested that these non-binding requests be included whenever the
above license is reproduced.
*/
#include "IpEndpointName.h"

#include <cstdio>

#include "NetworkingUtils.h"

unsigned long IpEndpointName::GetHostByName(const char* s) {
return ::GetHostByName(s);
}

void IpEndpointName::AddressAsString(char* s) const {
if (address == ANY_ADDRESS) {
// std::sprintf(s, "<any>");
std::snprintf(s, 16, "<any>");
} else {
// std::sprintf(s,
// "%d.%d.%d.%d",
// (int)((address >> 24) & 0xFF),
// (int)((address >> 16) & 0xFF),
// (int)((address >> 8) & 0xFF),
// (int)(address & 0xFF));
std::snprintf(s,
16,
"%d.%d.%d.%d",
(int)((address >> 24) & 0xFF),
(int)((address >> 16) & 0xFF),
(int)((address >> 8) & 0xFF),
(int)(address & 0xFF));
}
}

void IpEndpointName::AddressAndPortAsString(char* s) const {
if (port == ANY_PORT) {
if (address == ANY_ADDRESS) {
// std::sprintf(s, "<any>:<any>");
std::snprintf(s, 16, "<any>:<any>");
} else {
// std::sprintf(s,
// "%d.%d.%d.%d:<any>",
// (int)((address >> 24) & 0xFF),
// (int)((address >> 16) & 0xFF),
// (int)((address >> 8) & 0xFF),
// (int)(address & 0xFF));
std::snprintf(s,
16,
"%d.%d.%d.%d:<any>",

Check warning on line 82 in src/osc/ip/IpEndpointName.cpp

View workflow job for this annotation

GitHub Actions / Ubuntu 22.04

‘:<any>’ directive output may be truncated writing 6 bytes into a region of size between 1 and 9 [-Wformat-truncation=]
(int)((address >> 24) & 0xFF),
(int)((address >> 16) & 0xFF),
(int)((address >> 8) & 0xFF),
(int)(address & 0xFF));
}
} else {
if (address == ANY_ADDRESS) {
// std::sprintf(s, "<any>:%d", port);
std::snprintf(s, 16, "<any>:%d", port);
} else {
// std::sprintf(s,
// "%d.%d.%d.%d:%d",
// (int)((address >> 24) & 0xFF),
// (int)((address >> 16) & 0xFF),
// (int)((address >> 8) & 0xFF),
// (int)(address & 0xFF),
// (int)port);
std::snprintf(s,
16,
"%d.%d.%d.%d:%d",

Check warning on line 102 in src/osc/ip/IpEndpointName.cpp

View workflow job for this annotation

GitHub Actions / Ubuntu 22.04

‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size between 0 and 8 [-Wformat-truncation=]
(int)((address >> 24) & 0xFF),
(int)((address >> 16) & 0xFF),
(int)((address >> 8) & 0xFF),
(int)(address & 0xFF),
(int)port);
}
}
}
91 changes: 91 additions & 0 deletions src/osc/ip/IpEndpointName.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
oscpack -- Open Sound Control (OSC) packet manipulation library
http://www.rossbencina.com/code/oscpack

Copyright (c) 2004-2013 Ross Bencina <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

/*
The text above constitutes the entire oscpack license; however,
the oscpack developer(s) also make the following non-binding requests:

Any person wishing to distribute modifications to the Software is
requested to send the modifications to the original developer so that
they can be incorporated into the canonical version. It is also
requested that these non-binding requests be included whenever the
above license is reproduced.
*/
#ifndef INCLUDED_OSCPACK_IPENDPOINTNAME_H
#define INCLUDED_OSCPACK_IPENDPOINTNAME_H

class IpEndpointName {
static unsigned long GetHostByName(const char* s);

public:
static const unsigned long ANY_ADDRESS = 0xFFFFFFFF;
static const int ANY_PORT = -1;

IpEndpointName()
: address(ANY_ADDRESS),
port(ANY_PORT) {
}
IpEndpointName(int port_)
: address(ANY_ADDRESS),
port(port_) {
}
IpEndpointName(unsigned long ipAddress_, int port_)
: address(ipAddress_),
port(port_) {
}
IpEndpointName(const char* addressName, int port_ = ANY_PORT)
: address(GetHostByName(addressName)),
port(port_) {
}
IpEndpointName(int addressA, int addressB, int addressC, int addressD, int port_ = ANY_PORT)
: address(((addressA << 24) | (addressB << 16) | (addressC << 8) | addressD)),
port(port_) {
}

// address and port are maintained in host byte order here
unsigned long address;
int port;

bool IsMulticastAddress() const {
return ((address >> 24) & 0xFF) >= 224 && ((address >> 24) & 0xFF) <= 239;
}

enum { ADDRESS_STRING_LENGTH = 17 };
void AddressAsString(char* s) const;

enum { ADDRESS_AND_PORT_STRING_LENGTH = 23 };
void AddressAndPortAsString(char* s) const;
};

inline bool operator==(const IpEndpointName& lhs, const IpEndpointName& rhs) {
return (lhs.address == rhs.address && lhs.port == rhs.port);
}

inline bool operator!=(const IpEndpointName& lhs, const IpEndpointName& rhs) {
return !(lhs == rhs);
}

#endif /* INCLUDED_OSCPACK_IPENDPOINTNAME_H */
Loading
Loading