Closed kazukazu123123 closed 3 months ago
Sounds nice. To me the only "problem" with libtsf is indeed the optimization, otherwise as a barebones synth its actually quite nice. Maybe vectorization of the mixer/synthesizer with SSE/AVX/NEON may also help?
In the current implementation, setting very large values such as
tsf_set_max_voice(5000)
ortsf_set_max_voices(10000)
results in a significant increase in RAM usage and a slowdown in rendering time, possibly due to voices being pre-allocated. This becomes a particularly problematic issue in high-load scenarios, such as rendering/playing MIDI files with a large number of events, like those seen in Black MIDI, where frequentnote_on
/note_off
calls occur. To address this issue, this proposal suggests implementing a system that dynamically allocates voices as needed and releases them when they are no longer necessary. This approach can optimize memory usage efficiency.Furthermore, it is recommended to consider a mechanism that immediately stops the playback of the oldest voice when the
note_on
function exceeds the limit ofmax_voice
. This prevents the problem of new sounds not starting when the simultaneous voice count exceedsmax_voice
. (Apologies if this is already implemented or if there are other existing methods).I truly appreciate this excellent library, which allows easy rendering of audio to the buffer and can be handled with a simple API such as
tsf_note_on()
andtsf_note_off
. If possible, please consider this proposal.I apologize for any shortcomings in the structure of the text. I am Japanese and not very fluent in English.