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 |
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( |
6546 |
__notify_progress(pProgress, 1.0); // notify done |
__notify_progress(pProgress, 1.0); // notify done |
6547 |
} |
} |
6548 |
|
|
6549 |
|
/** |
6550 |
|
* Returns a pointer to the first <i>Instrument</i> object of the file, |
6551 |
|
* <i>NULL</i> otherwise. |
6552 |
|
* |
6553 |
|
* @deprecated This method is not reentrant-safe, use GetInstrument() |
6554 |
|
* instead. |
6555 |
|
*/ |
6556 |
Instrument* File::GetFirstInstrument() { |
Instrument* File::GetFirstInstrument() { |
6557 |
if (!pInstruments) LoadInstruments(); |
if (!pInstruments) LoadInstruments(); |
6558 |
if (!pInstruments) return NULL; |
if (!pInstruments) return NULL; |
6560 |
return static_cast<gig::Instrument*>( (InstrumentsIterator != pInstruments->end()) ? *InstrumentsIterator : NULL ); |
return static_cast<gig::Instrument*>( (InstrumentsIterator != pInstruments->end()) ? *InstrumentsIterator : NULL ); |
6561 |
} |
} |
6562 |
|
|
6563 |
|
/** |
6564 |
|
* Returns a pointer to the next <i>Instrument</i> object of the file, |
6565 |
|
* <i>NULL</i> otherwise. |
6566 |
|
* |
6567 |
|
* @deprecated This method is not reentrant-safe, use GetInstrument() |
6568 |
|
* instead. |
6569 |
|
*/ |
6570 |
Instrument* File::GetNextInstrument() { |
Instrument* File::GetNextInstrument() { |
6571 |
if (!pInstruments) return NULL; |
if (!pInstruments) return NULL; |
6572 |
InstrumentsIterator++; |
InstrumentsIterator++; |
6594 |
* @param pProgress - optional: callback function for progress notification |
* @param pProgress - optional: callback function for progress notification |
6595 |
* @returns sought instrument or NULL if there's no such instrument |
* @returns sought instrument or NULL if there's no such instrument |
6596 |
*/ |
*/ |
6597 |
Instrument* File::GetInstrument(uint index, progress_t* pProgress) { |
Instrument* File::GetInstrument(size_t index, progress_t* pProgress) { |
6598 |
if (!pInstruments) { |
if (!pInstruments) { |
6599 |
// 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) |
6600 |
|
|
6625 |
} |
} |
6626 |
} |
} |
6627 |
if (!pInstruments) return NULL; |
if (!pInstruments) return NULL; |
6628 |
InstrumentsIterator = pInstruments->begin(); |
if (index >= pInstruments->size()) return NULL; |
6629 |
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; |
|
6630 |
} |
} |
6631 |
|
|
6632 |
/** @brief Add a new instrument definition. |
/** @brief Add a new instrument definition. |
6957 |
return bRequiresSave; |
return bRequiresSave; |
6958 |
} |
} |
6959 |
|
|
6960 |
|
/** |
6961 |
|
* Returns a pointer to the first <i>Group</i> object of the file, |
6962 |
|
* <i>NULL</i> otherwise. |
6963 |
|
* |
6964 |
|
* @deprecated This method is not reentrant-safe, use GetGroup() instead. |
6965 |
|
*/ |
6966 |
Group* File::GetFirstGroup() { |
Group* File::GetFirstGroup() { |
6967 |
if (!pGroups) LoadGroups(); |
if (!pGroups) LoadGroups(); |
6968 |
// there must always be at least one group |
// there must always be at least one group |
6970 |
return *GroupsIterator; |
return *GroupsIterator; |
6971 |
} |
} |
6972 |
|
|
6973 |
|
/** |
6974 |
|
* Returns a pointer to the next <i>Group</i> object of the file, |
6975 |
|
* <i>NULL</i> otherwise. |
6976 |
|
* |
6977 |
|
* @deprecated This method is not reentrant-safe, use GetGroup() instead. |
6978 |
|
*/ |
6979 |
Group* File::GetNextGroup() { |
Group* File::GetNextGroup() { |
6980 |
if (!pGroups) return NULL; |
if (!pGroups) return NULL; |
6981 |
++GroupsIterator; |
++GroupsIterator; |
7006 |
*/ |
*/ |
7007 |
Group* File::GetGroup(String name) { |
Group* File::GetGroup(String name) { |
7008 |
if (!pGroups) LoadGroups(); |
if (!pGroups) LoadGroups(); |
7009 |
GroupsIterator = pGroups->begin(); |
size_t i = 0; |
7010 |
for (uint i = 0; GroupsIterator != pGroups->end(); ++GroupsIterator, ++i) |
for (Group* pGroup = GetGroup(i); pGroup; pGroup = GetGroup(++i)) |
7011 |
if ((*GroupsIterator)->Name == name) return *GroupsIterator; |
if (pGroup->Name == name) return pGroup; |
7012 |
return NULL; |
return NULL; |
7013 |
} |
} |
7014 |
|
|