Midi sustain working when envelope is on (#3730)

* midi sustain working when envelope is on

* pressing sustain pedal again doesn't pause release

[cherry-picked from master]
This commit is contained in:
Andrés
2017-08-02 02:20:09 -03:00
committed by Oskar Wallgren
parent 2e841e4917
commit 31126b0aa4
3 changed files with 13 additions and 2 deletions

View File

@@ -156,6 +156,11 @@ public:
return m_released;
}
bool isReleaseStarted() const
{
return m_releaseStarted;
}
/*! Returns total numbers of frames played so far */
f_cnt_t totalFramesPlayed() const
{
@@ -297,6 +302,7 @@ private:
// release of note
NotePlayHandleList m_subNotes; // used for chords and arpeggios
volatile bool m_released; // indicates whether note is released
bool m_releaseStarted;
bool m_hasParent; // indicates whether note has parent
NotePlayHandle * m_parent; // parent note
bool m_hadChildren;

View File

@@ -137,7 +137,8 @@ void InstrumentSoundShaping::processAudioBuffer( sampleFrame* buffer,
const f_cnt_t envTotalFrames = n->totalFramesPlayed();
f_cnt_t envReleaseBegin = envTotalFrames - n->releaseFramesDone() + n->framesBeforeRelease();
if( n->isReleased() == false )
if( !n->isReleased() || ( n->instrumentTrack()->isSustainPedalPressed() &&
!n->isReleaseStarted() ) )
{
envReleaseBegin += frames;
}

View File

@@ -62,6 +62,7 @@ NotePlayHandle::NotePlayHandle( InstrumentTrack* instrumentTrack,
m_releaseFramesDone( 0 ),
m_subNotes(),
m_released( false ),
m_releaseStarted( false ),
m_hasParent( parent != NULL ),
m_parent( parent ),
m_hadChildren( false ),
@@ -248,8 +249,11 @@ void NotePlayHandle::play( sampleFrame * _working_buffer )
m_instrumentTrack->playNote( this, _working_buffer );
}
if( m_released )
if( m_released && (!instrumentTrack()->isSustainPedalPressed() ||
m_releaseStarted) )
{
m_releaseStarted = true;
f_cnt_t todo = framesThisPeriod;
// if this note is base-note for arpeggio, always set