From dd7fa77950c191004e6cd8d37627d46189a19be2 Mon Sep 17 00:00:00 2001 From: Andres Date: Wed, 26 Jul 2017 02:00:51 -0300 Subject: [PATCH 1/3] midi sustain working when envelope is on --- src/core/InstrumentSoundShaping.cpp | 2 +- src/core/NotePlayHandle.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/InstrumentSoundShaping.cpp b/src/core/InstrumentSoundShaping.cpp index 2a5a71e8635..6aa5582876e 100644 --- a/src/core/InstrumentSoundShaping.cpp +++ b/src/core/InstrumentSoundShaping.cpp @@ -137,7 +137,7 @@ 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() == false || n->instrumentTrack()->isSustainPedalPressed() ) { envReleaseBegin += frames; } diff --git a/src/core/NotePlayHandle.cpp b/src/core/NotePlayHandle.cpp index 8f437eb5a86..723f855076e 100644 --- a/src/core/NotePlayHandle.cpp +++ b/src/core/NotePlayHandle.cpp @@ -248,7 +248,7 @@ void NotePlayHandle::play( sampleFrame * _working_buffer ) m_instrumentTrack->playNote( this, _working_buffer ); } - if( m_released ) + if( m_released && !instrumentTrack()->isSustainPedalPressed() ) { f_cnt_t todo = framesThisPeriod; From df5271d337de1f7b6f9aad69c4673067bd506385 Mon Sep 17 00:00:00 2001 From: Andres Date: Sun, 30 Jul 2017 14:31:16 -0300 Subject: [PATCH 2/3] pressing sustain pedal again doesn't pause release --- include/NotePlayHandle.h | 7 +++++++ src/core/InstrumentSoundShaping.cpp | 3 ++- src/core/NotePlayHandle.cpp | 8 ++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/include/NotePlayHandle.h b/include/NotePlayHandle.h index bf5c266cac0..110a9a618a3 100644 --- a/include/NotePlayHandle.h +++ b/include/NotePlayHandle.h @@ -258,6 +258,11 @@ class EXPORT NotePlayHandle : public PlayHandle, public Note m_frequencyNeedsUpdate = true; } + bool isReleaseStarted() const + { + return m_releaseStarted; + } + private: class BaseDetuning { @@ -319,6 +324,8 @@ class EXPORT NotePlayHandle : public PlayHandle, public Note Origin m_origin; bool m_frequencyNeedsUpdate; // used to update pitch + + bool m_releaseStarted; } ; diff --git a/src/core/InstrumentSoundShaping.cpp b/src/core/InstrumentSoundShaping.cpp index 6aa5582876e..3a41983bd42 100644 --- a/src/core/InstrumentSoundShaping.cpp +++ b/src/core/InstrumentSoundShaping.cpp @@ -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 || n->instrumentTrack()->isSustainPedalPressed() ) + if( n->isReleased() == false || ( n->instrumentTrack()->isSustainPedalPressed() && + !n->isReleaseStarted() ) ) { envReleaseBegin += frames; } diff --git a/src/core/NotePlayHandle.cpp b/src/core/NotePlayHandle.cpp index 723f855076e..612f725227d 100644 --- a/src/core/NotePlayHandle.cpp +++ b/src/core/NotePlayHandle.cpp @@ -75,7 +75,8 @@ NotePlayHandle::NotePlayHandle( InstrumentTrack* instrumentTrack, m_songGlobalParentOffset( 0 ), m_midiChannel( midiEventChannel >= 0 ? midiEventChannel : instrumentTrack->midiPort()->realOutputChannel() ), m_origin( origin ), - m_frequencyNeedsUpdate( false ) + m_frequencyNeedsUpdate( false ), + m_releaseStarted( false ) { lock(); if( hasParent() == false ) @@ -248,8 +249,11 @@ void NotePlayHandle::play( sampleFrame * _working_buffer ) m_instrumentTrack->playNote( this, _working_buffer ); } - if( m_released && !instrumentTrack()->isSustainPedalPressed() ) + 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 From eb0ca345a5be274005d55f366e2fbb2544e230a4 Mon Sep 17 00:00:00 2001 From: Andres Date: Tue, 1 Aug 2017 22:14:57 -0300 Subject: [PATCH 3/3] format changes --- include/NotePlayHandle.h | 13 ++++++------- src/core/InstrumentSoundShaping.cpp | 2 +- src/core/NotePlayHandle.cpp | 4 ++-- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/include/NotePlayHandle.h b/include/NotePlayHandle.h index 110a9a618a3..344980eb61e 100644 --- a/include/NotePlayHandle.h +++ b/include/NotePlayHandle.h @@ -156,6 +156,11 @@ class EXPORT NotePlayHandle : public PlayHandle, public Note return m_released; } + bool isReleaseStarted() const + { + return m_releaseStarted; + } + /*! Returns total numbers of frames played so far */ f_cnt_t totalFramesPlayed() const { @@ -258,11 +263,6 @@ class EXPORT NotePlayHandle : public PlayHandle, public Note m_frequencyNeedsUpdate = true; } - bool isReleaseStarted() const - { - return m_releaseStarted; - } - private: class BaseDetuning { @@ -302,6 +302,7 @@ class EXPORT NotePlayHandle : public PlayHandle, public Note // 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; @@ -324,8 +325,6 @@ class EXPORT NotePlayHandle : public PlayHandle, public Note Origin m_origin; bool m_frequencyNeedsUpdate; // used to update pitch - - bool m_releaseStarted; } ; diff --git a/src/core/InstrumentSoundShaping.cpp b/src/core/InstrumentSoundShaping.cpp index 3a41983bd42..22327ae8eed 100644 --- a/src/core/InstrumentSoundShaping.cpp +++ b/src/core/InstrumentSoundShaping.cpp @@ -137,7 +137,7 @@ 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 || ( n->instrumentTrack()->isSustainPedalPressed() && + if( !n->isReleased() || ( n->instrumentTrack()->isSustainPedalPressed() && !n->isReleaseStarted() ) ) { envReleaseBegin += frames; diff --git a/src/core/NotePlayHandle.cpp b/src/core/NotePlayHandle.cpp index 612f725227d..84d888fee6b 100644 --- a/src/core/NotePlayHandle.cpp +++ b/src/core/NotePlayHandle.cpp @@ -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 ), @@ -75,8 +76,7 @@ NotePlayHandle::NotePlayHandle( InstrumentTrack* instrumentTrack, m_songGlobalParentOffset( 0 ), m_midiChannel( midiEventChannel >= 0 ? midiEventChannel : instrumentTrack->midiPort()->realOutputChannel() ), m_origin( origin ), - m_frequencyNeedsUpdate( false ), - m_releaseStarted( false ) + m_frequencyNeedsUpdate( false ) { lock(); if( hasParent() == false )