Skip to content

Commit 3a94ed3

Browse files
DomClarkzonkmachine
authored andcommitted
Fix occasional Sinnah hang
1 parent 277e8b6 commit 3a94ed3

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

include/InstrumentPlayHandle.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,7 @@ class EXPORT InstrumentPlayHandle : public PlayHandle
4242

4343
virtual void play( sampleFrame * _working_buffer )
4444
{
45-
// if the instrument is midi-based, we can safely render right away
46-
if( m_instrument->flags() & Instrument::IsMidiBased )
47-
{
48-
m_instrument->play( _working_buffer );
49-
return;
50-
}
51-
52-
// if not, we need to ensure that all our nph's have been processed first
45+
// ensure that all our nph's have been processed first
5346
ConstNotePlayHandleList nphv = NotePlayHandle::nphsOfInstrumentTrack( m_instrument->instrumentTrack(), true );
5447

5548
bool nphsLeft;

plugins/vst_base/RemoteVstPlugin.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
#define USE_WS_PREFIX
6464
#include <windows.h>
6565

66+
#include <algorithm>
6667
#include <vector>
6768
#include <queue>
6869
#include <string>
@@ -900,6 +901,14 @@ void RemoteVstPlugin::process( const sampleFrame * _in, sampleFrame * _out )
900901
static char eventsBuffer[sizeof( VstEvents ) + sizeof( VstMidiEvent * ) * MIDI_EVENT_BUFFER_COUNT];
901902
static VstMidiEvent vme[MIDI_EVENT_BUFFER_COUNT];
902903

904+
// first sort events chronologically, since some plugins
905+
// (e.g. Sinnah) can hang if they're out of order
906+
std::stable_sort( m_midiEvents.begin(), m_midiEvents.end(),
907+
[]( const VstMidiEvent &a, const VstMidiEvent &b )
908+
{
909+
return a.deltaFrames < b.deltaFrames;
910+
} );
911+
903912
VstEvents* events = (VstEvents *) eventsBuffer;
904913
events->reserved = 0;
905914
events->numEvents = m_midiEvents.size();

0 commit comments

Comments
 (0)