ref: 2faf5b7adde4a263fe64ee94413c6aec326e5d07
parent: 268f8e86c3d78d9d165c1605ae0e0e04c575598c
author: Bernhard Schelling <schellingb@gmail.com>
date: Tue Oct 24 21:41:12 EDT 2017
Correctly stop notes with note_off Previous commit still was not correct as it ended up not stopping notes which were in sustained state
--- a/tsf.h
+++ b/tsf.h
@@ -1241,7 +1241,7 @@
for (; v != vEnd; v++)
{
//Find the first and last entry in the voices list with matching preset, key and look up the smallest play index
- if (v->playingPreset != preset_index || v->playingKey != key || v->ampenv.segment >= TSF_SEGMENT_SUSTAIN) continue;
+ if (v->playingPreset != preset_index || v->playingKey != key || v->ampenv.segment >= TSF_SEGMENT_RELEASE) continue;
else if (!vMatchFirst || v->playIndex < vMatchFirst->playIndex) vMatchFirst = vMatchLast = v;
else if (v->playIndex == vMatchFirst->playIndex) vMatchLast = v;
}
@@ -1250,7 +1250,7 @@
{
//Stop all voices with matching preset, key and the smallest play index which was enumerated above
if (v != vMatchFirst && v != vMatchLast &&
- (v->playIndex != vMatchFirst->playIndex || v->playingPreset != preset_index || v->playingKey != key || v->ampenv.segment >= TSF_SEGMENT_SUSTAIN)) continue;
+ (v->playIndex != vMatchFirst->playIndex || v->playingPreset != preset_index || v->playingKey != key || v->ampenv.segment >= TSF_SEGMENT_RELEASE)) continue;
tsf_voice_end(v, f->outSampleRate);
}
}