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. |
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. |