--- libgig/trunk/src/DLS.cpp 2021/06/15 11:38:38 3928 +++ libgig/trunk/src/DLS.cpp 2021/06/18 13:47:46 3940 @@ -189,6 +189,30 @@ pArticulations = NULL; } + /** + * Returns Articulation at supplied @a pos position within the articulation + * list. If supplied @a pos is out of bounds then @c NULL is returned. + * + * @param pos - position of sought Articulation in articulation list + * @returns pointer address to requested articulation or @c NULL if @a pos + * is out of bounds + */ + Articulation* Articulator::GetArticulation(size_t pos) { + if (!pArticulations) LoadArticulations(); + if (!pArticulations) return NULL; + if (pos >= pArticulations->size()) return NULL; + return (*pArticulations)[pos]; + } + + /** + * Returns the first Articulation in the list of articulations. You have to + * call this method once before you can use GetNextArticulation(). + * + * @returns pointer address to first Articulation or NULL if there is none + * @see GetNextArticulation() + * @deprecated This method is not reentrant-safe, use GetArticulation() + * instead. + */ Articulation* Articulator::GetFirstArticulation() { if (!pArticulations) LoadArticulations(); if (!pArticulations) return NULL; @@ -196,6 +220,17 @@ return (ArticulationsIterator != pArticulations->end()) ? *ArticulationsIterator : NULL; } + /** + * Returns the next Articulation from the list of articulations. You have + * to call GetFirstArticulation() once before you can use this method. By + * calling this method multiple times it iterates through the available + * articulations. + * + * @returns pointer address to the next Articulation or NULL if end reached + * @see GetFirstArticulation() + * @deprecated This method is not reentrant-safe, use GetArticulation() + * instead. + */ Articulation* Articulator::GetNextArticulation() { if (!pArticulations) return NULL; ArticulationsIterator++; @@ -1164,10 +1199,11 @@ if (pSample) return pSample; File* file = (File*) GetParent()->GetParent(); uint64_t soughtoffset = file->pWavePoolTable[WavePoolTableIndex]; - Sample* sample = file->GetFirstSample(); - while (sample) { + size_t i = 0; + for (Sample* sample = file->GetSample(i); sample; + sample = file->GetSample(++i)) + { if (sample->ullWavePoolOffset == soughtoffset) return (pSample = sample); - sample = file->GetNextSample(); } return NULL; }