diff --git a/plugins/GigPlayer/GigPlayer.cpp b/plugins/GigPlayer/GigPlayer.cpp index c4f98ca2c..34e404420 100644 --- a/plugins/GigPlayer/GigPlayer.cpp +++ b/plugins/GigPlayer/GigPlayer.cpp @@ -371,7 +371,12 @@ void GigInstrument::play( sampleFrame * _working_buffer ) for( QList::iterator sample = it->samples.begin(); sample != it->samples.end(); ++sample ) { - if( sample->sample == NULL || sample->adsr.done() ) + // Delete if the ADSR for a sample is complete for normal + // notes, or if a release sample, then if we've reached + // the end of the sample + if( sample->sample == NULL || sample->adsr.done() || + ( it->isRelease == true && + sample->pos >= sample->sample->SamplesTotal - 1 ) ) { sample = it->samples.erase( sample ); @@ -729,6 +734,10 @@ void GigInstrument::addSamples( GigNote & gignote, bool wantReleaseSample ) gig::DimensionRegion * pDimRegion = pRegion->GetDimensionRegionByValue( dim.DimValues ); gig::Sample * pSample = pDimRegion->pSample; + // If this is a release sample, the note won't ever be + // released, so we handle it differently + gignote.isRelease = wantReleaseSample; + // Does this note have release samples? Set this only on the original // notes and not when we get the release samples. if( wantReleaseSample != true ) diff --git a/plugins/GigPlayer/GigPlayer.h b/plugins/GigPlayer/GigPlayer.h index 25600e166..f302df622 100644 --- a/plugins/GigPlayer/GigPlayer.h +++ b/plugins/GigPlayer/GigPlayer.h @@ -201,6 +201,7 @@ public: int midiNote; int velocity; bool release; // Whether to trigger a release sample on key up + bool isRelease; // Whether this is a release sample, changes when we delete it GigState state; float frequency; QList samples; @@ -213,7 +214,8 @@ public: GigNote( int midiNote, int velocity, float frequency, GIGPluginData * handle ) : midiNote( midiNote ), velocity( velocity ), - release( false ), state( KeyDown ), frequency( frequency ), handle( handle ) + release( false ), isRelease( false ), state( KeyDown ), + frequency( frequency ), handle( handle ) { } } ;