Release only one note on keyup
Previously if you release a C4 then all C4 notes would be released. Now it stores the pointer to the plugin data which is unique for each key press and determines which to release based on the matching pointers.
This commit is contained in:
@@ -74,14 +74,6 @@ Plugin::Descriptor PLUGIN_EXPORT gigplayer_plugin_descriptor =
|
||||
|
||||
|
||||
|
||||
struct GIGPluginData
|
||||
{
|
||||
int midiNote;
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
|
||||
GigInstrument::GigInstrument( InstrumentTrack * _instrument_track ) :
|
||||
Instrument( _instrument_track, &gigplayer_plugin_descriptor ),
|
||||
m_instance( NULL ),
|
||||
@@ -313,7 +305,7 @@ void GigInstrument::playNote( NotePlayHandle * _n, sampleFrame * )
|
||||
const uint velocity = _n->midiVelocity( baseVelocity );
|
||||
|
||||
QMutexLocker locker( &m_notesMutex );
|
||||
m_notes.push_back( GigNote( midiNote, velocity, _n->unpitchedFrequency() ) );
|
||||
m_notes.push_back( GigNote( midiNote, velocity, _n->unpitchedFrequency(), pluginData ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -686,7 +678,8 @@ void GigInstrument::deleteNotePluginData( NotePlayHandle * _n )
|
||||
// pressed (i.e., not if the key was already released)
|
||||
for( QList<GigNote>::iterator i = m_notes.begin(); i != m_notes.end(); ++i )
|
||||
{
|
||||
if( i->midiNote == pluginData->midiNote &&
|
||||
// Find the note by matching pointers to the plugin data
|
||||
if( i->handle == pluginData &&
|
||||
( i->state == KeyDown || i->state == PlayingKeyDown ) )
|
||||
{
|
||||
i->state = KeyUp;
|
||||
|
||||
@@ -48,6 +48,16 @@ class PatchesDialog;
|
||||
class QLabel;
|
||||
|
||||
|
||||
|
||||
|
||||
struct GIGPluginData
|
||||
{
|
||||
int midiNote;
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
|
||||
// Load a GIG file using libgig
|
||||
class GigInstance
|
||||
{
|
||||
@@ -195,9 +205,15 @@ public:
|
||||
float frequency;
|
||||
QList<GigSample> samples;
|
||||
|
||||
GigNote( int midiNote, int velocity, float frequency )
|
||||
// Used to determine which note should be released on key up
|
||||
//
|
||||
// Note: if accessing the data, be careful not to access it after the key
|
||||
// has been released since that's when it is deleted
|
||||
GIGPluginData * handle;
|
||||
|
||||
GigNote( int midiNote, int velocity, float frequency, GIGPluginData * handle )
|
||||
: midiNote( midiNote ), velocity( velocity ),
|
||||
release( false ), state( KeyDown ), frequency( frequency )
|
||||
release( false ), state( KeyDown ), frequency( frequency ), handle( handle )
|
||||
{
|
||||
}
|
||||
} ;
|
||||
|
||||
Reference in New Issue
Block a user