Skip to content

fix: Clear SoundFonts on SamplePool reset#254

Open
ax0 wants to merge 6 commits into
djdiskmachine:masterfrom
ax0:sf2-fix
Open

fix: Clear SoundFonts on SamplePool reset#254
ax0 wants to merge 6 commits into
djdiskmachine:masterfrom
ax0:sf2-fix

Conversation

@ax0
Copy link
Copy Markdown

@ax0 ax0 commented May 4, 2026

Description

This PR clears loaded SoundFonts on SoundFontManager (thus also SamplePool) 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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

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:

  • Hardware: Intel x64, Anbernic RG28XX.
  • Test steps:
    1. Load a project containing a SoundFont and play it, confirming playback of the SoundFont sample(s).
    2. Repeat Step 1 as many times as necessary to confirm that occupied SoundFont slots do not persist across project loads.

Checklist:

  • I have performed a self-review of my code
  • I have commented particularly in hard-to-understand areas
  • I have updated CHANGELOG
  • I have updated docs/wiki/What-is-LittlePiggyTracker.md reflecting my changes
  • I have version bumped in sources/Application/Model/Project.h
  • My changes generate no new warnings (build without your change then apply your change to check this)

@djdiskmachine
Copy link
Copy Markdown
Owner

Hey thanks a lot for the fix!
I barely used Soundfonts, you're saying that re-loading the same project with soundfonts multiple times would eventually cause a crash?

@ax0
Copy link
Copy Markdown
Author

ax0 commented May 4, 2026

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:

if(bankNodes[i].pHydra == NULL ) { // use first we find...

@djdiskmachine
Copy link
Copy Markdown
Owner

Hey I appreciate you putting time into this, I'm sorry but I haven't had the time to test it out yet.
I'd really like to improve on the soundfont stuff, it'd be really nice to be able to browse import and possibly even export soundfonts in the future so I'm really thankful you did this ^_^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants