Unfortunately this isn't quite finished, because there is a second reason why songs sometimes don't finish. It involves changing the play position slider to alter where the song it up to.
I am finding, when I call BASS_ChannelSetPosition, that VST string notes are carrying through to the new play position. It only happens with VST instruments - all SF2 notes are stopped. Strings carried through in this way will persist until a note off is encountered, and if not, it will persist to the end of the song and prevent it from ending properly. I think strings stand out because their notes don't decay like many other instruments. I suspect it is happening on other instruments, but all the other non-decay instrument are handled by SF2, not VST, so strings are different for my case.
Is it possible there is an issue with VST instruments not being reliably stopped during BASS_ChannelSetPosition?
I'm changing position by calling ...
BASS_ChannelSetPosition(hStream, pos, BASS_POS_MIDI_TICK | BASS_POS_FLUSH | BASS_MUSIC_POSRESET);
It is a MIDI stream, created with ...
BASS_MIDI_StreamCreateFile(FALSE, this->getFilename(), 0, 0, BASS_MIDI_ASYNC | BASS_MIDI_DECAYEND | BASS_SAMPLE_FLOAT, 44100)
Apart from BASS_POS_FLUSH and BASS_MUSIC_POSRESET on the BASS_ChannelSetPosition,I've tried calling BASS_VST_Resume(hVSTStream) on each VST channel, and even most recently tried ...
BASS_ChannelRemoveDSP(m_hVST_channel, m_hVSTDSP);
m_hVSTDSP = BASS_ChannelSetDSP(m_hVST_channel, DSP_Callback, (VOID*)this, 0);
... on each VST channel, renewing the DSP, in order to try and force all VST data to be killed. But still the problem persists.
I don't have any more thoughts on how to stop those VST strings from persisting through a stream position change.