Skip to content

Commit

Permalink
Panning via MIDI controller
Browse files Browse the repository at this point in the history
This actually implements the --ctrlmidich options for panning with a
MIDI controller for issue jamulussoftware#95.  For example, in native mode a KORG
nanoKONTROL2 can be used with

Jamulus --ctrlmidich '0;f0*8;p16*8'

since its colume faders start at controller 0 and its pan pots start
at controller 16.
dakhubgit committed Feb 14, 2021

Verified

This commit was signed with the committer’s verified signature.
hannojg Hanno J. Gödecke
1 parent 5403207 commit 49edb49
Showing 8 changed files with 52 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/audiomixerboard.cpp
Original file line number Diff line number Diff line change
@@ -1246,6 +1246,20 @@ void CAudioMixerBoard::SetFaderLevel ( const int iChannelIdx,
}
}

void CAudioMixerBoard::SetPanValue ( const int iChannelIdx,
const int iValue )
{
// only apply new pan value if channel index is valid and the panner is visible
if ( ( iChannelIdx >= 0 ) && ( iChannelIdx < MAX_NUM_CHANNELS )
&& bDisplayPans )
{
if ( vecpChanFader[iChannelIdx]->IsVisible() )
{
vecpChanFader[iChannelIdx]->SetPanValue ( iValue );
}
}
}

void CAudioMixerBoard::SetAllFaderLevelsToNewClientLevel()
{
QMutexLocker locker ( &Mutex );
3 changes: 3 additions & 0 deletions src/audiomixerboard.h
Original file line number Diff line number Diff line change
@@ -210,6 +210,9 @@ class CAudioMixerBoard :
void SetFaderLevel ( const int iChannelIdx,
const int iValue );

void SetPanValue ( const int iChannelIdx,
const int iValue );

void SetNumMixerPanelRows ( const int iNNumMixerPanelRows );
int GetNumMixerPanelRows() { return iNumMixerPanelRows; }

16 changes: 16 additions & 0 deletions src/client.cpp
Original file line number Diff line number Diff line change
@@ -184,6 +184,9 @@ CClient::CClient ( const quint16 iPortNumber,
QObject::connect ( &Sound, &CSound::ControllerInFaderLevel,
this, &CClient::OnControllerInFaderLevel );

QObject::connect ( &Sound, &CSound::ControllerInPanValue,
this, &CClient::OnControllerInPanValue );

QObject::connect ( &Socket, &CHighPrioSocket::InvalidPacketReceived,
this, &CClient::OnInvalidPacketReceived );

@@ -707,6 +710,19 @@ void CClient::OnControllerInFaderLevel ( int iChannelIdx,
emit ControllerInFaderLevel ( iChannelIdx, iValue );
}

void CClient::OnControllerInPanValue ( int iChannelIdx,
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
// channel index is valid
SetRemoteChanPan ( iChannelIdx, static_cast<float>( iValue ) / AUD_MIX_PAN_MAX);
#endif

emit ControllerInPanValue ( iChannelIdx, iValue );
}

void CClient::OnClientIDReceived ( int iChanID )
{
// for headless mode we support to mute our own signal in the personal mix
2 changes: 2 additions & 0 deletions src/client.h
Original file line number Diff line number Diff line change
@@ -391,6 +391,7 @@ protected slots:

void OnSndCrdReinitRequest ( int iSndCrdResetType );
void OnControllerInFaderLevel ( int iChannelIdx, int iValue );
void OnControllerInPanValue ( int iChannelIdx, int iValue );
void OnClientIDReceived ( int iChanID );

signals:
@@ -426,4 +427,5 @@ protected slots:
void Disconnected();
void SoundDeviceChanged ( QString strError );
void ControllerInFaderLevel ( int iChannelIdx, int iValue );
void ControllerInPanValue ( int iChannelIdx, int iValue );
};
3 changes: 3 additions & 0 deletions src/clientdlg.cpp
Original file line number Diff line number Diff line change
@@ -487,6 +487,9 @@ CClientDlg::CClientDlg ( CClient* pNCliP,
QObject::connect ( pClient, &CClient::ControllerInFaderLevel,
this, &CClientDlg::OnControllerInFaderLevel );

QObject::connect ( pClient, &CClient::ControllerInPanValue,
this, &CClientDlg::OnControllerInPanValue );

QObject::connect ( pClient, &CClient::CLChannelLevelListReceived,
this, &CClientDlg::OnCLChannelLevelListReceived );

4 changes: 4 additions & 0 deletions src/clientdlg.h
Original file line number Diff line number Diff line change
@@ -143,6 +143,10 @@ public slots:
const int iValue ) { MainMixerBoard->SetFaderLevel ( iChannelIdx,
iValue ); }

void OnControllerInPanValue ( const int iChannelIdx,
const int iValue ) { MainMixerBoard->SetPanValue ( iChannelIdx,
iValue ); }

void OnVersionAndOSReceived ( COSUtil::EOpSystemType ,
QString strVersion );

9 changes: 9 additions & 0 deletions src/soundbase.cpp
Original file line number Diff line number Diff line change
@@ -385,7 +385,16 @@ printf ( "\n" );
emit ControllerInFaderLevel ( cCtrl.iChannel, iFaderLevel );
}
break;
case Pan:
{
// Pan levels need to be symmetric between 1 and 127
const int iPanValue = static_cast<int> (
static_cast<double> (
qMax ( iValue, 1 ) - 1) / 126 * AUD_MIX_PAN_MAX );

emit ControllerInPanValue ( cCtrl.iChannel, iPanValue );
}
break;
default:
break;
}
1 change: 1 addition & 0 deletions src/soundbase.h
Original file line number Diff line number Diff line change
@@ -164,4 +164,5 @@ class CSoundBase : public QThread
signals:
void ReinitRequest ( int iSndCrdResetType );
void ControllerInFaderLevel ( int iChannelIdx, int iValue );
void ControllerInPanValue ( int iChannelIdx, int iValue );
};

0 comments on commit 49edb49

Please sign in to comment.