1358 |
pRegions = NULL; |
pRegions = NULL; |
1359 |
} |
} |
1360 |
|
|
1361 |
|
/** |
1362 |
|
* Returns Region at supplied @a pos position within the region list of |
1363 |
|
* this instrument. If supplied @a pos is out of bounds then @c NULL is |
1364 |
|
* returned. |
1365 |
|
* |
1366 |
|
* @param pos - position of sought Region in region list |
1367 |
|
* @returns pointer address to requested region or @c NULL if @a pos is |
1368 |
|
* out of bounds |
1369 |
|
*/ |
1370 |
|
Region* Instrument::GetRegionAt(size_t pos) { |
1371 |
|
if (!pRegions) LoadRegions(); |
1372 |
|
if (!pRegions) return NULL; |
1373 |
|
if (pos >= pRegions->size()) return NULL; |
1374 |
|
return (*pRegions)[pos]; |
1375 |
|
} |
1376 |
|
|
1377 |
|
/** |
1378 |
|
* Returns the first Region of the instrument. You have to call this |
1379 |
|
* method once before you use GetNextRegion(). |
1380 |
|
* |
1381 |
|
* @returns pointer address to first region or NULL if there is none |
1382 |
|
* @see GetNextRegion() |
1383 |
|
* @deprecated This method is not reentrant-safe, use GetRegionAt() |
1384 |
|
* instead. |
1385 |
|
*/ |
1386 |
Region* Instrument::GetFirstRegion() { |
Region* Instrument::GetFirstRegion() { |
1387 |
if (!pRegions) LoadRegions(); |
if (!pRegions) LoadRegions(); |
1388 |
if (!pRegions) return NULL; |
if (!pRegions) return NULL; |
1390 |
return (RegionsIterator != pRegions->end()) ? *RegionsIterator : NULL; |
return (RegionsIterator != pRegions->end()) ? *RegionsIterator : NULL; |
1391 |
} |
} |
1392 |
|
|
1393 |
|
/** |
1394 |
|
* Returns the next Region of the instrument. You have to call |
1395 |
|
* GetFirstRegion() once before you can use this method. By calling this |
1396 |
|
* method multiple times it iterates through the available Regions. |
1397 |
|
* |
1398 |
|
* @returns pointer address to the next region or NULL if end reached |
1399 |
|
* @see GetFirstRegion() |
1400 |
|
* @deprecated This method is not reentrant-safe, use GetRegionAt() |
1401 |
|
* instead. |
1402 |
|
*/ |
1403 |
Region* Instrument::GetNextRegion() { |
Region* Instrument::GetNextRegion() { |
1404 |
if (!pRegions) return NULL; |
if (!pRegions) return NULL; |
1405 |
RegionsIterator++; |
RegionsIterator++; |
1436 |
void Instrument::MoveRegion(Region* pSrc, Region* pDst) { |
void Instrument::MoveRegion(Region* pSrc, Region* pDst) { |
1437 |
RIFF::List* lrgn = pCkInstrument->GetSubList(LIST_TYPE_LRGN); |
RIFF::List* lrgn = pCkInstrument->GetSubList(LIST_TYPE_LRGN); |
1438 |
lrgn->MoveSubChunk(pSrc->pCkRegion, (RIFF::Chunk*) (pDst ? pDst->pCkRegion : 0)); |
lrgn->MoveSubChunk(pSrc->pCkRegion, (RIFF::Chunk*) (pDst ? pDst->pCkRegion : 0)); |
1439 |
|
for (size_t i = 0; i < pRegions->size(); ++i) { |
1440 |
pRegions->remove(pSrc); |
if ((*pRegions)[i] == pSrc) { |
1441 |
RegionList::iterator iter = find(pRegions->begin(), pRegions->end(), pDst); |
pRegions->erase(pRegions->begin() + i); |
1442 |
pRegions->insert(iter, pSrc); |
RegionList::iterator iter = find(pRegions->begin(), pRegions->end(), pDst); |
1443 |
|
pRegions->insert(iter, pSrc); |
1444 |
|
} |
1445 |
|
} |
1446 |
} |
} |
1447 |
|
|
1448 |
void Instrument::DeleteRegion(Region* pRegion) { |
void Instrument::DeleteRegion(Region* pRegion) { |
1564 |
void Instrument::CopyAssign(const Instrument* orig) { |
void Instrument::CopyAssign(const Instrument* orig) { |
1565 |
CopyAssignCore(orig); |
CopyAssignCore(orig); |
1566 |
// delete all regions first |
// delete all regions first |
1567 |
while (Regions) DeleteRegion(GetFirstRegion()); |
while (Regions) DeleteRegion(GetRegionAt(0)); |
1568 |
// now recreate and copy regions |
// now recreate and copy regions |
1569 |
{ |
{ |
1570 |
RegionList::const_iterator it = orig->pRegions->begin(); |
RegionList::const_iterator it = orig->pRegions->begin(); |
1700 |
delete pRIFF; |
delete pRIFF; |
1701 |
} |
} |
1702 |
|
|
1703 |
|
/** |
1704 |
|
* Returns Sample object of @a index. |
1705 |
|
* |
1706 |
|
* @param index - position of sample in sample list (0..n) |
1707 |
|
* @returns sample object or NULL if index is out of bounds |
1708 |
|
*/ |
1709 |
|
Sample* File::GetSample(size_t index) { |
1710 |
|
if (!pSamples) LoadSamples(); |
1711 |
|
if (!pSamples) return NULL; |
1712 |
|
if (index >= pSamples->size()) return NULL; |
1713 |
|
return (*pSamples)[index]; |
1714 |
|
} |
1715 |
|
|
1716 |
|
/** |
1717 |
|
* Returns a pointer to the first <i>Sample</i> object of the file, |
1718 |
|
* <i>NULL</i> otherwise. |
1719 |
|
* |
1720 |
|
* @deprecated This method is not reentrant-safe, use GetSample() |
1721 |
|
* instead. |
1722 |
|
*/ |
1723 |
Sample* File::GetFirstSample() { |
Sample* File::GetFirstSample() { |
1724 |
if (!pSamples) LoadSamples(); |
if (!pSamples) LoadSamples(); |
1725 |
if (!pSamples) return NULL; |
if (!pSamples) return NULL; |
1727 |
return (SamplesIterator != pSamples->end()) ? *SamplesIterator : NULL; |
return (SamplesIterator != pSamples->end()) ? *SamplesIterator : NULL; |
1728 |
} |
} |
1729 |
|
|
1730 |
|
/** |
1731 |
|
* Returns a pointer to the next <i>Sample</i> object of the file, |
1732 |
|
* <i>NULL</i> otherwise. |
1733 |
|
* |
1734 |
|
* @deprecated This method is not reentrant-safe, use GetSample() |
1735 |
|
* instead. |
1736 |
|
*/ |
1737 |
Sample* File::GetNextSample() { |
Sample* File::GetNextSample() { |
1738 |
if (!pSamples) return NULL; |
if (!pSamples) return NULL; |
1739 |
SamplesIterator++; |
SamplesIterator++; |