diff --git a/include/InstrumentTrack.h b/include/InstrumentTrack.h index 57e8ffb60..1dc4383c6 100644 --- a/include/InstrumentTrack.h +++ b/include/InstrumentTrack.h @@ -2,7 +2,7 @@ * InstrumentTrack.h - declaration of class InstrumentTrack, a track + window * which holds an instrument-plugin * - * Copyright (c) 2004-2010 Tobias Doerffel + * Copyright (c) 2004-2012 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -80,6 +80,11 @@ public: // silence all running notes played by this track void silenceAllNotes(); + bool isSustainPedalPressed() const + { + return m_sustainPedalPressed; + } + f_cnt_t beatLen( notePlayHandle * _n ) const; @@ -215,6 +220,7 @@ private: notePlayHandle * m_notes[NumKeys]; int m_runningMidiNotes[NumKeys]; + bool m_sustainPedalPressed; IntModel m_baseNoteModel; diff --git a/src/core/note_play_handle.cpp b/src/core/note_play_handle.cpp index a94a9eca4..90bf54d01 100644 --- a/src/core/note_play_handle.cpp +++ b/src/core/note_play_handle.cpp @@ -190,6 +190,7 @@ void notePlayHandle::play( sampleFrame * _working_buffer ) } if( m_released == false && + instrumentTrack()->isSustainPedalPressed() == false && m_totalFramesPlayed + engine::getMixer()->framesPerPeriod() >= m_frames ) { @@ -293,7 +294,11 @@ void notePlayHandle::play( sampleFrame * _working_buffer ) f_cnt_t notePlayHandle::framesLeft() const { - if( m_released && actualReleaseFramesToDo() == 0 ) + if( instrumentTrack()->isSustainPedalPressed() ) + { + return 4*engine::getMixer()->framesPerPeriod(); + } + else if( m_released && actualReleaseFramesToDo() == 0 ) { return m_framesBeforeRelease; } diff --git a/src/tracks/InstrumentTrack.cpp b/src/tracks/InstrumentTrack.cpp index 73adbbde8..267af765b 100644 --- a/src/tracks/InstrumentTrack.cpp +++ b/src/tracks/InstrumentTrack.cpp @@ -98,6 +98,7 @@ InstrumentTrack::InstrumentTrack( trackContainer * _tc ) : m_midiPort( tr( "unnamed_track" ), engine::getMixer()->midiClient(), this, this ), m_notes(), + m_sustainPedalPressed( false ), m_baseNoteModel( 0, 0, KeysPerOctave * NumOctaves - 1, this, tr( "Base note" ) ), m_volumeModel( DefaultVolume, MinVolume, MaxVolume, 0.1f, this, @@ -303,6 +304,18 @@ void InstrumentTrack::processInEvent( const midiEvent & _me, break; case MidiControlChange: + if( _me.controllerNumber() == MidiControllerSustain ) + { + if( _me.controllerValue() > MidiMaxControllerValue/2 ) + { + m_sustainPedalPressed = true; + } + else + { + m_sustainPedalPressed = false; + } + } + case MidiProgramChange: m_instrument->handleMidiEvent( _me, _time ); break;