Skip to content

Commit

Permalink
Avoid spurious sets of isModified in mixer
Browse files Browse the repository at this point in the history
  • Loading branch information
cme committed May 11, 2024
1 parent 235de1d commit 44dcf4c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 22 deletions.
41 changes: 28 additions & 13 deletions src/gui/src/Mixer/Mixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,20 +232,26 @@ void Mixer::muteClicked(ComponentMixerLine* ref)
bool isMuteClicked = ref->isMuteClicked();

auto pCompo = pSong->getDrumkit()->getComponent( ref->getComponentID() );

pCompo->set_muted( isMuteClicked );
Hydrogen::get_instance()->setIsModified( true );
if ( isMuteClicked != pCompo->is_muted() ) {
pCompo->set_muted( isMuteClicked );
Hydrogen::get_instance()->setIsModified( true );
}
}

void Mixer::soloClicked(ComponentMixerLine* ref)
{
auto pSong = Hydrogen::get_instance()->getSong();
bool isSoloClicked = ref->isSoloClicked();
int nLine = findCompoMixerLineByRef(ref);

ComponentMixerLine* pComponentMixerLine = m_pComponentMixerLine[nLine];

pComponentMixerLine->setSoloClicked( isSoloClicked );
Hydrogen::get_instance()->setIsModified( true );
auto pCompo = pSong->getDrumkit()->getComponent( ref->getComponentID() );

if ( isSoloClicked != pCompo->is_soloed() ) {
pCompo->set_soloed( isSoloClicked );
pComponentMixerLine->setSoloClicked( isSoloClicked );
Hydrogen::get_instance()->setIsModified( true );
}
}

void Mixer::volumeChanged(ComponentMixerLine* ref)
Expand All @@ -255,8 +261,10 @@ void Mixer::volumeChanged(ComponentMixerLine* ref)

auto pCompo = pSong->getDrumkit()->getComponent( ref->getComponentID() );

pCompo->set_volume( newVolume );
Hydrogen::get_instance()->setIsModified( true );
if ( newVolume != pCompo->get_volume() ) {
pCompo->set_volume( newVolume );
Hydrogen::get_instance()->setIsModified( true );
}
}

void Mixer::soloClicked(MixerLine* ref)
Expand Down Expand Up @@ -737,9 +745,14 @@ void Mixer::knobChanged(MixerLine* ref, int nKnob) {
ERRORLOG( "No instrument selected" );
return;
}
float fLevel = ref->getFXLevel(nKnob);

if ( pSelectedInstrument->get_fx_level( nKnob) != fLevel ) {
pSelectedInstrument->set_fx_level( fLevel, nKnob );

pHydrogen->setIsModified( true );
}

pSelectedInstrument->set_fx_level( ref->getFXLevel(nKnob), nKnob );

QString sMessage = tr( "Set FX %1 level [%2] of instrument" )
.arg( nKnob )
.arg( ref->getFXLevel(nKnob), 0, 'f', 2 );
Expand All @@ -751,7 +764,6 @@ void Mixer::knobChanged(MixerLine* ref, int nKnob) {
( HydrogenApp::get_instance() )->
showStatusBarMessage( sMessage, sCaller );

pHydrogen->setIsModified( true );
}


Expand Down Expand Up @@ -847,7 +859,11 @@ void Mixer::ladspaVolumeChanged( LadspaFXMixerLine* ref)
if (ref == m_pLadspaFXLine[ nFX ] ) {
LadspaFX *pFX = Effects::get_instance()->getLadspaFX(nFX);
if ( pFX != nullptr ) {
pFX->setVolume( ref->getVolume() );
float fVolume = ref->getVolume();
if ( pFX->getVolume() != fVolume ) {
pFX->setVolume( fVolume );
Hydrogen::get_instance()->setIsModified( true );
}

QString sMessage = tr( "Set volume [%1] of FX" )
.arg( ref->getVolume(), 0, 'f', 2 );
Expand All @@ -858,7 +874,6 @@ void Mixer::ladspaVolumeChanged( LadspaFXMixerLine* ref)
HydrogenApp::get_instance()->
showStatusBarMessage( sMessage, sCaller );

Hydrogen::get_instance()->setIsModified( true );
}
}
}
Expand Down
10 changes: 2 additions & 8 deletions src/gui/src/Mixer/MixerLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,20 +201,17 @@ void MixerLine::updateMixerLine()
}

void MixerLine::muteBtnClicked() {
Hydrogen::get_instance()->setIsModified( true );
emit muteBtnClicked(this);
}

void MixerLine::soloBtnClicked() {
Hydrogen::get_instance()->setIsModified( true );
emit soloBtnClicked(this);
}

void MixerLine::faderChanged( WidgetWithInput *pRef ) {

assert( pRef );

Hydrogen::get_instance()->setIsModified( true );

emit volumeChanged(this);

WidgetWithInput* pFader = static_cast<Fader*>( pRef );
Expand Down Expand Up @@ -495,8 +492,7 @@ void ComponentMixerLine::soloBtnClicked() {
void ComponentMixerLine::faderChanged( WidgetWithInput *pRef ) {

assert( pRef );

Hydrogen::get_instance()->setIsModified( true );

emit volumeChanged(this);

WidgetWithInput* pFader = static_cast<Fader*>( pRef );
Expand Down Expand Up @@ -684,8 +680,6 @@ void MasterMixerLine::faderChanged( WidgetWithInput *pRef )

emit volumeChanged(this);

Hydrogen::get_instance()->setIsModified( true );

double value = (double) pFader->getValue();
( HydrogenApp::get_instance() )->
showStatusBarMessage( tr( "Set master volume [%1]" )
Expand Down
2 changes: 1 addition & 1 deletion src/gui/src/Mixer/MixerLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class MixerLine: public PixmapWidget, public H2Core::Object<MixerLine>
void setSoloClicked(bool isClicked);

float getVolume();
void setVolume(float value);
void setVolume( float value );

void setPeak_L( float peak );
float getPeak_L();
Expand Down

0 comments on commit 44dcf4c

Please sign in to comment.