schellingb / TinySoundFont

SoundFont2 synthesizer library in a single C/C++ file
MIT License
608 stars 71 forks source link

Memory duplicate #44

Open WindowsNT opened 4 years ago

WindowsNT commented 4 years ago

It's really great, I use it for my sequencer. However I have an issue, for simultaneous processing. Say I have two tracks that use the same channel and loaded SF file, then simultaneous processing cannot be with TSF.

  1. Is there a way to have simultaneous processing within the same TSF object?
  2. If not, is there a way to "mirror" the samples from another TSF object? Currently I use tsf_load_memory to load a SF, but although the memory is the same, TSF duplicates it in their own structures. Is there a way to avoid duplication of the same samples?

Best regards,

schellingb commented 4 years ago

Hey there

Can you check out pull request #1 and see if it fits your needs? I have considered merging this at some point but wasn't sure if this solves many problems or just very specific ones and then forgot again about it. If you could try it and give some feedback, I can look into merging this again. This would be solution 2. which probably is far easier than a good clean API that solves it with an approach described in 1.

WindowsNT commented 4 years ago

Thanks a lot, I will take a look. VST instruments do not support multi-processing so without such a mechanism I would need to duplicate the VST, which means that TSF would create the same presets twice in memory. If there is a copy mechanism then another instance of TSF, independent of the first, would be able to run on the same samples.

I will check it and notify you of the results. Here is my project. Best,