Hi all, When we implemented the dynamic sample loading, we also discussed if it would be good to provide a way to preload samples. Back then it was mainly meant as a way to preload all presets from a MIDI file, so that loading the samples dynamically wouldn't stall the playback. We decided that it wasn't worth the effort, as nobody had expressed an interest or seen a real need for it.
Well, I do have a real need for preloading presets (or rather samples) now. My use-case is the following: I'm building musical instruments that make use of FluidSynth for sound generation and those instruments are used in a real-time performance context. Players have the ability to switch between different instrument setups at the touch of a button and want to make use of this feature even in the middle of a performance. Those instrument setups also change the channel presets in FluidSynth, and as the SoundFonts reside on an SD-Card, switching between setups sometimes takes a few seconds. That is way too long for my users, who would like to switch setups between beats, in the fraction of a second. You could say that I shouldn't use dynamic sample loading in that case, but memory on the instrument is limited and I would rather not load all samples from a huge soundfont just because the player uses a single preset from that font. It also makes boot-up of the instrument *much* faster, so I really want a solution that works with dynamic sample loading. So currently I'm using a hackish way to implement preloading of sample data. I have increased the number of MIDI channels in the synth to 64 and use the otherwise unused channels 16-63 as "preload slots". When a user triggers the "preload" function, I go through all presets in all setups and assign each unique preset to the next available "preload slot channel", thereby loading the samples into the sample cache. That method works, but it does feel like a hack. It also puts an arbitrary limit on the number of presets I can preload, regardless of their actual size in memory. So I would really like to extend FluidSynth to allow for preloading of presets / samples via a public API. But before I make a suggestion in that direction, I wanted to ask your opinion on a a couple of questions: 1. Would such a preload feature even be interesting to other users? Or is the use-case so unique to my application that it wouldn't make sense to add it to FluidSynth? 2. If you think it could be added, is that because you would have a use-case for it as well? And if so, is it similar to mine (preloading an externally determined list of presets) or do you need it for something else (like preloading all presets from a MIDI file, for example)? The answers to those two questions would greatly influence the approach for this feature. Obviously the answer to 1. would be most important whether to approach it at all. But the answer to 2. might influence how to go about it. It could be implemented as a preload (load before use) or as "pinning" (don't unload after use). It might also affect where to extend FS: a public API for the sample cache, extending the preset selection functions, extending the soundfont loader interface, ... It would be great to hear your opinion about this! All the best Marcus _______________________________________________ fluid-dev mailing list fluid-dev@nongnu.org https://lists.nongnu.org/mailman/listinfo/fluid-dev