komh / ksoftseq

K Soft Sequencer
3 stars 1 forks source link

enhancement suggestion: preload .SF2 file ? #11

Closed lerdmann closed 1 year ago

lerdmann commented 1 year ago

When I double click on a MIDI file to have it played, apparently something happens that takes quite some time until the MIDI file finally starts to replay. This happens on any file selection for replay and it apparently is also independent on the MIDI file's size.

I suspect that this is the loading of the .SF2 file (the WAV sound samples ?) because the .SF2 file that I am using is 248 MB in size which of course can take quite some time to read from the disk and load into memory. If possible, I would suggest to load the .SF2 file only once, directly from the _DLL_InitTerm function (and free it when the DLL unloads). Or is this a behaviour of the fluidsynth DLL that cannot be customized ?

lerdmann commented 1 year ago

Looked at the code and saw that the kmididec API has the limitation that it only allows an .SF2 filename but not file descriptor when opening an instance. Maybe the trick is to create a memory file and provide that filename of that memory file to the kmididec function (don't know if the LIBC API offers such a feature).

komh commented 1 year ago

Thanks for your suggestion!

I also thought about it. But if such a big SF2 file is always resident, memory consumption is not efficiency because if ksoftseq is loaded, it is not freed until system restarts, or maybe WPS.

In addition, in my case I'm using > 400MB sf2 file. Some other users may have bigger sf2 files. Then, it is likely to encounter memory exhaustion when launchs heavy programs.

Because of this, I decided to load sf2 file every time.

lerdmann commented 1 year ago

We have plenty of memory in the year 2023. And for those systems that can only address 1 GB even if they have much more memory installed, OS/2 is no longer a viable choice anyways.

DavidMcKenna commented 1 year ago

Maybe it would be possible to be able to select whether to keep ksoftseq.sf2 in memory (or not) by a checkbox on the K Soft Sequencer tab of the Multimedia Setup program?

komh commented 1 year ago

I put this in lowest priority. But patches always welcome.

Thanks!