bug fix: grouping faders in the client should be proportional (see discussion in #202)

This commit is contained in:
Volker Fischer 2020-06-30 21:37:36 +02:00
parent 51e8399ece
commit eaf9a1ad0e
3 changed files with 75 additions and 57 deletions

View file

@ -2,16 +2,18 @@
3.5.8git 3.5.8git
TODO bug fix: incorrect selection of UI language (#408) - bug fix: grouping faders in the client should be proportional (see discussion in #202)
TODO bug fix: incorrect selection of UI language (#408) !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
TODO improve settings management -> move settings class in client/server classes, move actual settings variables TODO improve settings management -> move settings class in client/server classes, move actual settings variables
TODO add new register message which contains version and, e.g., max number of clients TODO add new register message which contains version and, e.g., max number of clients
TODO bug fix: grouping faders in the client should be proportional (see discussion in #202)
TODO https://github.com/corrados/jamulus/issues/341#issuecomment-647172946 TODO https://github.com/corrados/jamulus/issues/341#issuecomment-647172946
- generate .qm on compile time with lrelease - generate .qm on compile time with lrelease

View file

@ -313,7 +313,7 @@ void CChannelFader::Reset()
// init gain and pan value -> maximum value as definition according to server // init gain and pan value -> maximum value as definition according to server
pFader->setValue ( AUD_MIX_FADER_MAX ); pFader->setValue ( AUD_MIX_FADER_MAX );
iPreviousFaderLevel = AUD_MIX_FADER_MAX; dPreviousFaderLevel = AUD_MIX_FADER_MAX;
pPan->setValue ( AUD_MIX_PAN_MAX / 2 ); pPan->setValue ( AUD_MIX_PAN_MAX / 2 );
// reset mute/solo/group check boxes and level meter // reset mute/solo/group check boxes and level meter
@ -343,20 +343,20 @@ void CChannelFader::Reset()
bIsMyOwnFader = false; bIsMyOwnFader = false;
} }
void CChannelFader::SetFaderLevel ( const int iLevel, void CChannelFader::SetFaderLevel ( const double dLevel,
const bool bIsGroupUpdate ) const bool bIsGroupUpdate )
{ {
// first make a range check // first make a range check
if ( ( iLevel >= 0 ) && ( iLevel <= AUD_MIX_FADER_MAX ) ) if ( ( dLevel >= 0 ) && ( dLevel <= AUD_MIX_FADER_MAX ) )
{ {
// we set the new fader level in the GUI (slider control) and also tell the // we set the new fader level in the GUI (slider control) and also tell the
// server about the change (block the signal of the fader since we want to // server about the change (block the signal of the fader since we want to
// call SendFaderLevelToServer with a special additional parameter) // call SendFaderLevelToServer with a special additional parameter)
pFader->blockSignals ( true ); pFader->blockSignals ( true );
pFader->setValue ( iLevel ); pFader->setValue ( MathUtils::round ( dLevel ) );
pFader->blockSignals ( false ); pFader->blockSignals ( false );
SendFaderLevelToServer ( iLevel, bIsGroupUpdate ); SendFaderLevelToServer ( dLevel, bIsGroupUpdate );
} }
} }
@ -401,23 +401,26 @@ void CChannelFader::SetRemoteFaderIsMute ( const bool bIsMute )
} }
} }
void CChannelFader::SendFaderLevelToServer ( const int iLevel, void CChannelFader::SendFaderLevelToServer ( const double dLevel,
const bool bIsGroupUpdate ) const bool bIsGroupUpdate )
{ {
// if mute flag is set or other channel is on solo, do not apply the new // if mute flag is set or other channel is on solo, do not apply the new
// fader value (exception: we are on solo, in that case we ignore the // fader value to the server (exception: we are on solo, in that case we
// "other channel is on solo" flag) // ignore the "other channel is on solo" flag)
if ( ( pcbMute->checkState() == Qt::Unchecked ) && const bool bSuppressServerUpdate = !( ( pcbMute->checkState() == Qt::Unchecked ) &&
( !bOtherChannelIsSolo || IsSolo() ) ) ( !bOtherChannelIsSolo || IsSolo() ) );
{
// emit signal for new fader gain value // emit signal for new fader gain value
emit gainValueChanged ( CalcFaderGain ( iLevel ), emit gainValueChanged ( CalcFaderGain ( dLevel ),
bIsMyOwnFader, bIsMyOwnFader,
bIsGroupUpdate, bIsGroupUpdate,
iLevel - iPreviousFaderLevel ); bSuppressServerUpdate,
dLevel / dPreviousFaderLevel );
// update previous fader level since the level has changed // update previous fader level since the level has changed
iPreviousFaderLevel = iLevel; if ( dLevel > 0 )
{
dPreviousFaderLevel = dLevel;
} }
} }
@ -437,7 +440,7 @@ void CChannelFader::SetMute ( const bool bState )
if ( bState ) if ( bState )
{ {
// mute channel -> send gain of 0 // mute channel -> send gain of 0
emit gainValueChanged ( 0, bIsMyOwnFader, false, 0 ); emit gainValueChanged ( 0, bIsMyOwnFader, false, false, -1 );
} }
else else
{ {
@ -445,13 +448,13 @@ void CChannelFader::SetMute ( const bool bState )
if ( !bOtherChannelIsSolo || IsSolo() ) if ( !bOtherChannelIsSolo || IsSolo() )
{ {
// mute was unchecked, get current fader value and apply // mute was unchecked, get current fader value and apply
emit gainValueChanged ( CalcFaderGain ( GetFaderLevel() ), bIsMyOwnFader, false, 0 ); emit gainValueChanged ( CalcFaderGain ( GetFaderLevel() ), bIsMyOwnFader, false, false, -1 );
// TODO When mute or solo is activated, the group synchronization does not work anymore. // TODO When mute or solo is activated, the group synchronization does not work anymore.
// To get a smoother experience, we adjust the previous level as soon as the mute is // To get a smoother experience, we adjust the previous level as soon as the mute is
// again set to off (if we would not do that, on the next move of the fader the other // again set to off (if we would not do that, on the next move of the fader the other
// faders in the group would jump which is very bad). // faders in the group would jump which is very bad).
iPreviousFaderLevel = GetFaderLevel(); dPreviousFaderLevel = GetFaderLevel();
} }
} }
} }
@ -624,14 +627,14 @@ void CChannelFader::SetChannelInfos ( const CChannelInfo& cChanInfo )
plblLabel->setToolTip ( strToolTip ); plblLabel->setToolTip ( strToolTip );
} }
double CChannelFader::CalcFaderGain ( const int value ) double CChannelFader::CalcFaderGain ( const double dValue )
{ {
// convert actual slider range in gain values // convert actual slider range in gain values
// and normalize so that maximum gain is 1 // and normalize so that maximum gain is 1
const double dInValueRange0_1 = static_cast<double> ( value ) / AUD_MIX_FADER_MAX; const double dInValueRange0_1 = dValue / AUD_MIX_FADER_MAX;
// map range from 0..1 to range -35..0 dB and calculate linear gain // map range from 0..1 to range -35..0 dB and calculate linear gain
if ( value == 0 ) if ( dValue == 0 )
{ {
return 0; // -infinity return 0; // -infinity
} }
@ -718,7 +721,7 @@ inline void CAudioMixerBoard::connectFaderSignalsToMixerBoardSlots()
{ {
int iCurChanID = slotId - 1; int iCurChanID = slotId - 1;
void ( CAudioMixerBoard::* pGainValueChanged )( double, bool, bool, int ) = void ( CAudioMixerBoard::* pGainValueChanged )( double, bool, bool, bool, double ) =
&CAudioMixerBoardSlots<slotId>::OnChGainValueChanged; &CAudioMixerBoardSlots<slotId>::OnChGainValueChanged;
void ( CAudioMixerBoard::* pPanValueChanged )( double ) = void ( CAudioMixerBoard::* pPanValueChanged )( double ) =
@ -940,8 +943,8 @@ void CAudioMixerBoard::ApplyNewConClientList ( CVector<CChannelInfo>& vecChanInf
( iNewClientFaderLevel != 100 ) ) ( iNewClientFaderLevel != 100 ) )
{ {
// the value is in percent -> convert range // the value is in percent -> convert range
vecpChanFader[i]->SetFaderLevel ( static_cast<int> ( vecpChanFader[i]->SetFaderLevel (
iNewClientFaderLevel / 100.0 * AUD_MIX_FADER_MAX ) ); iNewClientFaderLevel / 100.0 * AUD_MIX_FADER_MAX );
} }
} }
@ -1051,10 +1054,14 @@ void CAudioMixerBoard::UpdateGainValue ( const int iChannelIdx,
const double dValue, const double dValue,
const bool bIsMyOwnFader, const bool bIsMyOwnFader,
const bool bIsGroupUpdate, const bool bIsGroupUpdate,
const int iDiffLevel ) const bool bSuppressServerUpdate,
const double dLevelRatio )
{ {
// update current gain // update current gain
if ( !bSuppressServerUpdate )
{
emit ChangeChanGain ( iChannelIdx, dValue, bIsMyOwnFader ); emit ChangeChanGain ( iChannelIdx, dValue, bIsMyOwnFader );
}
// if this fader is selected, all other in the group must be updated as // if this fader is selected, all other in the group must be updated as
// well (note that we do not have to update if this is already a group update // well (note that we do not have to update if this is already a group update
@ -1064,11 +1071,14 @@ void CAudioMixerBoard::UpdateGainValue ( const int iChannelIdx,
for ( int i = 0; i < MAX_NUM_CHANNELS; i++ ) for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
{ {
// update rest of faders selected // update rest of faders selected
if ( vecpChanFader[i]->IsVisible() && vecpChanFader[i]->IsSelect() && ( i != iChannelIdx ) ) if ( vecpChanFader[i]->IsVisible() &&
vecpChanFader[i]->IsSelect() &&
( i != iChannelIdx ) &&
( dLevelRatio >= 0 ) )
{ {
// synchronize faders with moving fader level (it is important // synchronize faders with moving fader level (it is important
// to set the group flag to avoid infinite looping) // to set the group flag to avoid infinite looping)
vecpChanFader[i]->SetFaderLevel ( vecpChanFader[i]->GetFaderLevel() + iDiffLevel, true ); vecpChanFader[i]->SetFaderLevel ( vecpChanFader[i]->GetPreviousFaderLevel() * dLevelRatio, true );
} }
} }
} }
@ -1165,7 +1175,7 @@ void CAudioMixerBoard::SetChannelLevels ( const CVector<uint16_t>& vecChannelLev
for ( int iChId = 0; iChId < MAX_NUM_CHANNELS; iChId++ ) for ( int iChId = 0; iChId < MAX_NUM_CHANNELS; iChId++ )
{ {
if ( vecpChanFader[iChId]->IsVisible() && i < iNumChannelLevels ) if ( vecpChanFader[iChId]->IsVisible() && ( i < iNumChannelLevels ) )
{ {
vecpChanFader[iChId]->SetChannelLevel ( vecChannelLevel[i++] ); vecpChanFader[iChId]->SetChannelLevel ( vecChannelLevel[i++] );

View file

@ -69,10 +69,11 @@ public:
void SetFaderIsMute ( const bool bIsMute ); void SetFaderIsMute ( const bool bIsMute );
void SetRemoteFaderIsMute ( const bool bIsMute ); void SetRemoteFaderIsMute ( const bool bIsMute );
void SetFaderIsSelect ( const bool bIsMute ); void SetFaderIsSelect ( const bool bIsMute );
void SetFaderLevel ( const int iLevel, void SetFaderLevel ( const double dLevel,
const bool bIsGroupUpdate = false ); const bool bIsGroupUpdate = false );
int GetFaderLevel() { return pFader->value(); } int GetFaderLevel() { return pFader->value(); }
double GetPreviousFaderLevel() { return dPreviousFaderLevel; }
int GetPanValue() { return pPan->value(); } int GetPanValue() { return pPan->value(); }
void Reset(); void Reset();
void SetChannelLevel ( const uint16_t iLevel ); void SetChannelLevel ( const uint16_t iLevel );
@ -80,11 +81,11 @@ public:
void UpdateSoloState ( const bool bNewOtherSoloState ); void UpdateSoloState ( const bool bNewOtherSoloState );
protected: protected:
double CalcFaderGain ( const int value ); double CalcFaderGain ( const double dValue );
void SetMute ( const bool bState ); void SetMute ( const bool bState );
void SetupFaderTag ( const ESkillLevel eSkillLevel ); void SetupFaderTag ( const ESkillLevel eSkillLevel );
void SendPanValueToServer ( const int iPan ); void SendPanValueToServer ( const int iPan );
void SendFaderLevelToServer ( const int iLevel, void SendFaderLevelToServer ( const double dLevel,
const bool bIsGroupUpdate ); const bool bIsGroupUpdate );
QFrame* pFrame; QFrame* pFrame;
@ -112,7 +113,7 @@ protected:
bool bOtherChannelIsSolo; bool bOtherChannelIsSolo;
bool bIsMyOwnFader; bool bIsMyOwnFader;
int iPreviousFaderLevel; double dPreviousFaderLevel;
public slots: public slots:
void OnLevelValueChanged ( int value ) { SendFaderLevelToServer ( value, false ); } void OnLevelValueChanged ( int value ) { SendFaderLevelToServer ( value, false ); }
@ -123,7 +124,8 @@ signals:
void gainValueChanged ( double value, void gainValueChanged ( double value,
bool bIsMyOwnFader, bool bIsMyOwnFader,
bool bIsGroupUpdate, bool bIsGroupUpdate,
int iDiffLevel ); bool bSuppressServerUpdate,
double dLevelRatio );
void panValueChanged ( double value ); void panValueChanged ( double value );
void soloStateChanged ( int value ); void soloStateChanged ( int value );
@ -136,11 +138,13 @@ public:
void OnChGainValueChanged ( double dValue, void OnChGainValueChanged ( double dValue,
bool bIsMyOwnFader, bool bIsMyOwnFader,
bool bIsGroupUpdate, bool bIsGroupUpdate,
int iDiffLevel ) { UpdateGainValue ( slotId - 1, bool bSuppressServerUpdate,
double dLevelRatio ) { UpdateGainValue ( slotId - 1,
dValue, dValue,
bIsMyOwnFader, bIsMyOwnFader,
bIsGroupUpdate, bIsGroupUpdate,
iDiffLevel ); } bSuppressServerUpdate,
dLevelRatio ); }
void OnChPanValueChanged ( double dValue ) { UpdatePanValue ( slotId - 1, dValue ); } void OnChPanValueChanged ( double dValue ) { UpdatePanValue ( slotId - 1, dValue ); }
@ -149,7 +153,8 @@ protected:
const double dValue, const double dValue,
const bool bIsMyOwnFader, const bool bIsMyOwnFader,
const bool bIsGroupUpdate, const bool bIsGroupUpdate,
const int iDiffLevel ) = 0; const bool bSuppressServerUpdate,
const double dLevelRatio ) = 0;
virtual void UpdatePanValue ( const int iChannelIdx, virtual void UpdatePanValue ( const int iChannelIdx,
const double dValue ) = 0; const double dValue ) = 0;
@ -244,7 +249,8 @@ protected:
const double dValue, const double dValue,
const bool bIsMyOwnFader, const bool bIsMyOwnFader,
const bool bIsGroupUpdate, const bool bIsGroupUpdate,
const int iDiffLevel ); const bool bSuppressServerUpdate,
const double dLevelRatio );
virtual void UpdatePanValue ( const int iChannelIdx, virtual void UpdatePanValue ( const int iChannelIdx,
const double dValue ); const double dValue );