InstrumentTrack, NotePlayHandled: added initial sustain pedal support

This commit is contained in:
Tobias Doerffel
2012-11-11 19:39:27 +01:00
parent aae89e186c
commit c39512403b
3 changed files with 26 additions and 2 deletions

View File

@@ -2,7 +2,7 @@
* InstrumentTrack.h - declaration of class InstrumentTrack, a track + window
* which holds an instrument-plugin
*
* Copyright (c) 2004-2010 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2012 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* 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;

View File

@@ -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;
}

View File

@@ -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;