122 |
artl->GetChunkID() != CHUNK_ID_ARTL) { |
artl->GetChunkID() != CHUNK_ID_ARTL) { |
123 |
throw DLS::Exception("<artl-ck> or <art2-ck> chunk expected"); |
throw DLS::Exception("<artl-ck> or <art2-ck> chunk expected"); |
124 |
} |
} |
125 |
|
|
126 |
|
artl->SetPos(0); |
127 |
|
|
128 |
HeaderSize = artl->ReadUint32(); |
HeaderSize = artl->ReadUint32(); |
129 |
Connections = artl->ReadUint32(); |
Connections = artl->ReadUint32(); |
130 |
artl->SetPos(HeaderSize); |
artl->SetPos(HeaderSize); |
167 |
} |
} |
168 |
} |
} |
169 |
|
|
170 |
|
/** @brief Remove all RIFF chunks associated with this Articulation object. |
171 |
|
* |
172 |
|
* At the moment Articulation::DeleteChunks() does nothing. It is |
173 |
|
* recommended to call this method explicitly though from deriving classes's |
174 |
|
* own overridden implementation of this method to avoid potential future |
175 |
|
* compatiblity issues. |
176 |
|
* |
177 |
|
* See Storage::DeleteChunks() for details. |
178 |
|
*/ |
179 |
|
void Articulation::DeleteChunks() { |
180 |
|
} |
181 |
|
|
182 |
|
|
183 |
|
|
184 |
// *************** Articulator *************** |
// *************** Articulator *************** |
247 |
} |
} |
248 |
} |
} |
249 |
} |
} |
250 |
|
|
251 |
|
/** @brief Remove all RIFF chunks associated with this Articulator object. |
252 |
|
* |
253 |
|
* See Storage::DeleteChunks() for details. |
254 |
|
*/ |
255 |
|
void Articulator::DeleteChunks() { |
256 |
|
if (pArticulations) { |
257 |
|
ArticulationList::iterator iter = pArticulations->begin(); |
258 |
|
ArticulationList::iterator end = pArticulations->end(); |
259 |
|
for (; iter != end; ++iter) { |
260 |
|
(*iter)->DeleteChunks(); |
261 |
|
} |
262 |
|
} |
263 |
|
} |
264 |
|
|
265 |
/** |
/** |
266 |
* Not yet implemented in this version, since the .gig format does |
* Not yet implemented in this version, since the .gig format does |
267 |
* not need to copy DLS articulators and so far nobody used pure |
* not need to copy DLS articulators and so far nobody used pure |
428 |
SaveString(CHUNK_ID_ISRF, lstINFO, SourceForm, String("")); |
SaveString(CHUNK_ID_ISRF, lstINFO, SourceForm, String("")); |
429 |
SaveString(CHUNK_ID_ITCH, lstINFO, Technician, String("")); |
SaveString(CHUNK_ID_ITCH, lstINFO, Technician, String("")); |
430 |
} |
} |
431 |
|
|
432 |
|
/** @brief Remove all RIFF chunks associated with this Info object. |
433 |
|
* |
434 |
|
* At the moment Info::DeleteChunks() does nothing. It is |
435 |
|
* recommended to call this method explicitly though from deriving classes's |
436 |
|
* own overridden implementation of this method to avoid potential future |
437 |
|
* compatiblity issues. |
438 |
|
* |
439 |
|
* See Storage::DeleteChunks() for details. |
440 |
|
*/ |
441 |
|
void Info::DeleteChunks() { |
442 |
|
} |
443 |
|
|
444 |
/** |
/** |
445 |
* Make a deep copy of the Info object given by @a orig and assign it to |
* Make a deep copy of the Info object given by @a orig and assign it to |
446 |
* this object. |
* this object. |
491 |
|
|
492 |
RIFF::Chunk* ckDLSID = lstResource->GetSubChunk(CHUNK_ID_DLID); |
RIFF::Chunk* ckDLSID = lstResource->GetSubChunk(CHUNK_ID_DLID); |
493 |
if (ckDLSID) { |
if (ckDLSID) { |
494 |
|
ckDLSID->SetPos(0); |
495 |
|
|
496 |
pDLSID = new dlsid_t; |
pDLSID = new dlsid_t; |
497 |
ckDLSID->Read(&pDLSID->ulData1, 1, 4); |
ckDLSID->Read(&pDLSID->ulData1, 1, 4); |
498 |
ckDLSID->Read(&pDLSID->usData2, 1, 2); |
ckDLSID->Read(&pDLSID->usData2, 1, 2); |
507 |
if (pInfo) delete pInfo; |
if (pInfo) delete pInfo; |
508 |
} |
} |
509 |
|
|
510 |
|
/** @brief Remove all RIFF chunks associated with this Resource object. |
511 |
|
* |
512 |
|
* At the moment Resource::DeleteChunks() does nothing. It is recommended |
513 |
|
* to call this method explicitly though from deriving classes's own |
514 |
|
* overridden implementation of this method to avoid potential future |
515 |
|
* compatiblity issues. |
516 |
|
* |
517 |
|
* See Storage::DeleteChunks() for details. |
518 |
|
*/ |
519 |
|
void Resource::DeleteChunks() { |
520 |
|
} |
521 |
|
|
522 |
/** @brief Update chunks with current Resource data. |
/** @brief Update chunks with current Resource data. |
523 |
* |
* |
524 |
* Apply Resource data persistently below the previously given resource |
* Apply Resource data persistently below the previously given resource |
610 |
pParentList = ParentList; |
pParentList = ParentList; |
611 |
RIFF::Chunk* wsmp = ParentList->GetSubChunk(CHUNK_ID_WSMP); |
RIFF::Chunk* wsmp = ParentList->GetSubChunk(CHUNK_ID_WSMP); |
612 |
if (wsmp) { |
if (wsmp) { |
613 |
|
wsmp->SetPos(0); |
614 |
|
|
615 |
uiHeaderSize = wsmp->ReadUint32(); |
uiHeaderSize = wsmp->ReadUint32(); |
616 |
UnityNote = wsmp->ReadUint16(); |
UnityNote = wsmp->ReadUint16(); |
617 |
FineTune = wsmp->ReadInt16(); |
FineTune = wsmp->ReadInt16(); |
686 |
} |
} |
687 |
} |
} |
688 |
|
|
689 |
|
/** @brief Remove all RIFF chunks associated with this Sampler object. |
690 |
|
* |
691 |
|
* At the moment Sampler::DeleteChunks() does nothing. It is |
692 |
|
* recommended to call this method explicitly though from deriving classes's |
693 |
|
* own overridden implementation of this method to avoid potential future |
694 |
|
* compatiblity issues. |
695 |
|
* |
696 |
|
* See Storage::DeleteChunks() for details. |
697 |
|
*/ |
698 |
|
void Sampler::DeleteChunks() { |
699 |
|
} |
700 |
|
|
701 |
/** |
/** |
702 |
* Adds a new sample loop with the provided loop definition. |
* Adds a new sample loop with the provided loop definition. |
703 |
* |
* |
790 |
pCkFormat = waveList->GetSubChunk(CHUNK_ID_FMT); |
pCkFormat = waveList->GetSubChunk(CHUNK_ID_FMT); |
791 |
pCkData = waveList->GetSubChunk(CHUNK_ID_DATA); |
pCkData = waveList->GetSubChunk(CHUNK_ID_DATA); |
792 |
if (pCkFormat) { |
if (pCkFormat) { |
793 |
|
pCkFormat->SetPos(0); |
794 |
|
|
795 |
// common fields |
// common fields |
796 |
FormatTag = pCkFormat->ReadUint16(); |
FormatTag = pCkFormat->ReadUint16(); |
797 |
Channels = pCkFormat->ReadUint16(); |
Channels = pCkFormat->ReadUint16(); |
822 |
|
|
823 |
/** @brief Destructor. |
/** @brief Destructor. |
824 |
* |
* |
825 |
* Removes RIFF chunks associated with this Sample and frees all |
* Frees all memory occupied by this sample. |
|
* memory occupied by this sample. |
|
826 |
*/ |
*/ |
827 |
Sample::~Sample() { |
Sample::~Sample() { |
828 |
RIFF::List* pParent = pWaveList->GetParent(); |
if (pCkData) |
829 |
pParent->DeleteSubChunk(pWaveList); |
pCkData->ReleaseChunkData(); |
830 |
|
if (pCkFormat) |
831 |
|
pCkFormat->ReleaseChunkData(); |
832 |
} |
} |
833 |
|
|
834 |
|
/** @brief Remove all RIFF chunks associated with this Sample object. |
835 |
|
* |
836 |
|
* See Storage::DeleteChunks() for details. |
837 |
|
*/ |
838 |
|
void Sample::DeleteChunks() { |
839 |
|
// handle base class |
840 |
|
Resource::DeleteChunks(); |
841 |
|
|
842 |
|
// handle own RIFF chunks |
843 |
|
if (pWaveList) { |
844 |
|
RIFF::List* pParent = pWaveList->GetParent(); |
845 |
|
pParent->DeleteSubChunk(pWaveList); |
846 |
|
pWaveList = NULL; |
847 |
|
} |
848 |
|
} |
849 |
|
|
850 |
/** |
/** |
851 |
* Make a deep copy of the Sample object given by @a orig (without the |
* Make a deep copy of the Sample object given by @a orig (without the |
852 |
* actual sample waveform data however) and assign it to this object. |
* actual sample waveform data however) and assign it to this object. |
1091 |
// articulation information |
// articulation information |
1092 |
RIFF::Chunk* rgnh = rgnList->GetSubChunk(CHUNK_ID_RGNH); |
RIFF::Chunk* rgnh = rgnList->GetSubChunk(CHUNK_ID_RGNH); |
1093 |
if (rgnh) { |
if (rgnh) { |
1094 |
|
rgnh->SetPos(0); |
1095 |
|
|
1096 |
rgnh->Read(&KeyRange, 2, 2); |
rgnh->Read(&KeyRange, 2, 2); |
1097 |
rgnh->Read(&VelocityRange, 2, 2); |
rgnh->Read(&VelocityRange, 2, 2); |
1098 |
FormatOptionFlags = rgnh->ReadUint16(); |
FormatOptionFlags = rgnh->ReadUint16(); |
1115 |
// sample information |
// sample information |
1116 |
RIFF::Chunk* wlnk = rgnList->GetSubChunk(CHUNK_ID_WLNK); |
RIFF::Chunk* wlnk = rgnList->GetSubChunk(CHUNK_ID_WLNK); |
1117 |
if (wlnk) { |
if (wlnk) { |
1118 |
|
wlnk->SetPos(0); |
1119 |
|
|
1120 |
WaveLinkOptionFlags = wlnk->ReadUint16(); |
WaveLinkOptionFlags = wlnk->ReadUint16(); |
1121 |
PhaseGroup = wlnk->ReadUint16(); |
PhaseGroup = wlnk->ReadUint16(); |
1122 |
Channel = wlnk->ReadUint32(); |
Channel = wlnk->ReadUint32(); |
1135 |
|
|
1136 |
/** @brief Destructor. |
/** @brief Destructor. |
1137 |
* |
* |
1138 |
* Removes RIFF chunks associated with this Region. |
* Intended to free up all memory occupied by this Region object. ATM this |
1139 |
|
* destructor implementation does nothing though. |
1140 |
*/ |
*/ |
1141 |
Region::~Region() { |
Region::~Region() { |
1142 |
RIFF::List* pParent = pCkRegion->GetParent(); |
} |
1143 |
pParent->DeleteSubChunk(pCkRegion); |
|
1144 |
|
/** @brief Remove all RIFF chunks associated with this Region object. |
1145 |
|
* |
1146 |
|
* See Storage::DeleteChunks() for details. |
1147 |
|
*/ |
1148 |
|
void Region::DeleteChunks() { |
1149 |
|
// handle base classes |
1150 |
|
Resource::DeleteChunks(); |
1151 |
|
Articulator::DeleteChunks(); |
1152 |
|
Sampler::DeleteChunks(); |
1153 |
|
|
1154 |
|
// handle own RIFF chunks |
1155 |
|
if (pCkRegion) { |
1156 |
|
RIFF::List* pParent = pCkRegion->GetParent(); |
1157 |
|
pParent->DeleteSubChunk(pCkRegion); |
1158 |
|
pCkRegion = NULL; |
1159 |
|
} |
1160 |
} |
} |
1161 |
|
|
1162 |
Sample* Region::GetSample() { |
Sample* Region::GetSample() { |
1338 |
midi_locale_t locale; |
midi_locale_t locale; |
1339 |
RIFF::Chunk* insh = pCkInstrument->GetSubChunk(CHUNK_ID_INSH); |
RIFF::Chunk* insh = pCkInstrument->GetSubChunk(CHUNK_ID_INSH); |
1340 |
if (insh) { |
if (insh) { |
1341 |
|
insh->SetPos(0); |
1342 |
|
|
1343 |
Regions = insh->ReadUint32(); |
Regions = insh->ReadUint32(); |
1344 |
insh->Read(&locale, 2, 4); |
insh->Read(&locale, 2, 4); |
1345 |
} else { // 'insh' chunk missing |
} else { // 'insh' chunk missing |
1411 |
if (iter == pRegions->end()) return; |
if (iter == pRegions->end()) return; |
1412 |
pRegions->erase(iter); |
pRegions->erase(iter); |
1413 |
Regions = (uint32_t) pRegions->size(); |
Regions = (uint32_t) pRegions->size(); |
1414 |
|
pRegion->DeleteChunks(); |
1415 |
delete pRegion; |
delete pRegion; |
1416 |
} |
} |
1417 |
|
|
1445 |
RegionList::iterator iter = pRegions->begin(); |
RegionList::iterator iter = pRegions->begin(); |
1446 |
RegionList::iterator end = pRegions->end(); |
RegionList::iterator end = pRegions->end(); |
1447 |
for (int i = 0; iter != end; ++iter, ++i) { |
for (int i = 0; iter != end; ++iter, ++i) { |
1448 |
// divide local progress into subprogress |
if (pProgress) { |
1449 |
progress_t subprogress; |
// divide local progress into subprogress |
1450 |
__divide_progress(pProgress, &subprogress, pRegions->size(), i); |
progress_t subprogress; |
1451 |
// do the actual work |
__divide_progress(pProgress, &subprogress, pRegions->size(), i); |
1452 |
(*iter)->UpdateChunks(&subprogress); |
// do the actual work |
1453 |
|
(*iter)->UpdateChunks(&subprogress); |
1454 |
|
} else |
1455 |
|
(*iter)->UpdateChunks(NULL); |
1456 |
} |
} |
1457 |
__notify_progress(pProgress, 1.0); // notify done |
if (pProgress) |
1458 |
|
__notify_progress(pProgress, 1.0); // notify done |
1459 |
} |
} |
1460 |
|
|
1461 |
/** @brief Destructor. |
/** @brief Destructor. |
1462 |
* |
* |
1463 |
* Removes RIFF chunks associated with this Instrument and frees all |
* Frees all memory occupied by this instrument. |
|
* memory occupied by this instrument. |
|
1464 |
*/ |
*/ |
1465 |
Instrument::~Instrument() { |
Instrument::~Instrument() { |
1466 |
if (pRegions) { |
if (pRegions) { |
1472 |
} |
} |
1473 |
delete pRegions; |
delete pRegions; |
1474 |
} |
} |
|
// remove instrument's chunks |
|
|
RIFF::List* pParent = pCkInstrument->GetParent(); |
|
|
pParent->DeleteSubChunk(pCkInstrument); |
|
1475 |
} |
} |
1476 |
|
|
1477 |
|
/** @brief Remove all RIFF chunks associated with this Instrument object. |
1478 |
|
* |
1479 |
|
* See Storage::DeleteChunks() for details. |
1480 |
|
*/ |
1481 |
|
void Instrument::DeleteChunks() { |
1482 |
|
// handle base classes |
1483 |
|
Resource::DeleteChunks(); |
1484 |
|
Articulator::DeleteChunks(); |
1485 |
|
|
1486 |
|
// handle RIFF chunks of members |
1487 |
|
if (pRegions) { |
1488 |
|
RegionList::iterator it = pRegions->begin(); |
1489 |
|
RegionList::iterator end = pRegions->end(); |
1490 |
|
for (; it != end; ++it) |
1491 |
|
(*it)->DeleteChunks(); |
1492 |
|
} |
1493 |
|
|
1494 |
|
// handle own RIFF chunks |
1495 |
|
if (pCkInstrument) { |
1496 |
|
RIFF::List* pParent = pCkInstrument->GetParent(); |
1497 |
|
pParent->DeleteSubChunk(pCkInstrument); |
1498 |
|
pCkInstrument = NULL; |
1499 |
|
} |
1500 |
|
} |
1501 |
|
|
1502 |
void Instrument::CopyAssignCore(const Instrument* orig) { |
void Instrument::CopyAssignCore(const Instrument* orig) { |
1503 |
// handle base classes |
// handle base classes |
1504 |
Resource::CopyAssign(orig); |
Resource::CopyAssign(orig); |
1582 |
bOwningRiff = false; |
bOwningRiff = false; |
1583 |
RIFF::Chunk* ckVersion = pRIFF->GetSubChunk(CHUNK_ID_VERS); |
RIFF::Chunk* ckVersion = pRIFF->GetSubChunk(CHUNK_ID_VERS); |
1584 |
if (ckVersion) { |
if (ckVersion) { |
1585 |
|
ckVersion->SetPos(0); |
1586 |
|
|
1587 |
pVersion = new version_t; |
pVersion = new version_t; |
1588 |
ckVersion->Read(pVersion, 4, 2); |
ckVersion->Read(pVersion, 4, 2); |
1589 |
} |
} |
1591 |
|
|
1592 |
RIFF::Chunk* colh = pRIFF->GetSubChunk(CHUNK_ID_COLH); |
RIFF::Chunk* colh = pRIFF->GetSubChunk(CHUNK_ID_COLH); |
1593 |
if (!colh) throw DLS::Exception("Mandatory chunks in RIFF list chunk not found."); |
if (!colh) throw DLS::Exception("Mandatory chunks in RIFF list chunk not found."); |
1594 |
|
colh->SetPos(0); |
1595 |
Instruments = colh->ReadUint32(); |
Instruments = colh->ReadUint32(); |
1596 |
|
|
1597 |
RIFF::Chunk* ptbl = pRIFF->GetSubChunk(CHUNK_ID_PTBL); |
RIFF::Chunk* ptbl = pRIFF->GetSubChunk(CHUNK_ID_PTBL); |
1602 |
WavePoolHeaderSize = 8; |
WavePoolHeaderSize = 8; |
1603 |
b64BitWavePoolOffsets = false; |
b64BitWavePoolOffsets = false; |
1604 |
} else { |
} else { |
1605 |
|
ptbl->SetPos(0); |
1606 |
|
|
1607 |
WavePoolHeaderSize = ptbl->ReadUint32(); |
WavePoolHeaderSize = ptbl->ReadUint32(); |
1608 |
WavePoolCount = ptbl->ReadUint32(); |
WavePoolCount = ptbl->ReadUint32(); |
1609 |
pWavePoolTable = new uint32_t[WavePoolCount]; |
pWavePoolTable = new uint32_t[WavePoolCount]; |
1677 |
if (!pSamples) pSamples = new SampleList; |
if (!pSamples) pSamples = new SampleList; |
1678 |
RIFF::List* wvpl = pRIFF->GetSubList(LIST_TYPE_WVPL); |
RIFF::List* wvpl = pRIFF->GetSubList(LIST_TYPE_WVPL); |
1679 |
if (wvpl) { |
if (wvpl) { |
1680 |
file_offset_t wvplFileOffset = wvpl->GetFilePos(); |
file_offset_t wvplFileOffset = wvpl->GetFilePos() - |
1681 |
|
wvpl->GetPos(); // should be zero, but just to be sure |
1682 |
RIFF::List* wave = wvpl->GetFirstSubList(); |
RIFF::List* wave = wvpl->GetFirstSubList(); |
1683 |
while (wave) { |
while (wave) { |
1684 |
if (wave->GetListType() == LIST_TYPE_WAVE) { |
if (wave->GetListType() == LIST_TYPE_WAVE) { |
1685 |
file_offset_t waveFileOffset = wave->GetFilePos(); |
file_offset_t waveFileOffset = wave->GetFilePos() - |
1686 |
|
wave->GetPos(); // should be zero, but just to be sure |
1687 |
pSamples->push_back(new Sample(this, wave, waveFileOffset - wvplFileOffset)); |
pSamples->push_back(new Sample(this, wave, waveFileOffset - wvplFileOffset)); |
1688 |
} |
} |
1689 |
wave = wvpl->GetNextSubList(); |
wave = wvpl->GetNextSubList(); |
1692 |
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) |
1693 |
RIFF::List* dwpl = pRIFF->GetSubList(LIST_TYPE_DWPL); |
RIFF::List* dwpl = pRIFF->GetSubList(LIST_TYPE_DWPL); |
1694 |
if (dwpl) { |
if (dwpl) { |
1695 |
file_offset_t dwplFileOffset = dwpl->GetFilePos(); |
file_offset_t dwplFileOffset = dwpl->GetFilePos() - |
1696 |
|
dwpl->GetPos(); // should be zero, but just to be sure |
1697 |
RIFF::List* wave = dwpl->GetFirstSubList(); |
RIFF::List* wave = dwpl->GetFirstSubList(); |
1698 |
while (wave) { |
while (wave) { |
1699 |
if (wave->GetListType() == LIST_TYPE_WAVE) { |
if (wave->GetListType() == LIST_TYPE_WAVE) { |
1700 |
file_offset_t waveFileOffset = wave->GetFilePos(); |
file_offset_t waveFileOffset = wave->GetFilePos() - |
1701 |
|
wave->GetPos(); // should be zero, but just to be sure |
1702 |
pSamples->push_back(new Sample(this, wave, waveFileOffset - dwplFileOffset)); |
pSamples->push_back(new Sample(this, wave, waveFileOffset - dwplFileOffset)); |
1703 |
} |
} |
1704 |
wave = dwpl->GetNextSubList(); |
wave = dwpl->GetNextSubList(); |
1737 |
SampleList::iterator iter = find(pSamples->begin(), pSamples->end(), pSample); |
SampleList::iterator iter = find(pSamples->begin(), pSamples->end(), pSample); |
1738 |
if (iter == pSamples->end()) return; |
if (iter == pSamples->end()) return; |
1739 |
pSamples->erase(iter); |
pSamples->erase(iter); |
1740 |
|
pSample->DeleteChunks(); |
1741 |
delete pSample; |
delete pSample; |
1742 |
} |
} |
1743 |
|
|
1797 |
InstrumentList::iterator iter = find(pInstruments->begin(), pInstruments->end(), pInstrument); |
InstrumentList::iterator iter = find(pInstruments->begin(), pInstruments->end(), pInstrument); |
1798 |
if (iter == pInstruments->end()) return; |
if (iter == pInstruments->end()) return; |
1799 |
pInstruments->erase(iter); |
pInstruments->erase(iter); |
1800 |
|
pInstrument->DeleteChunks(); |
1801 |
delete pInstrument; |
delete pInstrument; |
1802 |
} |
} |
1803 |
|
|
1804 |
/** |
/** |
1805 |
|
* Returns the underlying RIFF::File used for persistency of this DLS::File |
1806 |
|
* object. |
1807 |
|
*/ |
1808 |
|
RIFF::File* File::GetRiffFile() { |
1809 |
|
return pRIFF; |
1810 |
|
} |
1811 |
|
|
1812 |
|
/** |
1813 |
* Returns extension file of given index. Extension files are used |
* Returns extension file of given index. Extension files are used |
1814 |
* sometimes to circumvent the 2 GB file size limit of the RIFF format and |
* sometimes to circumvent the 2 GB file size limit of the RIFF format and |
1815 |
* of certain operating systems in general. In this case, instead of just |
* of certain operating systems in general. In this case, instead of just |
1882 |
|
|
1883 |
// update instrument's chunks |
// update instrument's chunks |
1884 |
if (pInstruments) { |
if (pInstruments) { |
1885 |
// divide local progress into subprogress |
if (pProgress) { |
1886 |
progress_t subprogress; |
// divide local progress into subprogress |
1887 |
__divide_progress(pProgress, &subprogress, 20.f, 0.f); // arbitrarily subdivided into 5% of total progress |
progress_t subprogress; |
1888 |
|
__divide_progress(pProgress, &subprogress, 20.f, 0.f); // arbitrarily subdivided into 5% of total progress |
1889 |
|
|
|
// 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); |
|
1890 |
// do the actual work |
// do the actual work |
1891 |
(*iter)->UpdateChunks(&subsubprogress); |
InstrumentList::iterator iter = pInstruments->begin(); |
1892 |
} |
InstrumentList::iterator end = pInstruments->end(); |
1893 |
|
for (int i = 0; iter != end; ++iter, ++i) { |
1894 |
|
// divide subprogress into sub-subprogress |
1895 |
|
progress_t subsubprogress; |
1896 |
|
__divide_progress(&subprogress, &subsubprogress, pInstruments->size(), i); |
1897 |
|
// do the actual work |
1898 |
|
(*iter)->UpdateChunks(&subsubprogress); |
1899 |
|
} |
1900 |
|
|
1901 |
__notify_progress(&subprogress, 1.0); // notify subprogress done |
__notify_progress(&subprogress, 1.0); // notify subprogress done |
1902 |
|
} else { |
1903 |
|
InstrumentList::iterator iter = pInstruments->begin(); |
1904 |
|
InstrumentList::iterator end = pInstruments->end(); |
1905 |
|
for (int i = 0; iter != end; ++iter, ++i) { |
1906 |
|
(*iter)->UpdateChunks(NULL); |
1907 |
|
} |
1908 |
|
} |
1909 |
} |
} |
1910 |
|
|
1911 |
// update 'ptbl' chunk |
// update 'ptbl' chunk |
1923 |
|
|
1924 |
// update sample's chunks |
// update sample's chunks |
1925 |
if (pSamples) { |
if (pSamples) { |
1926 |
// divide local progress into subprogress |
if (pProgress) { |
1927 |
progress_t subprogress; |
// divide local progress into subprogress |
1928 |
__divide_progress(pProgress, &subprogress, 20.f, 1.f); // arbitrarily subdivided into 95% of total progress |
progress_t subprogress; |
1929 |
|
__divide_progress(pProgress, &subprogress, 20.f, 1.f); // arbitrarily subdivided into 95% of total progress |
1930 |
|
|
|
// 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); |
|
1931 |
// do the actual work |
// do the actual work |
1932 |
(*iter)->UpdateChunks(&subsubprogress); |
SampleList::iterator iter = pSamples->begin(); |
1933 |
} |
SampleList::iterator end = pSamples->end(); |
1934 |
|
for (int i = 0; iter != end; ++iter, ++i) { |
1935 |
|
// divide subprogress into sub-subprogress |
1936 |
|
progress_t subsubprogress; |
1937 |
|
__divide_progress(&subprogress, &subsubprogress, pSamples->size(), i); |
1938 |
|
// do the actual work |
1939 |
|
(*iter)->UpdateChunks(&subsubprogress); |
1940 |
|
} |
1941 |
|
|
1942 |
__notify_progress(&subprogress, 1.0); // notify subprogress done |
__notify_progress(&subprogress, 1.0); // notify subprogress done |
1943 |
|
} else { |
1944 |
|
SampleList::iterator iter = pSamples->begin(); |
1945 |
|
SampleList::iterator end = pSamples->end(); |
1946 |
|
for (int i = 0; iter != end; ++iter, ++i) { |
1947 |
|
(*iter)->UpdateChunks(NULL); |
1948 |
|
} |
1949 |
|
} |
1950 |
} |
} |
1951 |
|
|
1952 |
// if there are any extension files, gather which ones are regular |
// if there are any extension files, gather which ones are regular |
2082 |
ptbl->Resize(iPtblSize); |
ptbl->Resize(iPtblSize); |
2083 |
} |
} |
2084 |
|
|
2085 |
__notify_progress(pProgress, 1.0); // notify done |
if (pProgress) |
2086 |
|
__notify_progress(pProgress, 1.0); // notify done |
2087 |
} |
} |
2088 |
|
|
2089 |
/** @brief Save changes to another file. |
/** @brief Save changes to another file. |
2108 |
// save extension files (if required) |
// save extension files (if required) |
2109 |
if (!ExtensionFiles.empty()) { |
if (!ExtensionFiles.empty()) { |
2110 |
// 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); |
|
2111 |
const std::string baseName = pathWithoutExtension(Path); |
const std::string baseName = pathWithoutExtension(Path); |
2112 |
// save the individual extension files |
// save the individual extension files |
2113 |
std::list<RIFF::File*>::iterator it = ExtensionFiles.begin(); |
std::list<RIFF::File*>::iterator it = ExtensionFiles.begin(); |
2114 |
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 |
|
2115 |
//FIXME: the .gx99 file is always used by GSt for convolution |
//FIXME: the .gx99 file is always used by GSt for convolution |
2116 |
// data (GigaPulse); so we should better detect by subchunk |
// data (GigaPulse); so we should better detect by subchunk |
2117 |
// whether the extension file is intended for convolution |
// whether the extension file is intended for convolution |
2119 |
// not work for saving new gigs created from scratch |
// not work for saving new gigs created from scratch |
2120 |
const std::string oldName = (*it)->GetFileName(); |
const std::string oldName = (*it)->GetFileName(); |
2121 |
const bool isGigaPulseFile = (extensionOfPath(oldName) == "gx99"); |
const bool isGigaPulseFile = (extensionOfPath(oldName) == "gx99"); |
2122 |
std::string ext = (isGigaPulseFile) ? ".gx99" : strPrint(".gx02d", i+1); |
std::string ext = (isGigaPulseFile) ? ".gx99" : strPrint(".gx%02d", i+1); |
2123 |
std::string newPath = concatPath(folder, baseName) + ext; |
std::string newPath = baseName + ext; |
2124 |
// save extension file to its new location |
// save extension file to its new location |
2125 |
(*it)->Save(newPath, &subprogress); |
if (pProgress) { |
2126 |
|
// divide local progress into subprogress |
2127 |
|
progress_t subprogress; |
2128 |
|
__divide_progress(pProgress, &subprogress, tasks, 0.f + i); // subdivided into amount of extension files |
2129 |
|
// do the actual work |
2130 |
|
(*it)->Save(newPath, &subprogress); |
2131 |
|
} else |
2132 |
|
(*it)->Save(newPath); |
2133 |
} |
} |
2134 |
} |
} |
2135 |
|
|
2136 |
{ |
if (pProgress) { |
2137 |
// divide local progress into subprogress |
// divide local progress into subprogress |
2138 |
progress_t subprogress; |
progress_t subprogress; |
2139 |
__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) |
2140 |
// do the actual work |
// do the actual work |
2141 |
UpdateChunks(&subprogress); |
UpdateChunks(&subprogress); |
2142 |
} |
} else |
2143 |
{ |
UpdateChunks(NULL); |
2144 |
|
|
2145 |
|
if (pProgress) { |
2146 |
// divide local progress into subprogress |
// divide local progress into subprogress |
2147 |
progress_t subprogress; |
progress_t subprogress; |
2148 |
__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) |
2149 |
// do the actual work |
// do the actual work |
2150 |
pRIFF->Save(Path, &subprogress); |
pRIFF->Save(Path, &subprogress); |
2151 |
} |
} else |
2152 |
|
pRIFF->Save(Path); |
2153 |
|
|
2154 |
UpdateFileOffsets(); |
UpdateFileOffsets(); |
2155 |
__notify_progress(pProgress, 1.0); // notify done |
|
2156 |
|
if (pProgress) |
2157 |
|
__notify_progress(pProgress, 1.0); // notify done |
2158 |
} |
} |
2159 |
|
|
2160 |
/** @brief Save changes to same file. |
/** @brief Save changes to same file. |
2176 |
if (!ExtensionFiles.empty()) { |
if (!ExtensionFiles.empty()) { |
2177 |
std::list<RIFF::File*>::iterator it = ExtensionFiles.begin(); |
std::list<RIFF::File*>::iterator it = ExtensionFiles.begin(); |
2178 |
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 |
|
2179 |
// save extension file |
// save extension file |
2180 |
(*it)->Save(&subprogress); |
if (pProgress) { |
2181 |
|
// divide local progress into subprogress |
2182 |
|
progress_t subprogress; |
2183 |
|
__divide_progress(pProgress, &subprogress, tasks, 0.f + i); // subdivided into amount of extension files |
2184 |
|
// do the actual work |
2185 |
|
(*it)->Save(&subprogress); |
2186 |
|
} else |
2187 |
|
(*it)->Save(); |
2188 |
} |
} |
2189 |
} |
} |
2190 |
|
|
2191 |
{ |
if (pProgress) { |
2192 |
// divide local progress into subprogress |
// divide local progress into subprogress |
2193 |
progress_t subprogress; |
progress_t subprogress; |
2194 |
__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) |
2195 |
// do the actual work |
// do the actual work |
2196 |
UpdateChunks(&subprogress); |
UpdateChunks(&subprogress); |
2197 |
} |
} else |
2198 |
{ |
UpdateChunks(NULL); |
2199 |
|
|
2200 |
|
if (pProgress) { |
2201 |
// divide local progress into subprogress |
// divide local progress into subprogress |
2202 |
progress_t subprogress; |
progress_t subprogress; |
2203 |
__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) |
2204 |
// do the actual work |
// do the actual work |
2205 |
pRIFF->Save(&subprogress); |
pRIFF->Save(&subprogress); |
2206 |
} |
} else |
2207 |
|
pRIFF->Save(); |
2208 |
|
|
2209 |
UpdateFileOffsets(); |
UpdateFileOffsets(); |
2210 |
__notify_progress(pProgress, 1.0); // notify done |
|
2211 |
|
if (pProgress) |
2212 |
|
__notify_progress(pProgress, 1.0); // notify done |
2213 |
} |
} |
2214 |
|
|
2215 |
/** @brief Updates all file offsets stored all over the file. |
/** @brief Updates all file offsets stored all over the file. |
2305 |
if (!pSamples) return; |
if (!pSamples) return; |
2306 |
// update offsets in wave pool table |
// update offsets in wave pool table |
2307 |
RIFF::List* wvpl = pRIFF->GetSubList(LIST_TYPE_WVPL); |
RIFF::List* wvpl = pRIFF->GetSubList(LIST_TYPE_WVPL); |
2308 |
uint64_t wvplFileOffset = wvpl->GetFilePos(); |
uint64_t wvplFileOffset = wvpl->GetFilePos() - |
2309 |
|
wvpl->GetPos(); // mandatory, since position might have changed |
2310 |
if (!b64BitWavePoolOffsets) { // conventional 32 bit offsets (and no extension files) ... |
if (!b64BitWavePoolOffsets) { // conventional 32 bit offsets (and no extension files) ... |
2311 |
SampleList::iterator iter = pSamples->begin(); |
SampleList::iterator iter = pSamples->begin(); |
2312 |
SampleList::iterator end = pSamples->end(); |
SampleList::iterator end = pSamples->end(); |
2313 |
for (int i = 0 ; iter != end ; ++iter, i++) { |
for (int i = 0 ; iter != end ; ++iter, i++) { |
2314 |
uint64_t _64BitOffset = (*iter)->pWaveList->GetFilePos() - wvplFileOffset - LIST_HEADER_SIZE(pRIFF->GetFileOffsetSize()); |
uint64_t _64BitOffset = |
2315 |
|
(*iter)->pWaveList->GetFilePos() - |
2316 |
|
(*iter)->pWaveList->GetPos() - // should be zero, but just to be sure |
2317 |
|
wvplFileOffset - |
2318 |
|
LIST_HEADER_SIZE(pRIFF->GetFileOffsetSize()); |
2319 |
(*iter)->ullWavePoolOffset = _64BitOffset; |
(*iter)->ullWavePoolOffset = _64BitOffset; |
2320 |
pWavePoolTable[i] = (uint32_t) _64BitOffset; |
pWavePoolTable[i] = (uint32_t) _64BitOffset; |
2321 |
} |
} |
2324 |
SampleList::iterator iter = pSamples->begin(); |
SampleList::iterator iter = pSamples->begin(); |
2325 |
SampleList::iterator end = pSamples->end(); |
SampleList::iterator end = pSamples->end(); |
2326 |
for (int i = 0 ; iter != end ; ++iter, i++) { |
for (int i = 0 ; iter != end ; ++iter, i++) { |
2327 |
uint64_t _64BitOffset = (*iter)->pWaveList->GetFilePos() - wvplFileOffset - LIST_HEADER_SIZE(pRIFF->GetFileOffsetSize()); |
uint64_t _64BitOffset = |
2328 |
|
(*iter)->pWaveList->GetFilePos() - |
2329 |
|
(*iter)->pWaveList->GetPos() - // should be zero, but just to be sure |
2330 |
|
wvplFileOffset - |
2331 |
|
LIST_HEADER_SIZE(pRIFF->GetFileOffsetSize()); |
2332 |
(*iter)->ullWavePoolOffset = _64BitOffset; |
(*iter)->ullWavePoolOffset = _64BitOffset; |
2333 |
pWavePoolTableHi[i] = (uint32_t) (_64BitOffset >> 32); |
pWavePoolTableHi[i] = (uint32_t) (_64BitOffset >> 32); |
2334 |
pWavePoolTable[i] = (uint32_t) _64BitOffset; |
pWavePoolTable[i] = (uint32_t) _64BitOffset; |
2361 |
RIFF::List* extWvpl = pCurPoolFile->GetSubList(LIST_TYPE_WVPL); |
RIFF::List* extWvpl = pCurPoolFile->GetSubList(LIST_TYPE_WVPL); |
2362 |
if (!extWvpl) |
if (!extWvpl) |
2363 |
throw DLS::Exception("Fatal error, pool file has no 'wvpl' list chunk"); |
throw DLS::Exception("Fatal error, pool file has no 'wvpl' list chunk"); |
2364 |
waveOffset = extWvpl->GetFilePos() + LIST_HEADER_SIZE(pCurPoolFile->GetFileOffsetSize()); |
waveOffset = |
2365 |
|
extWvpl->GetFilePos() - |
2366 |
|
extWvpl->GetPos() + // mandatory, since position might have changed |
2367 |
|
LIST_HEADER_SIZE(pCurPoolFile->GetFileOffsetSize()); |
2368 |
} |
} |
2369 |
uint64_t _64BitOffset = (*iter)->pWaveList->GetFilePos() - waveOffset; |
uint64_t _64BitOffset = |
2370 |
|
(*iter)->pWaveList->GetFilePos() - |
2371 |
|
(*iter)->pWaveList->GetPos() - // should be zero, but just to be sure |
2372 |
|
waveOffset; |
2373 |
// pWavePoolTableHi stores file number when extension files are in use |
// pWavePoolTableHi stores file number when extension files are in use |
2374 |
pWavePoolTableHi[i] = (uint32_t) fileNo; |
pWavePoolTableHi[i] = (uint32_t) fileNo; |
2375 |
pWavePoolTable[i] = (uint32_t) _64BitOffset; |
pWavePoolTable[i] = (uint32_t) _64BitOffset; |