Closed ell1e closed 2 years ago
If f->maxVoiceNum
has been set by tsf_set_max_voices
the line f->voices = ...TSF_REALLOC...
in tsf_note_on
should never hit afterwards. Is this not enforcing the max voices?
I do agree that it would be nicer if old voices were dropped once the limit is hit, but the current implementation is to just not play any new voices until one finishes (which is hinted at by the documentation line "so don't keep this number too low or otherwise sounds may not play.").
Oops, yeah I missed the f->maxVoiceNum
in the middle of that line, my bad. This should work fine.
The
tsf_set_max_voices()
function sounds like it sets a definite maximum of voices where notes will be dropped. This would be very useful for both predictability and better protection from stutter and other worse issues from too overly complex midi files.But it doesn't seem to enforce the limit at all, so in a threaded setting,
tsf_set_max_voices()
appears to be currently useless for safely avoiding later allocations unless one is manually checking in advance whether a song doesn't actually exceed the pre-allocated voices in any single spot. And this is not a trivial task for inexperienced programmers, IMHO, and it's also not obvious this is required. (Since it's calledtsf_set_max_voices()
, and nottsf_set_expected_max_voices()
or something.)In other words,
tsf_set_max_voices
should set an actual hard limit on thetsf*
instances where old voices actually get dropped, and not be a soft one that you can just plow through anyway by accident.