6389 |
wave->AddSubChunk(CHUNK_ID_FMT, 16); |
wave->AddSubChunk(CHUNK_ID_FMT, 16); |
6390 |
wave->AddSubList(LIST_TYPE_INFO); |
wave->AddSubList(LIST_TYPE_INFO); |
6391 |
|
|
6392 |
|
const size_t idxIt = SamplesIterator - pSamples->begin(); |
6393 |
pSamples->push_back(pSample); |
pSamples->push_back(pSample); |
6394 |
|
SamplesIterator = pSamples->begin() + std::min(idxIt, pSamples->size()); // avoid iterator invalidation |
6395 |
return pSample; |
return pSample; |
6396 |
} |
} |
6397 |
|
|
6408 |
if (!pSamples || !pSamples->size()) throw gig::Exception("Could not delete sample as there are no samples"); |
if (!pSamples || !pSamples->size()) throw gig::Exception("Could not delete sample as there are no samples"); |
6409 |
SampleList::iterator iter = find(pSamples->begin(), pSamples->end(), (DLS::Sample*) pSample); |
SampleList::iterator iter = find(pSamples->begin(), pSamples->end(), (DLS::Sample*) pSample); |
6410 |
if (iter == pSamples->end()) throw gig::Exception("Could not delete sample, could not find given sample"); |
if (iter == pSamples->end()) throw gig::Exception("Could not delete sample, could not find given sample"); |
6411 |
if (SamplesIterator != pSamples->end() && *SamplesIterator == pSample) ++SamplesIterator; // avoid iterator invalidation |
const size_t idxIt = SamplesIterator - pSamples->begin(); |
6412 |
pSamples->erase(iter); |
pSamples->erase(iter); |
6413 |
|
SamplesIterator = pSamples->begin() + std::min(idxIt, pSamples->size()); // avoid iterator invalidation |
6414 |
pSample->DeleteChunks(); |
pSample->DeleteChunks(); |
6415 |
delete pSample; |
delete pSample; |
6416 |
|
|
6517 |
ExtensionFiles.push_back(pExtFile); |
ExtensionFiles.push_back(pExtFile); |
6518 |
} |
} |
6519 |
|
|
6520 |
// load samples from extension files (if required) |
// load all samples (both from this/main .gig file as well as from |
6521 |
|
// extension files if required) |
6522 |
for (int i = 0; i < poolFiles.size(); i++) { |
for (int i = 0; i < poolFiles.size(); i++) { |
6523 |
RIFF::File* file = poolFiles[i]; |
RIFF::File* file = poolFiles[i]; |
6524 |
RIFF::List* wvpl = file->GetSubList(LIST_TYPE_WVPL); |
RIFF::List* wvpl = file->GetSubList(LIST_TYPE_WVPL); |
6525 |
if (wvpl) { |
if (wvpl) { |
6526 |
file_offset_t wvplFileOffset = wvpl->GetFilePos() - |
file_offset_t wvplFileOffset = wvpl->GetFilePos() - |
6527 |
wvpl->GetPos(); // should be zero, but just to be sure |
wvpl->GetPos(); // should be zero, but just to be sure |
6528 |
size_t i = 0; |
size_t iWaveCk = 0; |
6529 |
for (RIFF::List* wave = wvpl->GetSubListAt(i); wave; |
for (RIFF::List* wave = wvpl->GetSubListAt(iWaveCk); wave; |
6530 |
wave = wvpl->GetSubListAt(++i)) |
wave = wvpl->GetSubListAt(++iWaveCk)) |
6531 |
{ |
{ |
6532 |
if (wave->GetListType() == LIST_TYPE_WAVE) { |
if (wave->GetListType() == LIST_TYPE_WAVE) { |
6533 |
// notify current progress |
// notify current progress |