5063 |
if (!file) return; |
if (!file) return; |
5064 |
|
|
5065 |
// collect all samples that are not referenced by any instrument |
// collect all samples that are not referenced by any instrument |
5066 |
std::list<gig::Sample*> lsamples; |
std::list<gig::Sample*> lsamples = unusedSamples(file); |
|
for (int iSample = 0; file->GetSample(iSample); ++iSample) { |
|
|
gig::Sample* sample = file->GetSample(iSample); |
|
|
bool isUsed = false; |
|
|
for (gig::Instrument* instrument = file->GetFirstInstrument(); instrument; |
|
|
instrument = file->GetNextInstrument()) |
|
|
{ |
|
|
for (gig::Region* rgn = instrument->GetFirstRegion(); rgn; |
|
|
rgn = instrument->GetNextRegion()) |
|
|
{ |
|
|
for (int i = 0; i < 256; ++i) { |
|
|
if (!rgn->pDimensionRegions[i]) continue; |
|
|
if (rgn->pDimensionRegions[i]->pSample != sample) continue; |
|
|
isUsed = true; |
|
|
goto endOfRefSearch; |
|
|
} |
|
|
} |
|
|
} |
|
|
endOfRefSearch: |
|
|
if (!isUsed) lsamples.push_back(sample); |
|
|
} |
|
|
|
|
5067 |
if (lsamples.empty()) return; |
if (lsamples.empty()) return; |
5068 |
|
|
5069 |
// notify everybody that we're going to remove these samples |
// notify everybody that we're going to remove these samples |