I’ve created child classes for a sampler plugin where positions corresponding to midiNotes are populated by sounds according to category from a sound bank. On first run if there are currently no sounds fitted to the specified category, it properly just does not play the sound when the corresponding note is hit, however, if its changed to an empty category, then the program crashes when sounds are reloaded, generally throwing LittleEndian AudioBuffer errors.
I have attempted multiple approaches to removing sounds, but none seem to work. when running:
if(getNumSounds() != 0)
{
for(int i = 0; i < getNumSounds(); i++)
{
removeSound(i);
}
DBG(std::to_string(getNumSounds()) << " Sounds");
DBG(std::to_string(slots.size()) << " Slots");
}
the number of sounds gradually increases to encompass the entire sound bank. If a particular slot becomes empty, it still crashes. I have attempted clearing the soundBuffer, regenerating items, setting the format reader and/or sound[index] to a nullptr, etc… I’ve considered just adding a constraint to the category ComboBox, but that would not help in the instance a different sound bank is chosen where some sound categories might not be available. I’ve been banging my head on this for a few days, and its driving me nuts since I know there should be a way to handle cases where a specific sampler item becomes empty.
Any advice would be much appreciated, thanks!

Solution, remove them in reverse order and the problem goes away.
lol