From a898558b255f46f0a778c18ca99aeb771275c648 Mon Sep 17 00:00:00 2001 From: Ahmad Date: Tue, 5 May 2026 01:35:57 +1000 Subject: [PATCH 1/4] Unload SoundFonts on SoundFontManager reset --- sources/Application/Instruments/SoundFontManager.cpp | 5 +++++ sources/Application/Instruments/SoundFontManager.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/sources/Application/Instruments/SoundFontManager.cpp b/sources/Application/Instruments/SoundFontManager.cpp index d56a4efc..763ab1dd 100644 --- a/sources/Application/Instruments/SoundFontManager.cpp +++ b/sources/Application/Instruments/SoundFontManager.cpp @@ -14,6 +14,11 @@ void SoundFontManager::Reset() { SAFE_FREE(*it) ; it=sampleData_.erase(it) ; } ; + + // Unload all SoundFonts + sfBankID i; + for(i = 0; i < MAX_SOUNDFONTS; i++) + sfUnloadSFBank(i); } ; sfBankID SoundFontManager::LoadBank(const char *path) { diff --git a/sources/Application/Instruments/SoundFontManager.h b/sources/Application/Instruments/SoundFontManager.h index f0100200..cf495000 100644 --- a/sources/Application/Instruments/SoundFontManager.h +++ b/sources/Application/Instruments/SoundFontManager.h @@ -5,6 +5,8 @@ #include "Externals/Soundfont/ENAB.H" #include +#define MAX_SOUNDFONTS MAXLOADEDBANKS + class SoundFontManager:public T_Singleton { public: SoundFontManager() ; From 3fe326ff13d95fa0fa2b4f698ce31003eebb1764 Mon Sep 17 00:00:00 2001 From: Ahmad Date: Tue, 5 May 2026 01:37:37 +1000 Subject: [PATCH 2/4] Add SoundFont logs --- .../Application/Instruments/SamplePool.cpp | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/sources/Application/Instruments/SamplePool.cpp b/sources/Application/Instruments/SamplePool.cpp index 91d4815e..8d39b53d 100644 --- a/sources/Application/Instruments/SamplePool.cpp +++ b/sources/Application/Instruments/SamplePool.cpp @@ -72,15 +72,21 @@ void SamplePool::Load() { dir->GetContent("*.sf2") ; IteratorPtr it2(dir->GetIterator()) ; + int sf_idx = 0; - for(it2->Begin();!it2->IsDone();it2->Next()) { - Path &path=it2->CurrentItem() ; - loadSoundFont(path.GetPath().c_str()) ; - } ; + for (it2->Begin(); !it2->IsDone(); it2->Next(), sf_idx++) { + Path &path=it2->CurrentItem() ; + 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") ; + break ; + } ; + }; - delete dir ; + delete dir; - // now sort the samples + // now sort the samples Sort(); } ; @@ -323,9 +329,10 @@ bool SamplePool::loadSoundFont(const char *path) { sfPresetHdr current=pHeaders[i] ; wav_[count_]=new SoundFontPreset(id,i) ; const char *name=pHeaders[i].achPresetName ; - names_[count_]=(char*)SYS_MALLOC(strlen(name)+1) ; - strcpy(names_[count_],name) ; - count_++ ; + Trace::Log("loadSoundFont", "%s", name); + names_[count_] = (char *)SYS_MALLOC(strlen(name) + 1); + strcpy(names_[count_], name); + count_++; } } /* From c5a2ee461f78c5eb250b2068c1ba72d88fb9557a Mon Sep 17 00:00:00 2001 From: Ahmad Date: Tue, 5 May 2026 01:38:05 +1000 Subject: [PATCH 3/4] Add and document max SF2 count flexibility --- docs/wiki/What-is-LittlePiggyTracker.md | 2 +- sources/Externals/Soundfont/ENAB.H | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/wiki/What-is-LittlePiggyTracker.md b/docs/wiki/What-is-LittlePiggyTracker.md index b05c0e7a..c7236b84 100644 --- a/docs/wiki/What-is-LittlePiggyTracker.md +++ b/docs/wiki/What-is-LittlePiggyTracker.md @@ -47,7 +47,7 @@ After that you can copy additional wavs to the lgptRoot/lgptProject/samples dire **Use 8 or 16 Bit wav files, any sampling frequency, mono or stereo**. 8bit samples are converted to 16bit at load time for compatibility with the engine (you can save space in storage but not in RAM). -**Piggy now supports .sf2 Soundfonts. You must add these by hand to your SAMPLES directory, use PROGRAM CHANGE commands to load different patches. Loop points are automatically loaded, but you'll need to make VOLM setting to adjust decay.** +**Piggy now supports .sf2 Soundfonts.** You must add these by hand to your SAMPLES directory, use PROGRAM CHANGE commands to load different patches. Loop points are automatically loaded, but you'll need to make VOLM setting to adjust decay. By default, at most 3 are loaded per project; this limit may be increased by recompiling LittleGPTracker with the compiler flag `-DMAXLOADEDBANKS=X`, where `X` is the desired limit. ## New project diff --git a/sources/Externals/Soundfont/ENAB.H b/sources/Externals/Soundfont/ENAB.H index 1db993a5..79c85343 100644 --- a/sources/Externals/Soundfont/ENAB.H +++ b/sources/Externals/Soundfont/ENAB.H @@ -91,7 +91,9 @@ // the extent of the internal implementation, (array) of info nodes, one per // loaded banks. Need more than the default? Change this and you got 'em. +#ifndef MAXLOADEDBANKS # define MAXLOADEDBANKS 3 +#endif // This is the type of a sfBankID, -1 is an error condition. typedef SHORT sfBankID; From 503116e660c17ae117523d8f26c6acfa57178efd Mon Sep 17 00:00:00 2001 From: Ahmad Date: Tue, 5 May 2026 01:42:06 +1000 Subject: [PATCH 4/4] Update CHANGELOG and Project.h --- CHANGELOG | 1 + sources/Application/Model/Project.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 8c1f13d5..217e1718 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -26,6 +26,7 @@ Various additions Fix regression caused in https://github.com/djdiskmachine/LittleGPTracker/pull/245 Fix introduced microtonality for single cycle osc, thank you @INFU-AV <3 Purge samples actually purges samples [author: maks](https://github.com/xiphonics/picoTracker/pull/313) + Clear SoundFonts on SamplePool reset 1.6.0-bacon11 Slices decoupled from loop mode diff --git a/sources/Application/Model/Project.h b/sources/Application/Model/Project.h index a3c14a3c..00bfe0f4 100644 --- a/sources/Application/Model/Project.h +++ b/sources/Application/Model/Project.h @@ -21,7 +21,7 @@ #define PROJECT_NUMBER "1" #define PROJECT_RELEASE "6" -#define BUILD_COUNT "0-bacon14" +#define BUILD_COUNT "0-bacon15" #define MAX_TAP 3