Make region removal order-preserving
This commit is contained in:
parent
2c10173356
commit
215077deaa
1 changed files with 11 additions and 14 deletions
|
|
@ -361,22 +361,20 @@ void sfz::Synth::finalizeSfzLoad()
|
||||||
{
|
{
|
||||||
resources.filePool.setRootDirectory(parser.originalDirectory());
|
resources.filePool.setRootDirectory(parser.originalDirectory());
|
||||||
|
|
||||||
auto currentRegion = regions.begin();
|
size_t currentRegionIndex = 0;
|
||||||
auto lastRegion = regions.rbegin();
|
size_t currentRegionCount = regions.size();
|
||||||
auto removeCurrentRegion = [¤tRegion, &lastRegion]() {
|
|
||||||
if (currentRegion->get() == nullptr)
|
|
||||||
return;
|
|
||||||
|
|
||||||
DBG("Removing the region with sample " << currentRegion->get()->sampleId);
|
auto removeCurrentRegion = [this, ¤tRegionIndex, ¤tRegionCount]() {
|
||||||
std::iter_swap(currentRegion, lastRegion);
|
DBG("Removing the region with sample " << regions[currentRegionIndex]->sampleId);
|
||||||
++lastRegion;
|
regions.erase(regions.begin() + currentRegionIndex);
|
||||||
|
--currentRegionCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
size_t maxFilters { 0 };
|
size_t maxFilters { 0 };
|
||||||
size_t maxEQs { 0 };
|
size_t maxEQs { 0 };
|
||||||
|
|
||||||
while (currentRegion < lastRegion.base()) {
|
while (currentRegionIndex < currentRegionCount) {
|
||||||
auto region = currentRegion->get();
|
auto region = regions[currentRegionIndex].get();
|
||||||
|
|
||||||
if (!region->oscillator && !region->isGenerator()) {
|
if (!region->oscillator && !region->isGenerator()) {
|
||||||
if (!resources.filePool.checkSampleId(region->sampleId)) {
|
if (!resources.filePool.checkSampleId(region->sampleId)) {
|
||||||
|
|
@ -481,11 +479,10 @@ void sfz::Synth::finalizeSfzLoad()
|
||||||
maxFilters = max(maxFilters, region->filters.size());
|
maxFilters = max(maxFilters, region->filters.size());
|
||||||
maxEQs = max(maxEQs, region->equalizers.size());
|
maxEQs = max(maxEQs, region->equalizers.size());
|
||||||
|
|
||||||
++currentRegion;
|
++currentRegionIndex;
|
||||||
}
|
}
|
||||||
const auto remainingRegions = std::distance(regions.begin(), lastRegion.base());
|
DBG("Removing " << (regions.size() - currentRegionCount) << " out of " << regions.size() << " regions");
|
||||||
DBG("Removing " << (regions.size() - remainingRegions) << " out of " << regions.size() << " regions");
|
regions.resize(currentRegionCount);
|
||||||
regions.resize(remainingRegions);
|
|
||||||
modificationTime = checkModificationTime();
|
modificationTime = checkModificationTime();
|
||||||
|
|
||||||
for (auto& voice : voices) {
|
for (auto& voice : voices) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue