From 084dca96f6bc1a5bcf89d9a3e2c05acf4d19b6c3 Mon Sep 17 00:00:00 2001 From: probonopd Date: Sat, 9 Nov 2024 11:40:08 +0100 Subject: [PATCH] Add initial mdns responder for rtp-midi aka applemidi (#749) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Ömer Şiar Baysal --- src/minidexed.cpp | 19 +++++++++++++------ src/minidexed.h | 1 + src/rtpmididevice.cpp | 14 ++++---------- src/rtpmididevice.h | 22 +--------------------- 4 files changed, 19 insertions(+), 37 deletions(-) diff --git a/src/minidexed.cpp b/src/minidexed.cpp index a1a12d5..c210536 100644 --- a/src/minidexed.cpp +++ b/src/minidexed.cpp @@ -2197,7 +2197,8 @@ void CMiniDexed::UpdateNetwork() CString IPString; m_pNet->GetConfig()->GetIPAddress()->Format(&IPString); - LOGNOTE("Network up and running at: %s", static_cast(IPString)); + //LOGNOTE("Network up and running at: %s", static_cast(IPString)); + m_UDPMIDI.Initialize(); @@ -2214,11 +2215,17 @@ void CMiniDexed::UpdateNetwork() LOGNOTE("FTP daemon initialized"); } - m_UI.DisplayWrite ("IP", - "Network", - IPString, - 0, - 1); + m_UI.DisplayWrite ("IP", "Network", IPString, 0, 1); + + CmDNSPublisher *pmDNSPublisher = new CmDNSPublisher (m_pNet); + assert (pmDNSPublisher); + static const char ServiceName[] = "minidexed-rtpmidi"; + static const char *ppText[] = {"RTP-MIDI Receiver", nullptr}; // TXT record strings + if (!pmDNSPublisher->PublishService (ServiceName, CmDNSPublisher::ServiceTypeAppleMIDI, + 5004, ppText)) + { + LOGPANIC ("Cannot publish mdns service"); + } } else if (m_bNetworkReady && !bNetIsRunning) { diff --git a/src/minidexed.h b/src/minidexed.h index 2d73e74..8466eb0 100644 --- a/src/minidexed.h +++ b/src/minidexed.h @@ -43,6 +43,7 @@ #include #include #include +#include #include #include "common.h" #include "effect_mixer.hpp" diff --git a/src/rtpmididevice.cpp b/src/rtpmididevice.cpp index 2c29a94..572a5c9 100644 --- a/src/rtpmididevice.cpp +++ b/src/rtpmididevice.cpp @@ -26,24 +26,21 @@ #include "rtpmididevice.h" #include +#define VIRTUALCABLE 24 + LOGMODULE("rtpmididevice"); CRTPMIDIDevice::CRTPMIDIDevice (CMiniDexed *pSynthesizer, CConfig *pConfig, CUserInterface *pUI) : CMIDIDevice (pSynthesizer, pConfig, pUI), m_pConfig (pConfig) - - //m_Serial (pInterrupt, TRUE), - //m_nSerialState (0), - //m_nSysEx (0), - //m_SendBuffer (&m_Serial) { AddDevice ("rtpdummy"); } CRTPMIDIDevice::~CRTPMIDIDevice (void) { - //m_nSerialState = 255; + } boolean CRTPMIDIDevice::Initialize (void) @@ -63,10 +60,7 @@ boolean CRTPMIDIDevice::Initialize (void) void CRTPMIDIDevice::OnAppleMIDIDataReceived(const u8* pData, size_t nSize) { - LOGNOTE("Recieved RTP MIDI Data"); - printf ("MIDI-RTP: %02X %02X\n", - (unsigned) pData[0], (unsigned) pData[1]); - MIDIMessageHandler(pData, nSize); + MIDIMessageHandler(pData, nSize, VIRTUALCABLE); } void CRTPMIDIDevice::OnAppleMIDIConnect(const CIPAddress* pIPAddress, const char* pName) diff --git a/src/rtpmididevice.h b/src/rtpmididevice.h index 418fcde..870301b 100644 --- a/src/rtpmididevice.h +++ b/src/rtpmididevice.h @@ -27,11 +27,6 @@ #include "config.h" #include "net/applemidi.h" -#include -#include -#include -#include - class CMiniDexed; class CRTPMIDIDevice : CAppleMIDIHandler, CMIDIDevice @@ -44,26 +39,11 @@ public: virtual void OnAppleMIDIDataReceived(const u8* pData, size_t nSize) override; virtual void OnAppleMIDIConnect(const CIPAddress* pIPAddress, const char* pName) override; virtual void OnAppleMIDIDisconnect(const CIPAddress* pIPAddress, const char* pName) override; - //void OnAppleMIDIDataReceived(const u8* pData, size_t nSize); - //void OnAppleMIDIConnect(const CIPAddress* pIPAddress, const char* pName); - //void OnAppleMIDIDisconnect(const CIPAddress* pIPAddress, const char* pName); - - //void Process (void); - - //void Send (const u8 *pMessage, size_t nLength, unsigned nCable = 0) override; private: CConfig *m_pConfig; - - //CSerialDevice m_Serial; - //unsigned m_nSerialState; - //unsigned m_nSysEx; - //u8 m_SerialMessage[MAX_MIDI_MESSAGE]; - - //CWriteBufferDevice m_SendBuffer; CBcmRandomNumberGenerator m_Random; - //CAppleMIDIHandler* m_MIDIHandler; - CAppleMIDIParticipant* m_pAppleMIDIParticipant; // AppleMIDI participant instance + CAppleMIDIParticipant* m_pAppleMIDIParticipant; }; #endif