diff --git a/src/core/InstrumentSoundShaping.cpp b/src/core/InstrumentSoundShaping.cpp index 629cdfa2a..6d2b89df4 100644 --- a/src/core/InstrumentSoundShaping.cpp +++ b/src/core/InstrumentSoundShaping.cpp @@ -315,23 +315,19 @@ f_cnt_t InstrumentSoundShaping::envFrames( const bool _only_vol ) const f_cnt_t InstrumentSoundShaping::releaseFrames() const { - f_cnt_t ret_val = m_envLfoParameters[Volume]->isUsed() ? - m_envLfoParameters[Volume]->releaseFrames() : 0; - if( m_instrumentTrack->instrument() && - m_instrumentTrack->instrument()->desiredReleaseFrames() > ret_val ) + if( m_envLfoParameters[Volume]->isUsed() ) { - ret_val = m_instrumentTrack->instrument()->desiredReleaseFrames(); + return m_envLfoParameters[Volume]->releaseFrames(); } + f_cnt_t ret_val = m_instrumentTrack->instrument() + ? m_instrumentTrack->instrument()->desiredReleaseFrames() + : 0; - if( m_envLfoParameters[Volume]->isUsed() == false ) + for( int i = Volume+1; i < NumTargets; ++i ) { - for( int i = Volume+1; i < NumTargets; ++i ) + if( m_envLfoParameters[i]->isUsed() ) { - if( m_envLfoParameters[i]->isUsed() && - m_envLfoParameters[i]->releaseFrames() > ret_val ) - { - ret_val = m_envLfoParameters[i]->releaseFrames(); - } + ret_val = qMax( ret_val, m_envLfoParameters[i]->releaseFrames() ); } } return ret_val; diff --git a/src/core/Mixer.cpp b/src/core/Mixer.cpp index bd97cf9a2..b882b1b46 100644 --- a/src/core/Mixer.cpp +++ b/src/core/Mixer.cpp @@ -519,14 +519,7 @@ float Mixer::peakValueLeft( sampleFrame * _ab, const f_cnt_t _frames ) float p = 0.0f; for( f_cnt_t f = 0; f < _frames; ++f ) { - if( _ab[f][0] > p ) - { - p = _ab[f][0]; - } - else if( -_ab[f][0] > p ) - { - p = -_ab[f][0]; - } + p = qMax( p, qAbs( _ab[f][0] ) ); } return p; } @@ -539,14 +532,7 @@ float Mixer::peakValueRight( sampleFrame * _ab, const f_cnt_t _frames ) float p = 0.0f; for( f_cnt_t f = 0; f < _frames; ++f ) { - if( _ab[f][1] > p ) - { - p = _ab[f][1]; - } - else if( -_ab[f][1] > p ) - { - p = -_ab[f][1]; - } + p = qMax( p, qAbs( _ab[f][1] ) ); } return p; } diff --git a/src/tracks/pattern.cpp b/src/tracks/pattern.cpp index c6a30f5a5..2e8df8f87 100644 --- a/src/tracks/pattern.cpp +++ b/src/tracks/pattern.cpp @@ -853,27 +853,27 @@ void patternView::wheelEvent( QWheelEvent * _we ) { vol = n->getVolume(); len = n->length(); - } - if( len == 0 && _we->delta() > 0 ) - { - n->setLength( -DefaultTicksPerTact ); - n->setVolume( 5 ); - } - else if( _we->delta() > 0 ) - { - n->setVolume( qMin( 100, vol + 5 ) ); - } - else - { - n->setVolume( qMax( 0, vol - 5 ) ); - } + if( len == 0 && _we->delta() > 0 ) + { + n->setLength( -DefaultTicksPerTact ); + n->setVolume( 5 ); + } + else if( _we->delta() > 0 ) + { + n->setVolume( qMin( 100, vol + 5 ) ); + } + else + { + n->setVolume( qMax( 0, vol - 5 ) ); + } - engine::getSong()->setModified(); - update(); - if( engine::pianoRoll()->currentPattern() == m_pat ) - { - engine::pianoRoll()->update(); + engine::getSong()->setModified(); + update(); + if( engine::pianoRoll()->currentPattern() == m_pat ) + { + engine::pianoRoll()->update(); + } } _we->accept(); }