fix: Clear SoundFonts on SamplePool reset#254
Conversation
|
Hey thanks a lot for the fix! |
|
It wouldn't cause a crash, but it would result in SoundFonts failing to load on any subsequent projects unless LittleGPTracker is restarted. More concretely, loading the same project (containing one SoundFont) four times silently fails to load the SoundFonts the fourth time (and in any subsequently loaded projects): The project appears to load properly, but on playback the SoundFont samples are missing. This is because the array of loaded SoundFonts isn't cleared when a new project is loaded, which results in this branch never being executed when it is full: |
|
Hey I appreciate you putting time into this, I'm sorry but I haven't had the time to test it out yet. |
djdiskmachine
left a comment
There was a problem hiding this comment.
Super great feature, thanks a lot for making this!
Maybe we could indicate it's a SoundFont in the browser somehow? Inverted text / some icon maybe? :)
| Trace::Log("Load", "%s", path.GetCanonicalPath().c_str()); | ||
| loadSoundFont(path.GetPath().c_str()) ; | ||
| if (sf_idx == MAX_SOUNDFONTS) { | ||
| Trace::Error("Warning maximum soundfont count reached") ; |
There was a problem hiding this comment.
This is fine but we should notify the user too, check this
Requires enabling by putting this update thing somewhere in DrawView
There was a problem hiding this comment.
Maybe we could indicate it's a SoundFont in the browser somehow? Inverted text / some icon maybe? :)
I opted for inverted text and merged the sf2-import branch into this one.
This is fine but we should notify the user too, check this
I tried using a notification, but I wasn't happy with its visibility, especially when in the ImportSampleDialog. I opted for a MessageBox instead. An error now appears on startup or on importing a sample whenever necessary.
Description
This PR clears loaded SoundFonts on
SoundFontManager(thus alsoSamplePool) reset. This fixes a bug where loading SoundFont-containing projects successively results in unloaded SoundFonts once the maximum number of loaded SoundFonts (set to 3) is exhausted, e.g. loading a project containing one SoundFont four times in a row results in an unloaded SoundFont in the last instance. I've also added logs for SoundFont loads and allowed the aforementioned limit to be specified at compile-time (documented in the reference manual).Type of change
How Has This Been Tested?
The workflow described above involving projects with SoundFonts was checked with the proposed changes and resulted in loaded SoundFonts in all cases. The preprocessor directive was also tested with projects containing more than 3 SoundFonts.
Test Configuration:
Checklist:
sources/Application/Model/Project.h