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( |
6414 |
|
|
6415 |
SampleList::iterator tmp = SamplesIterator; |
SampleList::iterator tmp = SamplesIterator; |
6416 |
// remove all references to the sample |
// remove all references to the sample |
6417 |
for (Instrument* instrument = GetFirstInstrument() ; instrument ; |
size_t iIns = 0; |
6418 |
instrument = GetNextInstrument()) { |
for (Instrument* instrument = GetInstrument(iIns); instrument; |
6419 |
|
instrument = GetInstrument(++iIns)) |
6420 |
|
{ |
6421 |
size_t iRgn = 0; |
size_t iRgn = 0; |
6422 |
for (Region* region = instrument->GetRegionAt(iRgn); region; |
for (Region* region = instrument->GetRegionAt(iRgn); region; |
6423 |
region = instrument->GetRegionAt(++iRgn)) |
region = instrument->GetRegionAt(++iRgn)) |
6548 |
__notify_progress(pProgress, 1.0); // notify done |
__notify_progress(pProgress, 1.0); // notify done |
6549 |
} |
} |
6550 |
|
|
6551 |
|
/** |
6552 |
|
* Returns a pointer to the first <i>Instrument</i> object of the file, |
6553 |
|
* <i>NULL</i> otherwise. |
6554 |
|
* |
6555 |
|
* @deprecated This method is not reentrant-safe, use GetInstrument() |
6556 |
|
* instead. |
6557 |
|
*/ |
6558 |
Instrument* File::GetFirstInstrument() { |
Instrument* File::GetFirstInstrument() { |
6559 |
if (!pInstruments) LoadInstruments(); |
if (!pInstruments) LoadInstruments(); |
6560 |
if (!pInstruments) return NULL; |
if (!pInstruments) return NULL; |
6562 |
return static_cast<gig::Instrument*>( (InstrumentsIterator != pInstruments->end()) ? *InstrumentsIterator : NULL ); |
return static_cast<gig::Instrument*>( (InstrumentsIterator != pInstruments->end()) ? *InstrumentsIterator : NULL ); |
6563 |
} |
} |
6564 |
|
|
6565 |
|
/** |
6566 |
|
* Returns a pointer to the next <i>Instrument</i> object of the file, |
6567 |
|
* <i>NULL</i> otherwise. |
6568 |
|
* |
6569 |
|
* @deprecated This method is not reentrant-safe, use GetInstrument() |
6570 |
|
* instead. |
6571 |
|
*/ |
6572 |
Instrument* File::GetNextInstrument() { |
Instrument* File::GetNextInstrument() { |
6573 |
if (!pInstruments) return NULL; |
if (!pInstruments) return NULL; |
6574 |
InstrumentsIterator++; |
InstrumentsIterator++; |
6596 |
* @param pProgress - optional: callback function for progress notification |
* @param pProgress - optional: callback function for progress notification |
6597 |
* @returns sought instrument or NULL if there's no such instrument |
* @returns sought instrument or NULL if there's no such instrument |
6598 |
*/ |
*/ |
6599 |
Instrument* File::GetInstrument(uint index, progress_t* pProgress) { |
Instrument* File::GetInstrument(size_t index, progress_t* pProgress) { |
6600 |
if (!pInstruments) { |
if (!pInstruments) { |
6601 |
// 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) |
6602 |
|
|
6627 |
} |
} |
6628 |
} |
} |
6629 |
if (!pInstruments) return NULL; |
if (!pInstruments) return NULL; |
6630 |
InstrumentsIterator = pInstruments->begin(); |
if (index >= pInstruments->size()) return NULL; |
6631 |
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; |
|
6632 |
} |
} |
6633 |
|
|
6634 |
/** @brief Add a new instrument definition. |
/** @brief Add a new instrument definition. |
7008 |
*/ |
*/ |
7009 |
Group* File::GetGroup(String name) { |
Group* File::GetGroup(String name) { |
7010 |
if (!pGroups) LoadGroups(); |
if (!pGroups) LoadGroups(); |
7011 |
GroupsIterator = pGroups->begin(); |
size_t i = 0; |
7012 |
for (uint i = 0; GroupsIterator != pGroups->end(); ++GroupsIterator, ++i) |
for (Group* pGroup = GetGroup(i); pGroup; pGroup = GetGroup(++i)) |
7013 |
if ((*GroupsIterator)->Name == name) return *GroupsIterator; |
if (pGroup->Name == name) return pGroup; |
7014 |
return NULL; |
return NULL; |
7015 |
} |
} |
7016 |
|
|
7327 |
|
|
7328 |
memset(&pData[48], 0, sublen - 48); |
memset(&pData[48], 0, sublen - 48); |
7329 |
|
|
7330 |
for (Instrument* instrument = GetFirstInstrument() ; instrument ; |
size_t iIns = 0; |
7331 |
instrument = GetNextInstrument()) { |
for (Instrument* instrument = GetInstrument(iIns); instrument; |
7332 |
|
instrument = GetInstrument(++iIns)) |
7333 |
|
{ |
7334 |
int nbusedsamples = 0; |
int nbusedsamples = 0; |
7335 |
int nbusedchannels = 0; |
int nbusedchannels = 0; |
7336 |
int nbdimregions = 0; |
int nbdimregions = 0; |
7435 |
void File::UpdateFileOffsets() { |
void File::UpdateFileOffsets() { |
7436 |
DLS::File::UpdateFileOffsets(); |
DLS::File::UpdateFileOffsets(); |
7437 |
|
|
7438 |
for (Instrument* instrument = GetFirstInstrument(); instrument; |
size_t i = 0; |
7439 |
instrument = GetNextInstrument()) |
for (Instrument* instrument = GetInstrument(i); instrument; |
7440 |
|
instrument = GetInstrument(++i)) |
7441 |
{ |
{ |
7442 |
instrument->UpdateScriptFileOffsets(); |
instrument->UpdateScriptFileOffsets(); |
7443 |
} |
} |