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

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