Fixed release samples never being deleted
I removed code in a previous commit that deleted ended samples since that sometimes caused issues when the samples had loop points. However, removing the code caused issues with the release samples. Thus, now it removes ended samples only if they are release samples. Otherwise, the keyup event and ADSR handle ending the note.
This commit is contained in:
@@ -371,7 +371,12 @@ void GigInstrument::play( sampleFrame * _working_buffer )
|
||||
for( QList<GigSample>::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 )
|
||||
|
||||
@@ -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<GigSample> 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 )
|
||||
{
|
||||
}
|
||||
} ;
|
||||
|
||||
Reference in New Issue
Block a user