609 |
uint16_t iSampleGroup = 0; // 0 refers to default sample group |
uint16_t iSampleGroup = 0; // 0 refers to default sample group |
610 |
File* pFile = static_cast<File*>(pParent); |
File* pFile = static_cast<File*>(pParent); |
611 |
if (pFile->pGroups) { |
if (pFile->pGroups) { |
612 |
std::list<Group*>::iterator iter = pFile->pGroups->begin(); |
std::vector<Group*>::iterator iter = pFile->pGroups->begin(); |
613 |
std::list<Group*>::iterator end = pFile->pGroups->end(); |
std::vector<Group*>::iterator end = pFile->pGroups->end(); |
614 |
for (int i = 0; iter != end; i++, iter++) { |
for (int i = 0; iter != end; i++, iter++) { |
615 |
if (*iter == pGroup) { |
if (*iter == pGroup) { |
616 |
iSampleGroup = i; |
iSampleGroup = i; |
4325 |
uint64_t soughtoffset = |
uint64_t soughtoffset = |
4326 |
uint64_t(file->pWavePoolTable[WavePoolTableIndex]) | |
uint64_t(file->pWavePoolTable[WavePoolTableIndex]) | |
4327 |
uint64_t(file->pWavePoolTableHi[WavePoolTableIndex]) << 32; |
uint64_t(file->pWavePoolTableHi[WavePoolTableIndex]) << 32; |
4328 |
Sample* sample = file->GetFirstSample(pProgress); |
size_t i = 0; |
4329 |
while (sample) { |
for (Sample* sample = file->GetSample(i, pProgress); sample; |
4330 |
|
sample = file->GetSample(++i)) |
4331 |
|
{ |
4332 |
if (sample->ullWavePoolOffset == soughtoffset) |
if (sample->ullWavePoolOffset == soughtoffset) |
4333 |
return static_cast<gig::Sample*>(sample); |
return sample; |
|
sample = file->GetNextSample(); |
|
4334 |
} |
} |
4335 |
} else { |
} else { |
4336 |
// use extension files and 32 bit wave pool offsets |
// use extension files and 32 bit wave pool offsets |
4337 |
file_offset_t soughtoffset = file->pWavePoolTable[WavePoolTableIndex]; |
file_offset_t soughtoffset = file->pWavePoolTable[WavePoolTableIndex]; |
4338 |
file_offset_t soughtfileno = file->pWavePoolTableHi[WavePoolTableIndex]; |
file_offset_t soughtfileno = file->pWavePoolTableHi[WavePoolTableIndex]; |
4339 |
Sample* sample = file->GetFirstSample(pProgress); |
size_t i = 0; |
4340 |
while (sample) { |
for (Sample* sample = file->GetSample(i, pProgress); sample; |
4341 |
|
sample = file->GetSample(++i)) |
4342 |
|
{ |
4343 |
if (sample->ullWavePoolOffset == soughtoffset && |
if (sample->ullWavePoolOffset == soughtoffset && |
4344 |
sample->FileNo == soughtfileno) return static_cast<gig::Sample*>(sample); |
sample->FileNo == soughtfileno) return sample; |
|
sample = file->GetNextSample(); |
|
4345 |
} |
} |
4346 |
} |
} |
4347 |
return NULL; |
return NULL; |
5394 |
* @param dst - destination instrument at which this instrument will be |
* @param dst - destination instrument at which this instrument will be |
5395 |
* moved to, or pass NULL for moving to end of list |
* moved to, or pass NULL for moving to end of list |
5396 |
* @throw gig::Exception if this instrument and target instrument are not |
* @throw gig::Exception if this instrument and target instrument are not |
5397 |
* part of the same file |
* part of the same file, as well as on unexpected |
5398 |
|
* internal error |
5399 |
*/ |
*/ |
5400 |
void Instrument::MoveTo(Instrument* dst) { |
void Instrument::MoveTo(Instrument* dst) { |
5401 |
if (dst && GetParent() != dst->GetParent()) |
if (dst && GetParent() != dst->GetParent()) |
5412 |
|
|
5413 |
File::InstrumentList::iterator itFrom = |
File::InstrumentList::iterator itFrom = |
5414 |
std::find(list.begin(), list.end(), static_cast<DLS::Instrument*>(this)); |
std::find(list.begin(), list.end(), static_cast<DLS::Instrument*>(this)); |
5415 |
|
if (itFrom == list.end()) |
5416 |
|
throw Exception( |
5417 |
|
"gig::Instrument::MoveTo(): unexpected missing membership " |
5418 |
|
"of this instrument." |
5419 |
|
); |
5420 |
|
list.erase(itFrom); |
5421 |
|
|
5422 |
File::InstrumentList::iterator itTo = |
File::InstrumentList::iterator itTo = |
5423 |
std::find(list.begin(), list.end(), static_cast<DLS::Instrument*>(dst)); |
std::find(list.begin(), list.end(), static_cast<DLS::Instrument*>(dst)); |
5424 |
|
|
5425 |
list.splice(itTo, list, itFrom); |
list.insert(itTo, this); |
5426 |
} |
} |
5427 |
|
|
5428 |
// move the instrument's actual list RIFF chunk appropriately |
// move the instrument's actual list RIFF chunk appropriately |
6014 |
pMidiRules[0] = NULL; |
pMidiRules[0] = NULL; |
6015 |
|
|
6016 |
// delete all old regions |
// delete all old regions |
6017 |
while (Regions) DeleteRegion(GetFirstRegion()); |
while (Regions) DeleteRegion(GetRegionAt(0)); |
6018 |
// create new regions and copy them from original |
// create new regions and copy them from original |
6019 |
{ |
{ |
6020 |
RegionList::const_iterator it = orig->pRegions->begin(); |
RegionList::const_iterator it = orig->pRegions->begin(); |
6070 |
Group::Group(File* file, RIFF::Chunk* ck3gnm) { |
Group::Group(File* file, RIFF::Chunk* ck3gnm) { |
6071 |
pFile = file; |
pFile = file; |
6072 |
pNameChunk = ck3gnm; |
pNameChunk = ck3gnm; |
6073 |
|
SamplesIterator = 0; |
6074 |
::LoadString(pNameChunk, Name); |
::LoadString(pNameChunk, Name); |
6075 |
} |
} |
6076 |
|
|
6129 |
} |
} |
6130 |
|
|
6131 |
/** |
/** |
6132 |
|
* Returns Sample object at @a index of this sample group. |
6133 |
|
* |
6134 |
|
* @param index - position of sample in this sample group's sample list |
6135 |
|
* (0..n) |
6136 |
|
* @returns sample object or NULL if index is out of bounds |
6137 |
|
*/ |
6138 |
|
Sample* Group::GetSample(size_t index) { |
6139 |
|
if (pFile->pSamples && index >= pFile->pSamples->size()) return NULL; |
6140 |
|
size_t indexInFile = 0; |
6141 |
|
size_t indexInGroup = 0; |
6142 |
|
for (Sample* pSample = pFile->GetSample(indexInFile); pSample; |
6143 |
|
pSample = pFile->GetSample(++indexInFile)) |
6144 |
|
{ |
6145 |
|
if (pSample->GetGroup() != this) continue; |
6146 |
|
if (indexInGroup++ == index) return pSample; |
6147 |
|
} |
6148 |
|
return NULL; |
6149 |
|
} |
6150 |
|
|
6151 |
|
/** |
6152 |
* Returns the first Sample of this Group. You have to call this method |
* Returns the first Sample of this Group. You have to call this method |
6153 |
* once before you use GetNextSample(). |
* once before you use GetNextSample(). |
6154 |
* |
* |
6158 |
* @returns pointer address to first Sample or NULL if there is none |
* @returns pointer address to first Sample or NULL if there is none |
6159 |
* applied to this Group |
* applied to this Group |
6160 |
* @see GetNextSample() |
* @see GetNextSample() |
6161 |
|
* @deprecated This method is not reentrant-safe, use GetSample() |
6162 |
|
* instead. |
6163 |
*/ |
*/ |
6164 |
Sample* Group::GetFirstSample() { |
Sample* Group::GetFirstSample() { |
6165 |
// FIXME: lazy und unsafe implementation, should be an autonomous iterator |
size_t& i = this->SamplesIterator; |
6166 |
for (Sample* pSample = pFile->GetFirstSample(); pSample; pSample = pFile->GetNextSample()) { |
i = 0; |
6167 |
if (pSample->GetGroup() == this) return pSample; |
for (Sample* pSample = pFile->GetSample(i); pSample; |
6168 |
|
pSample = pFile->GetSample(++i)) |
6169 |
|
{ |
6170 |
|
if (pSample->GetGroup() == this) |
6171 |
|
return pSample; |
6172 |
} |
} |
6173 |
return NULL; |
return NULL; |
6174 |
} |
} |
6182 |
* @returns pointer address to the next Sample of this Group or NULL if |
* @returns pointer address to the next Sample of this Group or NULL if |
6183 |
* end reached |
* end reached |
6184 |
* @see GetFirstSample() |
* @see GetFirstSample() |
6185 |
|
* @deprecated This method is not reentrant-safe, use GetSample() |
6186 |
|
* instead. |
6187 |
*/ |
*/ |
6188 |
Sample* Group::GetNextSample() { |
Sample* Group::GetNextSample() { |
6189 |
// FIXME: lazy und unsafe implementation, should be an autonomous iterator |
size_t& i = this->SamplesIterator; |
6190 |
for (Sample* pSample = pFile->GetNextSample(); pSample; pSample = pFile->GetNextSample()) { |
for (Sample* pSample = pFile->GetSample(++i); pSample; |
6191 |
if (pSample->GetGroup() == this) return pSample; |
pSample = pFile->GetSample(++i)) |
6192 |
|
{ |
6193 |
|
if (pSample->GetGroup() == this) |
6194 |
|
return pSample; |
6195 |
} |
} |
6196 |
return NULL; |
return NULL; |
6197 |
} |
} |
6211 |
*/ |
*/ |
6212 |
void Group::MoveAll() { |
void Group::MoveAll() { |
6213 |
// get "that" other group first |
// get "that" other group first |
6214 |
|
size_t i = 0; |
6215 |
Group* pOtherGroup = NULL; |
Group* pOtherGroup = NULL; |
6216 |
for (pOtherGroup = pFile->GetFirstGroup(); pOtherGroup; pOtherGroup = pFile->GetNextGroup()) { |
for (pOtherGroup = pFile->GetGroup(i); pOtherGroup; |
6217 |
|
pOtherGroup = pFile->GetGroup(++i)) |
6218 |
|
{ |
6219 |
if (pOtherGroup != this) break; |
if (pOtherGroup != this) break; |
6220 |
} |
} |
6221 |
if (!pOtherGroup) throw Exception( |
if (!pOtherGroup) throw Exception( |
6223 |
"other Group. This is a bug, report it!" |
"other Group. This is a bug, report it!" |
6224 |
); |
); |
6225 |
// now move all samples of this group to the other group |
// now move all samples of this group to the other group |
6226 |
for (Sample* pSample = GetFirstSample(); pSample; pSample = GetNextSample()) { |
Sample* pSample; |
6227 |
|
while ((pSample = GetSample(0))) { |
6228 |
pOtherGroup->AddSample(pSample); |
pOtherGroup->AddSample(pSample); |
6229 |
} |
} |
6230 |
} |
} |
6296 |
|
|
6297 |
File::~File() { |
File::~File() { |
6298 |
if (pGroups) { |
if (pGroups) { |
6299 |
std::list<Group*>::iterator iter = pGroups->begin(); |
std::vector<Group*>::iterator iter = pGroups->begin(); |
6300 |
std::list<Group*>::iterator end = pGroups->end(); |
std::vector<Group*>::iterator end = pGroups->end(); |
6301 |
while (iter != end) { |
while (iter != end) { |
6302 |
delete *iter; |
delete *iter; |
6303 |
++iter; |
++iter; |
6315 |
} |
} |
6316 |
} |
} |
6317 |
|
|
6318 |
|
/** |
6319 |
|
* Returns a pointer to the first <i>Sample</i> object of the file, |
6320 |
|
* <i>NULL</i> otherwise. |
6321 |
|
* |
6322 |
|
* @param pProgress - optional: callback function for progress notification |
6323 |
|
* @deprecated This method is not reentrant-safe, use GetSample() |
6324 |
|
* instead. |
6325 |
|
*/ |
6326 |
Sample* File::GetFirstSample(progress_t* pProgress) { |
Sample* File::GetFirstSample(progress_t* pProgress) { |
6327 |
if (!pSamples) LoadSamples(pProgress); |
if (!pSamples) LoadSamples(pProgress); |
6328 |
if (!pSamples) return NULL; |
if (!pSamples) return NULL; |
6330 |
return static_cast<gig::Sample*>( (SamplesIterator != pSamples->end()) ? *SamplesIterator : NULL ); |
return static_cast<gig::Sample*>( (SamplesIterator != pSamples->end()) ? *SamplesIterator : NULL ); |
6331 |
} |
} |
6332 |
|
|
6333 |
|
/** |
6334 |
|
* Returns a pointer to the next <i>Sample</i> object of the file, |
6335 |
|
* <i>NULL</i> otherwise. |
6336 |
|
* |
6337 |
|
* @deprecated This method is not reentrant-safe, use GetSample() |
6338 |
|
* instead. |
6339 |
|
*/ |
6340 |
Sample* File::GetNextSample() { |
Sample* File::GetNextSample() { |
6341 |
if (!pSamples) return NULL; |
if (!pSamples) return NULL; |
6342 |
SamplesIterator++; |
SamplesIterator++; |
6346 |
/** |
/** |
6347 |
* Returns Sample object of @a index. |
* Returns Sample object of @a index. |
6348 |
* |
* |
6349 |
|
* @param index - position of sample in sample list (0..n) |
6350 |
|
* @param pProgress - optional: callback function for progress notification |
6351 |
* @returns sample object or NULL if index is out of bounds |
* @returns sample object or NULL if index is out of bounds |
6352 |
*/ |
*/ |
6353 |
Sample* File::GetSample(uint index) { |
Sample* File::GetSample(size_t index, progress_t* pProgress) { |
6354 |
if (!pSamples) LoadSamples(); |
if (!pSamples) LoadSamples(pProgress); |
6355 |
if (!pSamples) return NULL; |
if (!pSamples) return NULL; |
6356 |
DLS::File::SampleList::iterator it = pSamples->begin(); |
if (index >= pSamples->size()) return NULL; |
6357 |
for (int i = 0; i < index; ++i) { |
return static_cast<gig::Sample*>( (*pSamples)[index] ); |
|
++it; |
|
|
if (it == pSamples->end()) return NULL; |
|
|
} |
|
|
if (it == pSamples->end()) return NULL; |
|
|
return static_cast<gig::Sample*>( *it ); |
|
6358 |
} |
} |
6359 |
|
|
6360 |
/** |
/** |
6416 |
// remove all references to the sample |
// remove all references to the sample |
6417 |
for (Instrument* instrument = GetFirstInstrument() ; instrument ; |
for (Instrument* instrument = GetFirstInstrument() ; instrument ; |
6418 |
instrument = GetNextInstrument()) { |
instrument = GetNextInstrument()) { |
6419 |
for (Region* region = instrument->GetFirstRegion() ; region ; |
size_t iRgn = 0; |
6420 |
region = instrument->GetNextRegion()) { |
for (Region* region = instrument->GetRegionAt(iRgn); region; |
6421 |
|
region = instrument->GetRegionAt(++iRgn)) |
6422 |
|
{ |
6423 |
if (region->GetSample() == pSample) region->SetSample(NULL); |
if (region->GetSample() == pSample) region->SetSample(NULL); |
6424 |
|
|
6425 |
for (int i = 0 ; i < region->DimensionRegions ; i++) { |
for (int i = 0 ; i < region->DimensionRegions ; i++) { |
6580 |
* @param pProgress - optional: callback function for progress notification |
* @param pProgress - optional: callback function for progress notification |
6581 |
* @returns sought instrument or NULL if there's no such instrument |
* @returns sought instrument or NULL if there's no such instrument |
6582 |
*/ |
*/ |
6583 |
Instrument* File::GetInstrument(uint index, progress_t* pProgress) { |
Instrument* File::GetInstrument(size_t index, progress_t* pProgress) { |
6584 |
if (!pInstruments) { |
if (!pInstruments) { |
6585 |
// TODO: hack - we simply load ALL samples here, it would have been done in the Region constructor anyway (ATM) |
// TODO: hack - we simply load ALL samples here, it would have been done in the Region constructor anyway (ATM) |
6586 |
|
|
6590 |
__divide_progress(pProgress, &subprogress, 3.0f, 0.0f); // randomly schedule 33% for this subtask |
__divide_progress(pProgress, &subprogress, 3.0f, 0.0f); // randomly schedule 33% for this subtask |
6591 |
__notify_progress(&subprogress, 0.0f); |
__notify_progress(&subprogress, 0.0f); |
6592 |
if (GetAutoLoad()) |
if (GetAutoLoad()) |
6593 |
GetFirstSample(&subprogress); // now force all samples to be loaded |
GetSample(0, &subprogress); // now force all samples to be loaded |
6594 |
__notify_progress(&subprogress, 1.0f); |
__notify_progress(&subprogress, 1.0f); |
6595 |
|
|
6596 |
// instrument loading subtask |
// instrument loading subtask |
6604 |
} else { |
} else { |
6605 |
// sample loading subtask |
// sample loading subtask |
6606 |
if (GetAutoLoad()) |
if (GetAutoLoad()) |
6607 |
GetFirstSample(); // now force all samples to be loaded |
GetSample(0); // now force all samples to be loaded |
6608 |
|
|
6609 |
// instrument loading subtask |
// instrument loading subtask |
6610 |
LoadInstruments(); |
LoadInstruments(); |
6611 |
} |
} |
6612 |
} |
} |
6613 |
if (!pInstruments) return NULL; |
if (!pInstruments) return NULL; |
6614 |
InstrumentsIterator = pInstruments->begin(); |
if (index >= pInstruments->size()) return NULL; |
6615 |
for (uint i = 0; InstrumentsIterator != pInstruments->end(); i++) { |
return static_cast<gig::Instrument*>( (*pInstruments)[index] ); |
|
if (i == index) return static_cast<gig::Instrument*>( *InstrumentsIterator ); |
|
|
InstrumentsIterator++; |
|
|
} |
|
|
return NULL; |
|
6616 |
} |
} |
6617 |
|
|
6618 |
/** @brief Add a new instrument definition. |
/** @brief Add a new instrument definition. |
6840 |
} |
} |
6841 |
|
|
6842 |
int File::GetWaveTableIndexOf(gig::Sample* pSample) { |
int File::GetWaveTableIndexOf(gig::Sample* pSample) { |
6843 |
if (!pSamples) GetFirstSample(); // make sure sample chunks were scanned |
if (!pSamples) GetSample(0); // make sure sample chunks were scanned |
6844 |
File::SampleList::iterator iter = pSamples->begin(); |
File::SampleList::iterator iter = pSamples->begin(); |
6845 |
File::SampleList::iterator end = pSamples->end(); |
File::SampleList::iterator end = pSamples->end(); |
6846 |
for (int index = 0; iter != end; ++iter, ++index) |
for (int index = 0; iter != end; ++iter, ++index) |
6860 |
if (!_3crc) return false; |
if (!_3crc) return false; |
6861 |
if (_3crc->GetNewSize() <= 0) return false; |
if (_3crc->GetNewSize() <= 0) return false; |
6862 |
if (_3crc->GetNewSize() % 8) return false; |
if (_3crc->GetNewSize() % 8) return false; |
6863 |
if (!pSamples) GetFirstSample(); // make sure sample chunks were scanned |
if (!pSamples) GetSample(0); // make sure sample chunks were scanned |
6864 |
if (_3crc->GetNewSize() != pSamples->size() * 8) return false; |
if (_3crc->GetNewSize() != pSamples->size() * 8) return false; |
6865 |
|
|
6866 |
const file_offset_t n = _3crc->GetNewSize() / 8; |
const file_offset_t n = _3crc->GetNewSize() / 8; |
6894 |
*/ |
*/ |
6895 |
bool File::RebuildSampleChecksumTable() { |
bool File::RebuildSampleChecksumTable() { |
6896 |
// make sure sample chunks were scanned |
// make sure sample chunks were scanned |
6897 |
if (!pSamples) GetFirstSample(); |
if (!pSamples) GetSample(0); |
6898 |
|
|
6899 |
bool bRequiresSave = false; |
bool bRequiresSave = false; |
6900 |
|
|
6943 |
return bRequiresSave; |
return bRequiresSave; |
6944 |
} |
} |
6945 |
|
|
6946 |
|
/** |
6947 |
|
* Returns a pointer to the first <i>Group</i> object of the file, |
6948 |
|
* <i>NULL</i> otherwise. |
6949 |
|
* |
6950 |
|
* @deprecated This method is not reentrant-safe, use GetGroup() instead. |
6951 |
|
*/ |
6952 |
Group* File::GetFirstGroup() { |
Group* File::GetFirstGroup() { |
6953 |
if (!pGroups) LoadGroups(); |
if (!pGroups) LoadGroups(); |
6954 |
// there must always be at least one group |
// there must always be at least one group |
6956 |
return *GroupsIterator; |
return *GroupsIterator; |
6957 |
} |
} |
6958 |
|
|
6959 |
|
/** |
6960 |
|
* Returns a pointer to the next <i>Group</i> object of the file, |
6961 |
|
* <i>NULL</i> otherwise. |
6962 |
|
* |
6963 |
|
* @deprecated This method is not reentrant-safe, use GetGroup() instead. |
6964 |
|
*/ |
6965 |
Group* File::GetNextGroup() { |
Group* File::GetNextGroup() { |
6966 |
if (!pGroups) return NULL; |
if (!pGroups) return NULL; |
6967 |
++GroupsIterator; |
++GroupsIterator; |
6974 |
* @param index - number of the sought group (0..n) |
* @param index - number of the sought group (0..n) |
6975 |
* @returns sought group or NULL if there's no such group |
* @returns sought group or NULL if there's no such group |
6976 |
*/ |
*/ |
6977 |
Group* File::GetGroup(uint index) { |
Group* File::GetGroup(size_t index) { |
6978 |
if (!pGroups) LoadGroups(); |
if (!pGroups) LoadGroups(); |
6979 |
GroupsIterator = pGroups->begin(); |
if (index >= pGroups->size()) return NULL; |
6980 |
for (uint i = 0; GroupsIterator != pGroups->end(); i++) { |
return (*pGroups)[index]; |
|
if (i == index) return *GroupsIterator; |
|
|
++GroupsIterator; |
|
|
} |
|
|
return NULL; |
|
6981 |
} |
} |
6982 |
|
|
6983 |
/** |
/** |
6992 |
*/ |
*/ |
6993 |
Group* File::GetGroup(String name) { |
Group* File::GetGroup(String name) { |
6994 |
if (!pGroups) LoadGroups(); |
if (!pGroups) LoadGroups(); |
6995 |
GroupsIterator = pGroups->begin(); |
size_t i = 0; |
6996 |
for (uint i = 0; GroupsIterator != pGroups->end(); ++GroupsIterator, ++i) |
for (Group* pGroup = GetGroup(i); pGroup; pGroup = GetGroup(++i)) |
6997 |
if ((*GroupsIterator)->Name == name) return *GroupsIterator; |
if (pGroup->Name == name) return pGroup; |
6998 |
return NULL; |
return NULL; |
6999 |
} |
} |
7000 |
|
|
7018 |
*/ |
*/ |
7019 |
void File::DeleteGroup(Group* pGroup) { |
void File::DeleteGroup(Group* pGroup) { |
7020 |
if (!pGroups) LoadGroups(); |
if (!pGroups) LoadGroups(); |
7021 |
std::list<Group*>::iterator iter = find(pGroups->begin(), pGroups->end(), pGroup); |
std::vector<Group*>::iterator iter = |
7022 |
|
find(pGroups->begin(), pGroups->end(), pGroup); |
7023 |
if (iter == pGroups->end()) throw gig::Exception("Could not delete group, could not find given group"); |
if (iter == pGroups->end()) throw gig::Exception("Could not delete group, could not find given group"); |
7024 |
if (pGroups->size() == 1) throw gig::Exception("Cannot delete group, there must be at least one default group!"); |
if (pGroups->size() == 1) throw gig::Exception("Cannot delete group, there must be at least one default group!"); |
7025 |
// delete all members of this group |
// delete all members of this group |
7026 |
for (Sample* pSample = pGroup->GetFirstSample(); pSample; pSample = pGroup->GetNextSample()) { |
Sample* pSample; |
7027 |
|
while ((pSample = pGroup->GetSample(0))) { |
7028 |
DeleteSample(pSample); |
DeleteSample(pSample); |
7029 |
} |
} |
7030 |
// now delete this group object |
// now delete this group object |
7045 |
*/ |
*/ |
7046 |
void File::DeleteGroupOnly(Group* pGroup) { |
void File::DeleteGroupOnly(Group* pGroup) { |
7047 |
if (!pGroups) LoadGroups(); |
if (!pGroups) LoadGroups(); |
7048 |
std::list<Group*>::iterator iter = find(pGroups->begin(), pGroups->end(), pGroup); |
std::vector<Group*>::iterator iter = |
7049 |
|
find(pGroups->begin(), pGroups->end(), pGroup); |
7050 |
if (iter == pGroups->end()) throw gig::Exception("Could not delete group, could not find given group"); |
if (iter == pGroups->end()) throw gig::Exception("Could not delete group, could not find given group"); |
7051 |
if (pGroups->size() == 1) throw gig::Exception("Cannot delete group, there must be at least one default group!"); |
if (pGroups->size() == 1) throw gig::Exception("Cannot delete group, there must be at least one default group!"); |
7052 |
// move all members of this group to another group |
// move all members of this group to another group |
7057 |
} |
} |
7058 |
|
|
7059 |
void File::LoadGroups() { |
void File::LoadGroups() { |
7060 |
if (!pGroups) pGroups = new std::list<Group*>; |
if (!pGroups) pGroups = new std::vector<Group*>; |
7061 |
// try to read defined groups from file |
// try to read defined groups from file |
7062 |
RIFF::List* lst3gri = pRIFF->GetSubList(LIST_TYPE_3GRI); |
RIFF::List* lst3gri = pRIFF->GetSubList(LIST_TYPE_3GRI); |
7063 |
if (lst3gri) { |
if (lst3gri) { |
7256 |
} |
} |
7257 |
} |
} |
7258 |
|
|
7259 |
std::list<Group*>::iterator iter = pGroups->begin(); |
std::vector<Group*>::iterator iter = pGroups->begin(); |
7260 |
std::list<Group*>::iterator end = pGroups->end(); |
std::vector<Group*>::iterator end = pGroups->end(); |
7261 |
for (; iter != end; ++iter) { |
for (; iter != end; ++iter) { |
7262 |
(*iter)->UpdateChunks(pProgress); |
(*iter)->UpdateChunks(pProgress); |
7263 |
} |
} |
7295 |
uint8_t* pData = (uint8_t*) einf->LoadChunkData(); |
uint8_t* pData = (uint8_t*) einf->LoadChunkData(); |
7296 |
|
|
7297 |
std::map<gig::Sample*,int> sampleMap; |
std::map<gig::Sample*,int> sampleMap; |
7298 |
int sampleIdx = 0; |
size_t sampleIdx = 0; |
7299 |
for (Sample* pSample = GetFirstSample(); pSample; pSample = GetNextSample()) { |
for (Sample* pSample = GetSample(0); pSample; |
7300 |
sampleMap[pSample] = sampleIdx++; |
pSample = GetSample(++sampleIdx)) |
7301 |
|
{ |
7302 |
|
sampleMap[pSample] = sampleIdx; |
7303 |
} |
} |
7304 |
|
|
7305 |
int totnbusedsamples = 0; |
int totnbusedsamples = 0; |
7320 |
|
|
7321 |
memset(&pData[(instrumentIdx + 1) * sublen + 48], 0, sublen - 48); |
memset(&pData[(instrumentIdx + 1) * sublen + 48], 0, sublen - 48); |
7322 |
|
|
7323 |
for (Region* region = instrument->GetFirstRegion() ; region ; |
size_t iRgn = 0; |
7324 |
region = instrument->GetNextRegion()) { |
for (Region* region = instrument->GetRegionAt(iRgn); region; |
7325 |
|
region = instrument->GetRegionAt(++iRgn)) |
7326 |
|
{ |
7327 |
for (int i = 0 ; i < region->DimensionRegions ; i++) { |
for (int i = 0 ; i < region->DimensionRegions ; i++) { |
7328 |
gig::DimensionRegion *d = region->pDimensionRegions[i]; |
gig::DimensionRegion *d = region->pDimensionRegions[i]; |
7329 |
if (d->pSample) { |
if (d->pSample) { |