2 |
* * |
* * |
3 |
* libgig - C++ cross-platform Gigasampler format file access library * |
* libgig - C++ cross-platform Gigasampler format file access library * |
4 |
* * |
* * |
5 |
* Copyright (C) 2003-2019 by Christian Schoenebeck * |
* Copyright (C) 2003-2021 by Christian Schoenebeck * |
6 |
* <cuse@users.sourceforge.net> * |
* <cuse@users.sourceforge.net> * |
7 |
* * |
* * |
8 |
* This library is free software; you can redistribute it and/or modify * |
* This library is free software; you can redistribute it and/or modify * |
209 |
if (lart) { |
if (lart) { |
210 |
uint32_t artCkType = (lart->GetListType() == LIST_TYPE_LAR2) ? CHUNK_ID_ART2 |
uint32_t artCkType = (lart->GetListType() == LIST_TYPE_LAR2) ? CHUNK_ID_ART2 |
211 |
: CHUNK_ID_ARTL; |
: CHUNK_ID_ARTL; |
212 |
RIFF::Chunk* art = lart->GetFirstSubChunk(); |
size_t i = 0; |
213 |
while (art) { |
for (RIFF::Chunk* art = lart->GetSubChunkAt(i); art; |
214 |
|
art = lart->GetSubChunkAt(++i)) |
215 |
|
{ |
216 |
if (art->GetChunkID() == artCkType) { |
if (art->GetChunkID() == artCkType) { |
217 |
if (!pArticulations) pArticulations = new ArticulationList; |
if (!pArticulations) pArticulations = new ArticulationList; |
218 |
pArticulations->push_back(new Articulation(art)); |
pArticulations->push_back(new Articulation(art)); |
219 |
} |
} |
|
art = lart->GetNextSubChunk(); |
|
220 |
} |
} |
221 |
} |
} |
222 |
} |
} |
557 |
} |
} |
558 |
|
|
559 |
void Resource::GenerateDLSID(dlsid_t* pDLSID) { |
void Resource::GenerateDLSID(dlsid_t* pDLSID) { |
|
#if defined(WIN32) || defined(__APPLE__) || defined(HAVE_UUID_GENERATE) |
|
560 |
#ifdef WIN32 |
#ifdef WIN32 |
561 |
UUID uuid; |
UUID uuid; |
562 |
UuidCreate(&uuid); |
UuidCreate(&uuid); |
581 |
pDLSID->abData[5] = uuid.byte13; |
pDLSID->abData[5] = uuid.byte13; |
582 |
pDLSID->abData[6] = uuid.byte14; |
pDLSID->abData[6] = uuid.byte14; |
583 |
pDLSID->abData[7] = uuid.byte15; |
pDLSID->abData[7] = uuid.byte15; |
584 |
#else |
#elif defined(HAVE_UUID_GENERATE) |
585 |
uuid_t uuid; |
uuid_t uuid; |
586 |
uuid_generate(uuid); |
uuid_generate(uuid); |
587 |
pDLSID->ulData1 = uuid[0] | uuid[1] << 8 | uuid[2] << 16 | uuid[3] << 24; |
pDLSID->ulData1 = uuid[0] | uuid[1] << 8 | uuid[2] << 16 | uuid[3] << 24; |
588 |
pDLSID->usData2 = uuid[4] | uuid[5] << 8; |
pDLSID->usData2 = uuid[4] | uuid[5] << 8; |
589 |
pDLSID->usData3 = uuid[6] | uuid[7] << 8; |
pDLSID->usData3 = uuid[6] | uuid[7] << 8; |
590 |
memcpy(pDLSID->abData, &uuid[8], 8); |
memcpy(pDLSID->abData, &uuid[8], 8); |
591 |
#endif |
#else |
592 |
|
# error "Missing support for uuid generation" |
593 |
#endif |
#endif |
594 |
} |
} |
595 |
|
|
1358 |
pRegions = NULL; |
pRegions = NULL; |
1359 |
} |
} |
1360 |
|
|
1361 |
|
/** |
1362 |
|
* Returns Region at supplied @a pos position within the region list of |
1363 |
|
* this instrument. If supplied @a pos is out of bounds then @c NULL is |
1364 |
|
* returned. |
1365 |
|
* |
1366 |
|
* @param pos - position of sought Region in region list |
1367 |
|
* @returns pointer address to requested region or @c NULL if @a pos is |
1368 |
|
* out of bounds |
1369 |
|
*/ |
1370 |
|
Region* Instrument::GetRegionAt(size_t pos) { |
1371 |
|
if (!pRegions) LoadRegions(); |
1372 |
|
if (!pRegions) return NULL; |
1373 |
|
if (pos >= pRegions->size()) return NULL; |
1374 |
|
return (*pRegions)[pos]; |
1375 |
|
} |
1376 |
|
|
1377 |
|
/** |
1378 |
|
* Returns the first Region of the instrument. You have to call this |
1379 |
|
* method once before you use GetNextRegion(). |
1380 |
|
* |
1381 |
|
* @returns pointer address to first region or NULL if there is none |
1382 |
|
* @see GetNextRegion() |
1383 |
|
* @deprecated This method is not reentrant-safe, use GetRegionAt() |
1384 |
|
* instead. |
1385 |
|
*/ |
1386 |
Region* Instrument::GetFirstRegion() { |
Region* Instrument::GetFirstRegion() { |
1387 |
if (!pRegions) LoadRegions(); |
if (!pRegions) LoadRegions(); |
1388 |
if (!pRegions) return NULL; |
if (!pRegions) return NULL; |
1390 |
return (RegionsIterator != pRegions->end()) ? *RegionsIterator : NULL; |
return (RegionsIterator != pRegions->end()) ? *RegionsIterator : NULL; |
1391 |
} |
} |
1392 |
|
|
1393 |
|
/** |
1394 |
|
* Returns the next Region of the instrument. You have to call |
1395 |
|
* GetFirstRegion() once before you can use this method. By calling this |
1396 |
|
* method multiple times it iterates through the available Regions. |
1397 |
|
* |
1398 |
|
* @returns pointer address to the next region or NULL if end reached |
1399 |
|
* @see GetFirstRegion() |
1400 |
|
* @deprecated This method is not reentrant-safe, use GetRegionAt() |
1401 |
|
* instead. |
1402 |
|
*/ |
1403 |
Region* Instrument::GetNextRegion() { |
Region* Instrument::GetNextRegion() { |
1404 |
if (!pRegions) return NULL; |
if (!pRegions) return NULL; |
1405 |
RegionsIterator++; |
RegionsIterator++; |
1411 |
RIFF::List* lrgn = pCkInstrument->GetSubList(LIST_TYPE_LRGN); |
RIFF::List* lrgn = pCkInstrument->GetSubList(LIST_TYPE_LRGN); |
1412 |
if (lrgn) { |
if (lrgn) { |
1413 |
uint32_t regionCkType = (lrgn->GetSubList(LIST_TYPE_RGN2)) ? LIST_TYPE_RGN2 : LIST_TYPE_RGN; // prefer regions level 2 |
uint32_t regionCkType = (lrgn->GetSubList(LIST_TYPE_RGN2)) ? LIST_TYPE_RGN2 : LIST_TYPE_RGN; // prefer regions level 2 |
1414 |
RIFF::List* rgn = lrgn->GetFirstSubList(); |
size_t i = 0; |
1415 |
while (rgn) { |
for (RIFF::List* rgn = lrgn->GetSubListAt(i); rgn; |
1416 |
|
rgn = lrgn->GetSubListAt(++i)) |
1417 |
|
{ |
1418 |
if (rgn->GetListType() == regionCkType) { |
if (rgn->GetListType() == regionCkType) { |
1419 |
pRegions->push_back(new Region(this, rgn)); |
pRegions->push_back(new Region(this, rgn)); |
1420 |
} |
} |
|
rgn = lrgn->GetNextSubList(); |
|
1421 |
} |
} |
1422 |
} |
} |
1423 |
} |
} |
1436 |
void Instrument::MoveRegion(Region* pSrc, Region* pDst) { |
void Instrument::MoveRegion(Region* pSrc, Region* pDst) { |
1437 |
RIFF::List* lrgn = pCkInstrument->GetSubList(LIST_TYPE_LRGN); |
RIFF::List* lrgn = pCkInstrument->GetSubList(LIST_TYPE_LRGN); |
1438 |
lrgn->MoveSubChunk(pSrc->pCkRegion, (RIFF::Chunk*) (pDst ? pDst->pCkRegion : 0)); |
lrgn->MoveSubChunk(pSrc->pCkRegion, (RIFF::Chunk*) (pDst ? pDst->pCkRegion : 0)); |
1439 |
|
for (size_t i = 0; i < pRegions->size(); ++i) { |
1440 |
pRegions->remove(pSrc); |
if ((*pRegions)[i] == pSrc) { |
1441 |
RegionList::iterator iter = find(pRegions->begin(), pRegions->end(), pDst); |
pRegions->erase(pRegions->begin() + i); |
1442 |
pRegions->insert(iter, pSrc); |
RegionList::iterator iter = find(pRegions->begin(), pRegions->end(), pDst); |
1443 |
|
pRegions->insert(iter, pSrc); |
1444 |
|
} |
1445 |
|
} |
1446 |
} |
} |
1447 |
|
|
1448 |
void Instrument::DeleteRegion(Region* pRegion) { |
void Instrument::DeleteRegion(Region* pRegion) { |
1485 |
RegionList::iterator iter = pRegions->begin(); |
RegionList::iterator iter = pRegions->begin(); |
1486 |
RegionList::iterator end = pRegions->end(); |
RegionList::iterator end = pRegions->end(); |
1487 |
for (int i = 0; iter != end; ++iter, ++i) { |
for (int i = 0; iter != end; ++iter, ++i) { |
1488 |
// divide local progress into subprogress |
if (pProgress) { |
1489 |
progress_t subprogress; |
// divide local progress into subprogress |
1490 |
__divide_progress(pProgress, &subprogress, pRegions->size(), i); |
progress_t subprogress; |
1491 |
// do the actual work |
__divide_progress(pProgress, &subprogress, pRegions->size(), i); |
1492 |
(*iter)->UpdateChunks(&subprogress); |
// do the actual work |
1493 |
|
(*iter)->UpdateChunks(&subprogress); |
1494 |
|
} else |
1495 |
|
(*iter)->UpdateChunks(NULL); |
1496 |
} |
} |
1497 |
__notify_progress(pProgress, 1.0); // notify done |
if (pProgress) |
1498 |
|
__notify_progress(pProgress, 1.0); // notify done |
1499 |
} |
} |
1500 |
|
|
1501 |
/** @brief Destructor. |
/** @brief Destructor. |
1564 |
void Instrument::CopyAssign(const Instrument* orig) { |
void Instrument::CopyAssign(const Instrument* orig) { |
1565 |
CopyAssignCore(orig); |
CopyAssignCore(orig); |
1566 |
// delete all regions first |
// delete all regions first |
1567 |
while (Regions) DeleteRegion(GetFirstRegion()); |
while (Regions) DeleteRegion(GetRegionAt(0)); |
1568 |
// now recreate and copy regions |
// now recreate and copy regions |
1569 |
{ |
{ |
1570 |
RegionList::const_iterator it = orig->pRegions->begin(); |
RegionList::const_iterator it = orig->pRegions->begin(); |
1700 |
delete pRIFF; |
delete pRIFF; |
1701 |
} |
} |
1702 |
|
|
1703 |
|
/** |
1704 |
|
* Returns Sample object of @a index. |
1705 |
|
* |
1706 |
|
* @param index - position of sample in sample list (0..n) |
1707 |
|
* @returns sample object or NULL if index is out of bounds |
1708 |
|
*/ |
1709 |
|
Sample* File::GetSample(size_t index) { |
1710 |
|
if (!pSamples) LoadSamples(); |
1711 |
|
if (!pSamples) return NULL; |
1712 |
|
if (index >= pSamples->size()) return NULL; |
1713 |
|
return (*pSamples)[index]; |
1714 |
|
} |
1715 |
|
|
1716 |
|
/** |
1717 |
|
* Returns a pointer to the first <i>Sample</i> object of the file, |
1718 |
|
* <i>NULL</i> otherwise. |
1719 |
|
* |
1720 |
|
* @deprecated This method is not reentrant-safe, use GetSample() |
1721 |
|
* instead. |
1722 |
|
*/ |
1723 |
Sample* File::GetFirstSample() { |
Sample* File::GetFirstSample() { |
1724 |
if (!pSamples) LoadSamples(); |
if (!pSamples) LoadSamples(); |
1725 |
if (!pSamples) return NULL; |
if (!pSamples) return NULL; |
1727 |
return (SamplesIterator != pSamples->end()) ? *SamplesIterator : NULL; |
return (SamplesIterator != pSamples->end()) ? *SamplesIterator : NULL; |
1728 |
} |
} |
1729 |
|
|
1730 |
|
/** |
1731 |
|
* Returns a pointer to the next <i>Sample</i> object of the file, |
1732 |
|
* <i>NULL</i> otherwise. |
1733 |
|
* |
1734 |
|
* @deprecated This method is not reentrant-safe, use GetSample() |
1735 |
|
* instead. |
1736 |
|
*/ |
1737 |
Sample* File::GetNextSample() { |
Sample* File::GetNextSample() { |
1738 |
if (!pSamples) return NULL; |
if (!pSamples) return NULL; |
1739 |
SamplesIterator++; |
SamplesIterator++; |
1746 |
if (wvpl) { |
if (wvpl) { |
1747 |
file_offset_t wvplFileOffset = wvpl->GetFilePos() - |
file_offset_t wvplFileOffset = wvpl->GetFilePos() - |
1748 |
wvpl->GetPos(); // should be zero, but just to be sure |
wvpl->GetPos(); // should be zero, but just to be sure |
1749 |
RIFF::List* wave = wvpl->GetFirstSubList(); |
size_t i = 0; |
1750 |
while (wave) { |
for (RIFF::List* wave = wvpl->GetSubListAt(i); wave; |
1751 |
|
wave = wvpl->GetSubListAt(++i)) |
1752 |
|
{ |
1753 |
if (wave->GetListType() == LIST_TYPE_WAVE) { |
if (wave->GetListType() == LIST_TYPE_WAVE) { |
1754 |
file_offset_t waveFileOffset = wave->GetFilePos() - |
file_offset_t waveFileOffset = wave->GetFilePos() - |
1755 |
wave->GetPos(); // should be zero, but just to be sure |
wave->GetPos(); // should be zero, but just to be sure |
1756 |
pSamples->push_back(new Sample(this, wave, waveFileOffset - wvplFileOffset)); |
pSamples->push_back(new Sample(this, wave, waveFileOffset - wvplFileOffset)); |
1757 |
} |
} |
|
wave = wvpl->GetNextSubList(); |
|
1758 |
} |
} |
1759 |
} |
} |
1760 |
else { // Seen a dwpl list chunk instead of a wvpl list chunk in some file (officially not DLS compliant) |
else { // Seen a dwpl list chunk instead of a wvpl list chunk in some file (officially not DLS compliant) |
1762 |
if (dwpl) { |
if (dwpl) { |
1763 |
file_offset_t dwplFileOffset = dwpl->GetFilePos() - |
file_offset_t dwplFileOffset = dwpl->GetFilePos() - |
1764 |
dwpl->GetPos(); // should be zero, but just to be sure |
dwpl->GetPos(); // should be zero, but just to be sure |
1765 |
RIFF::List* wave = dwpl->GetFirstSubList(); |
size_t i = 0; |
1766 |
while (wave) { |
for (RIFF::List* wave = dwpl->GetSubListAt(i); wave; |
1767 |
|
wave = dwpl->GetSubListAt(++i)) |
1768 |
|
{ |
1769 |
if (wave->GetListType() == LIST_TYPE_WAVE) { |
if (wave->GetListType() == LIST_TYPE_WAVE) { |
1770 |
file_offset_t waveFileOffset = wave->GetFilePos() - |
file_offset_t waveFileOffset = wave->GetFilePos() - |
1771 |
wave->GetPos(); // should be zero, but just to be sure |
wave->GetPos(); // should be zero, but just to be sure |
1772 |
pSamples->push_back(new Sample(this, wave, waveFileOffset - dwplFileOffset)); |
pSamples->push_back(new Sample(this, wave, waveFileOffset - dwplFileOffset)); |
1773 |
} |
} |
|
wave = dwpl->GetNextSubList(); |
|
1774 |
} |
} |
1775 |
} |
} |
1776 |
} |
} |
1827 |
if (!pInstruments) pInstruments = new InstrumentList; |
if (!pInstruments) pInstruments = new InstrumentList; |
1828 |
RIFF::List* lstInstruments = pRIFF->GetSubList(LIST_TYPE_LINS); |
RIFF::List* lstInstruments = pRIFF->GetSubList(LIST_TYPE_LINS); |
1829 |
if (lstInstruments) { |
if (lstInstruments) { |
1830 |
RIFF::List* lstInstr = lstInstruments->GetFirstSubList(); |
size_t i = 0; |
1831 |
while (lstInstr) { |
for (RIFF::List* lstInstr = lstInstruments->GetSubListAt(i); |
1832 |
|
lstInstr; lstInstr = lstInstruments->GetSubListAt(++i)) |
1833 |
|
{ |
1834 |
if (lstInstr->GetListType() == LIST_TYPE_INS) { |
if (lstInstr->GetListType() == LIST_TYPE_INS) { |
1835 |
pInstruments->push_back(new Instrument(this, lstInstr)); |
pInstruments->push_back(new Instrument(this, lstInstr)); |
1836 |
} |
} |
|
lstInstr = lstInstruments->GetNextSubList(); |
|
1837 |
} |
} |
1838 |
} |
} |
1839 |
} |
} |
1952 |
|
|
1953 |
// update instrument's chunks |
// update instrument's chunks |
1954 |
if (pInstruments) { |
if (pInstruments) { |
1955 |
// divide local progress into subprogress |
if (pProgress) { |
1956 |
progress_t subprogress; |
// divide local progress into subprogress |
1957 |
__divide_progress(pProgress, &subprogress, 20.f, 0.f); // arbitrarily subdivided into 5% of total progress |
progress_t subprogress; |
1958 |
|
__divide_progress(pProgress, &subprogress, 20.f, 0.f); // arbitrarily subdivided into 5% of total progress |
1959 |
|
|
|
// do the actual work |
|
|
InstrumentList::iterator iter = pInstruments->begin(); |
|
|
InstrumentList::iterator end = pInstruments->end(); |
|
|
for (int i = 0; iter != end; ++iter, ++i) { |
|
|
// divide subprogress into sub-subprogress |
|
|
progress_t subsubprogress; |
|
|
__divide_progress(&subprogress, &subsubprogress, pInstruments->size(), i); |
|
1960 |
// do the actual work |
// do the actual work |
1961 |
(*iter)->UpdateChunks(&subsubprogress); |
InstrumentList::iterator iter = pInstruments->begin(); |
1962 |
} |
InstrumentList::iterator end = pInstruments->end(); |
1963 |
|
for (int i = 0; iter != end; ++iter, ++i) { |
1964 |
|
// divide subprogress into sub-subprogress |
1965 |
|
progress_t subsubprogress; |
1966 |
|
__divide_progress(&subprogress, &subsubprogress, pInstruments->size(), i); |
1967 |
|
// do the actual work |
1968 |
|
(*iter)->UpdateChunks(&subsubprogress); |
1969 |
|
} |
1970 |
|
|
1971 |
__notify_progress(&subprogress, 1.0); // notify subprogress done |
__notify_progress(&subprogress, 1.0); // notify subprogress done |
1972 |
|
} else { |
1973 |
|
InstrumentList::iterator iter = pInstruments->begin(); |
1974 |
|
InstrumentList::iterator end = pInstruments->end(); |
1975 |
|
for (int i = 0; iter != end; ++iter, ++i) { |
1976 |
|
(*iter)->UpdateChunks(NULL); |
1977 |
|
} |
1978 |
|
} |
1979 |
} |
} |
1980 |
|
|
1981 |
// update 'ptbl' chunk |
// update 'ptbl' chunk |
1993 |
|
|
1994 |
// update sample's chunks |
// update sample's chunks |
1995 |
if (pSamples) { |
if (pSamples) { |
1996 |
// divide local progress into subprogress |
if (pProgress) { |
1997 |
progress_t subprogress; |
// divide local progress into subprogress |
1998 |
__divide_progress(pProgress, &subprogress, 20.f, 1.f); // arbitrarily subdivided into 95% of total progress |
progress_t subprogress; |
1999 |
|
__divide_progress(pProgress, &subprogress, 20.f, 1.f); // arbitrarily subdivided into 95% of total progress |
2000 |
|
|
|
// do the actual work |
|
|
SampleList::iterator iter = pSamples->begin(); |
|
|
SampleList::iterator end = pSamples->end(); |
|
|
for (int i = 0; iter != end; ++iter, ++i) { |
|
|
// divide subprogress into sub-subprogress |
|
|
progress_t subsubprogress; |
|
|
__divide_progress(&subprogress, &subsubprogress, pSamples->size(), i); |
|
2001 |
// do the actual work |
// do the actual work |
2002 |
(*iter)->UpdateChunks(&subsubprogress); |
SampleList::iterator iter = pSamples->begin(); |
2003 |
} |
SampleList::iterator end = pSamples->end(); |
2004 |
|
for (int i = 0; iter != end; ++iter, ++i) { |
2005 |
|
// divide subprogress into sub-subprogress |
2006 |
|
progress_t subsubprogress; |
2007 |
|
__divide_progress(&subprogress, &subsubprogress, pSamples->size(), i); |
2008 |
|
// do the actual work |
2009 |
|
(*iter)->UpdateChunks(&subsubprogress); |
2010 |
|
} |
2011 |
|
|
2012 |
__notify_progress(&subprogress, 1.0); // notify subprogress done |
__notify_progress(&subprogress, 1.0); // notify subprogress done |
2013 |
|
} else { |
2014 |
|
SampleList::iterator iter = pSamples->begin(); |
2015 |
|
SampleList::iterator end = pSamples->end(); |
2016 |
|
for (int i = 0; iter != end; ++iter, ++i) { |
2017 |
|
(*iter)->UpdateChunks(NULL); |
2018 |
|
} |
2019 |
|
} |
2020 |
} |
} |
2021 |
|
|
2022 |
// if there are any extension files, gather which ones are regular |
// if there are any extension files, gather which ones are regular |
2152 |
ptbl->Resize(iPtblSize); |
ptbl->Resize(iPtblSize); |
2153 |
} |
} |
2154 |
|
|
2155 |
__notify_progress(pProgress, 1.0); // notify done |
if (pProgress) |
2156 |
|
__notify_progress(pProgress, 1.0); // notify done |
2157 |
} |
} |
2158 |
|
|
2159 |
/** @brief Save changes to another file. |
/** @brief Save changes to another file. |
2178 |
// save extension files (if required) |
// save extension files (if required) |
2179 |
if (!ExtensionFiles.empty()) { |
if (!ExtensionFiles.empty()) { |
2180 |
// for assembling path of extension files to be saved to |
// for assembling path of extension files to be saved to |
|
const std::string folder = parentPath(Path); |
|
2181 |
const std::string baseName = pathWithoutExtension(Path); |
const std::string baseName = pathWithoutExtension(Path); |
2182 |
// save the individual extension files |
// save the individual extension files |
2183 |
std::list<RIFF::File*>::iterator it = ExtensionFiles.begin(); |
std::list<RIFF::File*>::iterator it = ExtensionFiles.begin(); |
2184 |
for (int i = 0; it != ExtensionFiles.end(); ++i, ++it) { |
for (int i = 0; it != ExtensionFiles.end(); ++i, ++it) { |
|
// divide local progress into subprogress |
|
|
progress_t subprogress; |
|
|
__divide_progress(pProgress, &subprogress, tasks, 0.f + i); // subdivided into amount of extension files |
|
2185 |
//FIXME: the .gx99 file is always used by GSt for convolution |
//FIXME: the .gx99 file is always used by GSt for convolution |
2186 |
// data (GigaPulse); so we should better detect by subchunk |
// data (GigaPulse); so we should better detect by subchunk |
2187 |
// whether the extension file is intended for convolution |
// whether the extension file is intended for convolution |
2189 |
// not work for saving new gigs created from scratch |
// not work for saving new gigs created from scratch |
2190 |
const std::string oldName = (*it)->GetFileName(); |
const std::string oldName = (*it)->GetFileName(); |
2191 |
const bool isGigaPulseFile = (extensionOfPath(oldName) == "gx99"); |
const bool isGigaPulseFile = (extensionOfPath(oldName) == "gx99"); |
2192 |
std::string ext = (isGigaPulseFile) ? ".gx99" : strPrint(".gx02d", i+1); |
std::string ext = (isGigaPulseFile) ? ".gx99" : strPrint(".gx%02d", i+1); |
2193 |
std::string newPath = concatPath(folder, baseName) + ext; |
std::string newPath = baseName + ext; |
2194 |
// save extension file to its new location |
// save extension file to its new location |
2195 |
(*it)->Save(newPath, &subprogress); |
if (pProgress) { |
2196 |
|
// divide local progress into subprogress |
2197 |
|
progress_t subprogress; |
2198 |
|
__divide_progress(pProgress, &subprogress, tasks, 0.f + i); // subdivided into amount of extension files |
2199 |
|
// do the actual work |
2200 |
|
(*it)->Save(newPath, &subprogress); |
2201 |
|
} else |
2202 |
|
(*it)->Save(newPath); |
2203 |
} |
} |
2204 |
} |
} |
2205 |
|
|
2206 |
{ |
if (pProgress) { |
2207 |
// divide local progress into subprogress |
// divide local progress into subprogress |
2208 |
progress_t subprogress; |
progress_t subprogress; |
2209 |
__divide_progress(pProgress, &subprogress, tasks, 1.f + nExtFiles); // arbitrarily subdivided into 50% (minus extension files progress) |
__divide_progress(pProgress, &subprogress, tasks, 1.f + nExtFiles); // arbitrarily subdivided into 50% (minus extension files progress) |
2210 |
// do the actual work |
// do the actual work |
2211 |
UpdateChunks(&subprogress); |
UpdateChunks(&subprogress); |
2212 |
} |
} else |
2213 |
{ |
UpdateChunks(NULL); |
2214 |
|
|
2215 |
|
if (pProgress) { |
2216 |
// divide local progress into subprogress |
// divide local progress into subprogress |
2217 |
progress_t subprogress; |
progress_t subprogress; |
2218 |
__divide_progress(pProgress, &subprogress, tasks, 2.f + nExtFiles); // arbitrarily subdivided into 50% (minus extension files progress) |
__divide_progress(pProgress, &subprogress, tasks, 2.f + nExtFiles); // arbitrarily subdivided into 50% (minus extension files progress) |
2219 |
// do the actual work |
// do the actual work |
2220 |
pRIFF->Save(Path, &subprogress); |
pRIFF->Save(Path, &subprogress); |
2221 |
} |
} else |
2222 |
|
pRIFF->Save(Path); |
2223 |
|
|
2224 |
UpdateFileOffsets(); |
UpdateFileOffsets(); |
2225 |
__notify_progress(pProgress, 1.0); // notify done |
|
2226 |
|
if (pProgress) |
2227 |
|
__notify_progress(pProgress, 1.0); // notify done |
2228 |
} |
} |
2229 |
|
|
2230 |
/** @brief Save changes to same file. |
/** @brief Save changes to same file. |
2246 |
if (!ExtensionFiles.empty()) { |
if (!ExtensionFiles.empty()) { |
2247 |
std::list<RIFF::File*>::iterator it = ExtensionFiles.begin(); |
std::list<RIFF::File*>::iterator it = ExtensionFiles.begin(); |
2248 |
for (int i = 0; it != ExtensionFiles.end(); ++i, ++it) { |
for (int i = 0; it != ExtensionFiles.end(); ++i, ++it) { |
|
// divide local progress into subprogress |
|
|
progress_t subprogress; |
|
|
__divide_progress(pProgress, &subprogress, tasks, 0.f + i); // subdivided into amount of extension files |
|
2249 |
// save extension file |
// save extension file |
2250 |
(*it)->Save(&subprogress); |
if (pProgress) { |
2251 |
|
// divide local progress into subprogress |
2252 |
|
progress_t subprogress; |
2253 |
|
__divide_progress(pProgress, &subprogress, tasks, 0.f + i); // subdivided into amount of extension files |
2254 |
|
// do the actual work |
2255 |
|
(*it)->Save(&subprogress); |
2256 |
|
} else |
2257 |
|
(*it)->Save(); |
2258 |
} |
} |
2259 |
} |
} |
2260 |
|
|
2261 |
{ |
if (pProgress) { |
2262 |
// divide local progress into subprogress |
// divide local progress into subprogress |
2263 |
progress_t subprogress; |
progress_t subprogress; |
2264 |
__divide_progress(pProgress, &subprogress, tasks, 1.f + nExtFiles); // arbitrarily subdivided into 50% (minus extension files progress) |
__divide_progress(pProgress, &subprogress, tasks, 1.f + nExtFiles); // arbitrarily subdivided into 50% (minus extension files progress) |
2265 |
// do the actual work |
// do the actual work |
2266 |
UpdateChunks(&subprogress); |
UpdateChunks(&subprogress); |
2267 |
} |
} else |
2268 |
{ |
UpdateChunks(NULL); |
2269 |
|
|
2270 |
|
if (pProgress) { |
2271 |
// divide local progress into subprogress |
// divide local progress into subprogress |
2272 |
progress_t subprogress; |
progress_t subprogress; |
2273 |
__divide_progress(pProgress, &subprogress, tasks, 2.f + nExtFiles); // arbitrarily subdivided into 50% (minus extension files progress) |
__divide_progress(pProgress, &subprogress, tasks, 2.f + nExtFiles); // arbitrarily subdivided into 50% (minus extension files progress) |
2274 |
// do the actual work |
// do the actual work |
2275 |
pRIFF->Save(&subprogress); |
pRIFF->Save(&subprogress); |
2276 |
} |
} else |
2277 |
|
pRIFF->Save(); |
2278 |
|
|
2279 |
UpdateFileOffsets(); |
UpdateFileOffsets(); |
2280 |
__notify_progress(pProgress, 1.0); // notify done |
|
2281 |
|
if (pProgress) |
2282 |
|
__notify_progress(pProgress, 1.0); // notify done |
2283 |
} |
} |
2284 |
|
|
2285 |
/** @brief Updates all file offsets stored all over the file. |
/** @brief Updates all file offsets stored all over the file. |