From 4a1417821f0773115ccf78ecc2fa398947d797f0 Mon Sep 17 00:00:00 2001 From: Oskar Wallgren Date: Wed, 29 Jan 2014 02:29:19 +0100 Subject: [PATCH 1/3] Fixed envelope sustain response --- src/core/EnvelopeAndLfoParameters.cpp | 2 +- src/gui/widgets/EnvelopeAndLfoView.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/core/EnvelopeAndLfoParameters.cpp b/src/core/EnvelopeAndLfoParameters.cpp index 77acc30d50..76f6574115 100644 --- a/src/core/EnvelopeAndLfoParameters.cpp +++ b/src/core/EnvelopeAndLfoParameters.cpp @@ -402,7 +402,7 @@ void EnvelopeAndLfoParameters::updateSampleVars() expKnobVal( m_decayModel.value() * m_sustainModel.value() ) ); - m_sustainLevel = 1.0f - m_sustainModel.value(); + m_sustainLevel = m_sustainModel.value(); m_amount = m_amountModel.value(); if( m_amount >= 0 ) { diff --git a/src/gui/widgets/EnvelopeAndLfoView.cpp b/src/gui/widgets/EnvelopeAndLfoView.cpp index c1d06092a1..cda8f9e49e 100644 --- a/src/gui/widgets/EnvelopeAndLfoView.cpp +++ b/src/gui/widgets/EnvelopeAndLfoView.cpp @@ -441,7 +441,7 @@ void EnvelopeAndLfoView::paintEvent( QPaintEvent * ) p.drawLine( x1, y_base - avail_height, x2, y_base - avail_height ); p.fillRect( x1 - 1, y_base - 2 - avail_height, 4, 4, end_points_bg_color ); - p.fillRect( x1, y_base-1-avail_height, 2, 2, end_points_color ); + p.fillRect( x1, y_base - 1 - avail_height, 2, 2, end_points_color ); x1 = x2; x2 = x1 + static_cast( ( m_decayKnob->value() * m_sustainKnob->value() ) * @@ -449,7 +449,7 @@ void EnvelopeAndLfoView::paintEvent( QPaintEvent * ) p.drawLine( x1, y_base-avail_height, x2, static_cast( y_base - avail_height + - m_sustainKnob->value() * avail_height ) ); + ( 1 - m_sustainKnob->value() ) * avail_height ) ); p.fillRect( x1 - 1, y_base - 2 - avail_height, 4, 4, end_points_bg_color ); p.fillRect( x1, y_base - 1 - avail_height, 2, 2, end_points_color ); @@ -457,14 +457,14 @@ void EnvelopeAndLfoView::paintEvent( QPaintEvent * ) x2 = x1 + static_cast( m_releaseKnob->value() * TIME_UNIT_WIDTH ); p.drawLine( x1, static_cast( y_base - avail_height + - m_sustainKnob->value() * + ( 1 - m_sustainKnob->value() ) * avail_height ), x2, y_base ); - p.fillRect( x1-1, static_cast( y_base - avail_height + - m_sustainKnob->value() * + p.fillRect( x1 - 1, static_cast( y_base - avail_height + + ( 1 - m_sustainKnob->value() ) * avail_height ) - 2, 4, 4, end_points_bg_color ); p.fillRect( x1, static_cast( y_base - avail_height + - m_sustainKnob->value() * + ( 1 - m_sustainKnob->value() ) * avail_height ) - 1, 2, 2, end_points_color ); p.fillRect( x2 - 1, y_base - 2, 4, 4, end_points_bg_color ); From ba69e70bdb74b261715f4ad6a4e2560457baec37 Mon Sep 17 00:00:00 2001 From: Oskar Wallgren Date: Thu, 30 Jan 2014 01:01:58 +0100 Subject: [PATCH 2/3] More envelope sustain respon fixes --- src/core/EnvelopeAndLfoParameters.cpp | 18 ++++++++++++++---- src/gui/widgets/EnvelopeAndLfoView.cpp | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/core/EnvelopeAndLfoParameters.cpp b/src/core/EnvelopeAndLfoParameters.cpp index 76f6574115..552b2736e8 100644 --- a/src/core/EnvelopeAndLfoParameters.cpp +++ b/src/core/EnvelopeAndLfoParameters.cpp @@ -331,7 +331,7 @@ void EnvelopeAndLfoParameters::saveSettings( QDomDocument & _doc, m_attackModel.saveSettings( _doc, _parent, "att" ); m_holdModel.saveSettings( _doc, _parent, "hold" ); m_decayModel.saveSettings( _doc, _parent, "dec" ); - m_sustainModel.saveSettings( _doc, _parent, "sus" ); + m_sustainModel.saveSettings( _doc, _parent, "sustain" ); m_releaseModel.saveSettings( _doc, _parent, "rel" ); m_amountModel.saveSettings( _doc, _parent, "amt" ); m_lfoWaveModel.saveSettings( _doc, _parent, "lshp" ); @@ -353,7 +353,7 @@ void EnvelopeAndLfoParameters::loadSettings( const QDomElement & _this ) m_attackModel.loadSettings( _this, "att" ); m_holdModel.loadSettings( _this, "hold" ); m_decayModel.loadSettings( _this, "dec" ); - m_sustainModel.loadSettings( _this, "sus" ); + m_sustainModel.loadSettings( _this, "sustain" ); m_releaseModel.loadSettings( _this, "rel" ); m_amountModel.loadSettings( _this, "amt" ); m_lfoWaveModel.loadSettings( _this, "lshp" ); @@ -364,6 +364,16 @@ void EnvelopeAndLfoParameters::loadSettings( const QDomElement & _this ) m_x100Model.loadSettings( _this, "x100" ); m_controlEnvAmountModel.loadSettings( _this, "ctlenvamt" ); +/* ### TODO: + Old reversed sustain kept for backward compatibility + with 4.15 file format*/ + + if( _this.hasAttribute( "sus" ) ) + { + m_sustainModel.loadSettings( _this, "sus" ); + m_sustainModel.setValue( 1.0 - m_sustainModel.value() ); + } + // ### TODO: /* // Keep compatibility with version 2.1 file format if( _this.hasAttribute( "lfosyncmode" ) ) @@ -400,7 +410,7 @@ void EnvelopeAndLfoParameters::updateSampleVars() const f_cnt_t decay_frames = static_cast( frames_per_env_seg * expKnobVal( m_decayModel.value() * - m_sustainModel.value() ) ); + ( 1 - m_sustainModel.value() ) ) ); m_sustainLevel = m_sustainModel.value(); m_amount = m_amountModel.value(); @@ -452,7 +462,7 @@ void EnvelopeAndLfoParameters::updateSampleVars() } add += hold_frames; - const float dfI = (1.0 / decay_frames)*(m_sustainLevel-1)*m_amount; + const float dfI = ( 1.0 / decay_frames ) * ( m_sustainLevel -1 ) * m_amount; for( f_cnt_t i = 0; i < decay_frames; ++i ) { /* diff --git a/src/gui/widgets/EnvelopeAndLfoView.cpp b/src/gui/widgets/EnvelopeAndLfoView.cpp index cda8f9e49e..8a7ad8d8e1 100644 --- a/src/gui/widgets/EnvelopeAndLfoView.cpp +++ b/src/gui/widgets/EnvelopeAndLfoView.cpp @@ -444,7 +444,7 @@ void EnvelopeAndLfoView::paintEvent( QPaintEvent * ) p.fillRect( x1, y_base - 1 - avail_height, 2, 2, end_points_color ); x1 = x2; x2 = x1 + static_cast( ( m_decayKnob->value() * - m_sustainKnob->value() ) * + ( 1 - m_sustainKnob->value() ) ) * TIME_UNIT_WIDTH ); p.drawLine( x1, y_base-avail_height, x2, static_cast( y_base - From 1e98cb7b586c35eea9c44dab99b88cf21dc40a17 Mon Sep 17 00:00:00 2001 From: Oskar Wallgren Date: Thu, 30 Jan 2014 03:44:37 +0100 Subject: [PATCH 3/3] Envelope graph shooting over target --- src/gui/widgets/EnvelopeAndLfoView.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widgets/EnvelopeAndLfoView.cpp b/src/gui/widgets/EnvelopeAndLfoView.cpp index 8a7ad8d8e1..93422ee561 100644 --- a/src/gui/widgets/EnvelopeAndLfoView.cpp +++ b/src/gui/widgets/EnvelopeAndLfoView.cpp @@ -62,7 +62,7 @@ const int SUSTAIN_KNOB_X = DECAY_KNOB_X+KNOB_X_SPACING; const int RELEASE_KNOB_X = SUSTAIN_KNOB_X+KNOB_X_SPACING; const int AMOUNT_KNOB_X = RELEASE_KNOB_X+KNOB_X_SPACING; -const float TIME_UNIT_WIDTH = 36.0; +const float TIME_UNIT_WIDTH = 35.0; const int LFO_GRAPH_X = 6;