From 6a6e8f2d75fdae180a470ae0d46210985e5c29a5 Mon Sep 17 00:00:00 2001 From: henkdegroot <13550012+henkdegroot@users.noreply.github.com> Date: Sun, 13 Feb 2022 22:00:41 +0100 Subject: [PATCH] Add MIDI control for inputfader using i --- src/client.cpp | 14 ++++++++++++++ src/client.h | 2 ++ src/clientdlg.cpp | 2 ++ src/clientdlg.h | 2 ++ src/soundbase.cpp | 9 +++++++++ src/soundbase.h | 2 ++ 6 files changed, 31 insertions(+) diff --git a/src/client.cpp b/src/client.cpp index 203b1a0f36..32351a119c 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -166,6 +166,8 @@ CClient::CClient ( const quint16 iPortNumber, QObject::connect ( &Sound, &CSound::ControllerInMuteMyself, this, &CClient::OnControllerInMuteMyself ); + QObject::connect ( &Sound, &CSound::ControllerInInputPanValue, this, &CClient::OnControllerInInputPanValue ); + QObject::connect ( &Socket, &CHighPrioSocket::InvalidPacketReceived, this, &CClient::OnInvalidPacketReceived ); QObject::connect ( pSignalHandler, &CSignalHandler::HandledSignal, this, &CClient::OnHandledSignal ); @@ -717,6 +719,18 @@ void CClient::OnControllerInMuteMyself ( bool bMute ) emit ControllerInMuteMyself ( bMute ); } +void CClient::OnControllerInInputPanValue ( int iValue ) +{ + // in case of a headless client the panners cannot be moved so we need + // to send the controller information directly to the server +#ifdef HEADLESS + // FIXME: no idea what to do here. + //SetSliderAudioPan ( static_cast ( iValue ) / AUD_MIX_PAN_MAX ); +#endif + + emit ControllerInInputPanValue ( iValue ); +} + void CClient::OnClientIDReceived ( int iChanID ) { // for headless mode we support to mute our own signal in the personal mix diff --git a/src/client.h b/src/client.h index e7e44da2a9..2fdb9aa125 100644 --- a/src/client.h +++ b/src/client.h @@ -394,6 +394,7 @@ protected slots: void OnControllerInFaderIsSolo ( int iChannelIdx, bool bIsSolo ); void OnControllerInFaderIsMute ( int iChannelIdx, bool bIsMute ); void OnControllerInMuteMyself ( bool bMute ); + void OnControllerInInputPanValue ( int iValue ); void OnClientIDReceived ( int iChanID ); signals: @@ -425,4 +426,5 @@ protected slots: void ControllerInFaderIsSolo ( int iChannelIdx, bool bIsSolo ); void ControllerInFaderIsMute ( int iChannelIdx, bool bIsMute ); void ControllerInMuteMyself ( bool bMute ); + void ControllerInInputPanValue ( int iValue ); }; diff --git a/src/clientdlg.cpp b/src/clientdlg.cpp index 66b343a2d8..30f2a8653b 100644 --- a/src/clientdlg.cpp +++ b/src/clientdlg.cpp @@ -523,6 +523,8 @@ CClientDlg::CClientDlg ( CClient* pNCliP, QObject::connect ( pClient, &CClient::ControllerInMuteMyself, this, &CClientDlg::OnControllerInMuteMyself ); + QObject::connect ( pClient, &CClient::ControllerInInputPanValue, this, &CClientDlg::OnControllerInInputPanValue ); + QObject::connect ( pClient, &CClient::CLChannelLevelListReceived, this, &CClientDlg::OnCLChannelLevelListReceived ); QObject::connect ( pClient, &CClient::VersionAndOSReceived, this, &CClientDlg::OnVersionAndOSReceived ); diff --git a/src/clientdlg.h b/src/clientdlg.h index 2f177f1175..85278b4a2d 100644 --- a/src/clientdlg.h +++ b/src/clientdlg.h @@ -151,6 +151,8 @@ public slots: void OnControllerInMuteMyself ( const bool bMute ) { chbLocalMute->setChecked ( bMute ); } + void OnControllerInInputPanValue ( const int iValue ) { ClientSettingsDlg.OnAudioPanValueChanged ( iValue ); } + void OnVersionAndOSReceived ( COSUtil::EOpSystemType, QString strVersion ); void OnCLVersionAndOSReceived ( CHostAddress, COSUtil::EOpSystemType, QString strVersion ); diff --git a/src/soundbase.cpp b/src/soundbase.cpp index f91375183f..fc6a55b0f3 100644 --- a/src/soundbase.cpp +++ b/src/soundbase.cpp @@ -33,6 +33,7 @@ char const sMidiCtlChar[] = { /* [EMidiCtlType::Solo] = */ 's', /* [EMidiCtlType::Mute] = */ 'm', /* [EMidiCtlType::MuteMyself] = */ 'o', + /* [EMidiCtlType::InputPan] = */ 'i', /* [EMidiCtlType::None] = */ '\0' }; /* Implementation *************************************************************/ @@ -399,6 +400,14 @@ void CSoundBase::ParseMIDIMessage ( const CVector& vMIDIPaketBytes ) emit ControllerInMuteMyself ( iValue >= 0x40 ); } break; + case InputPan: + { + // Pan levels need to be symmetric between 1 and 127 + const int iInputPanValue = static_cast ( static_cast ( qMax ( iValue, 1 ) - 1 ) / 126 * AUD_MIX_PAN_MAX ); + + emit ControllerInInputPanValue ( iInputPanValue ); + } + break; default: break; } diff --git a/src/soundbase.h b/src/soundbase.h index 2249904aec..4ddb0329ce 100644 --- a/src/soundbase.h +++ b/src/soundbase.h @@ -49,6 +49,7 @@ enum EMidiCtlType Solo, Mute, MuteMyself, + InputPan, None }; @@ -173,4 +174,5 @@ class CSoundBase : public QThread void ControllerInFaderIsSolo ( int iChannelIdx, bool bIsSolo ); void ControllerInFaderIsMute ( int iChannelIdx, bool bIsMute ); void ControllerInMuteMyself ( bool bMute ); + void ControllerInInputPanValue ( int iValue ); };