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.
  • Loading branch information
dakhubgit committed Feb 2, 2021
1 parent 44539de commit 0e26069
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/audiomixerboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
3 changes: 3 additions & 0 deletions src/audiomixerboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down
16 changes: 16 additions & 0 deletions src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Up @@ -485,6 +485,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 );

Expand Down
4 changes: 4 additions & 0 deletions src/clientdlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,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 );

Expand Down
8 changes: 8 additions & 0 deletions src/soundbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,15 @@ 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;
}
Expand Down
1 change: 1 addition & 0 deletions src/soundbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,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 0e26069

Please sign in to comment.