/[svn]/libgig/trunk/src/gig.cpp
ViewVC logotype

Diff of /libgig/trunk/src/gig.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3925 by schoenebeck, Mon Jun 14 12:15:51 2021 UTC revision 3928 by schoenebeck, Tue Jun 15 11:38:38 2021 UTC
# Line 5301  namespace { Line 5301  namespace {
5301      }      }
5302    
5303      /**      /**
5304         * Returns Region at supplied @a pos position within the region list of
5305         * this instrument. If supplied @a pos is out of bounds then @c NULL is
5306         * returned.
5307         *
5308         * @param pos - position of sought Region in region list
5309         * @returns pointer address to requested region or @c NULL if @a pos is
5310         *          out of bounds
5311         */
5312        Region* Instrument::GetRegionAt(size_t pos) {
5313            if (!pRegions) return NULL;
5314            if (pos >= pRegions->size()) return NULL;
5315            return static_cast<gig::Region*>( (*pRegions)[pos] );
5316        }
5317    
5318        /**
5319       * Returns the first Region of the instrument. You have to call this       * Returns the first Region of the instrument. You have to call this
5320       * method once before you use GetNextRegion().       * method once before you use GetNextRegion().
5321       *       *
5322       * @returns  pointer address to first region or NULL if there is none       * @returns  pointer address to first region or NULL if there is none
5323       * @see      GetNextRegion()       * @see      GetNextRegion()
5324         * @deprecated  This method is not reentrant-safe, use GetRegionAt()
5325         *              instead.
5326       */       */
5327      Region* Instrument::GetFirstRegion() {      Region* Instrument::GetFirstRegion() {
5328          if (!pRegions) return NULL;          if (!pRegions) return NULL;
# Line 5320  namespace { Line 5337  namespace {
5337       *       *
5338       * @returns  pointer address to the next region or NULL if end reached       * @returns  pointer address to the next region or NULL if end reached
5339       * @see      GetFirstRegion()       * @see      GetFirstRegion()
5340         * @deprecated  This method is not reentrant-safe, use GetRegionAt()
5341         *              instead.
5342       */       */
5343      Region* Instrument::GetNextRegion() {      Region* Instrument::GetNextRegion() {
5344          if (!pRegions) return NULL;          if (!pRegions) return NULL;
# Line 5986  namespace { Line 6005  namespace {
6005          pMidiRules[0] = NULL;          pMidiRules[0] = NULL;
6006                    
6007          // delete all old regions          // delete all old regions
6008          while (Regions) DeleteRegion(GetFirstRegion());          while (Regions) DeleteRegion(GetRegionAt(0));
6009          // create new regions and copy them from original          // create new regions and copy them from original
6010          {          {
6011              RegionList::const_iterator it = orig->pRegions->begin();              RegionList::const_iterator it = orig->pRegions->begin();
# Line 6251  namespace { Line 6270  namespace {
6270          }          }
6271      }      }
6272    
6273        /**
6274         * Returns a pointer to the first <i>Sample</i> object of the file,
6275         * <i>NULL</i> otherwise.
6276         *
6277         * @param pProgress - optional: callback function for progress notification
6278         * @deprecated  This method is not reentrant-safe, use GetSample()
6279         *              instead.
6280         */
6281      Sample* File::GetFirstSample(progress_t* pProgress) {      Sample* File::GetFirstSample(progress_t* pProgress) {
6282          if (!pSamples) LoadSamples(pProgress);          if (!pSamples) LoadSamples(pProgress);
6283          if (!pSamples) return NULL;          if (!pSamples) return NULL;
# Line 6258  namespace { Line 6285  namespace {
6285          return static_cast<gig::Sample*>( (SamplesIterator != pSamples->end()) ? *SamplesIterator : NULL );          return static_cast<gig::Sample*>( (SamplesIterator != pSamples->end()) ? *SamplesIterator : NULL );
6286      }      }
6287    
6288        /**
6289         * Returns a pointer to the next <i>Sample</i> object of the file,
6290         * <i>NULL</i> otherwise.
6291         *
6292         * @deprecated  This method is not reentrant-safe, use GetSample()
6293         *              instead.
6294         */
6295      Sample* File::GetNextSample() {      Sample* File::GetNextSample() {
6296          if (!pSamples) return NULL;          if (!pSamples) return NULL;
6297          SamplesIterator++;          SamplesIterator++;
# Line 6267  namespace { Line 6301  namespace {
6301      /**      /**
6302       * Returns Sample object of @a index.       * Returns Sample object of @a index.
6303       *       *
6304         * @param index - position of sample in sample list (0..n)
6305         * @param pProgress - optional: callback function for progress notification
6306       * @returns sample object or NULL if index is out of bounds       * @returns sample object or NULL if index is out of bounds
6307       */       */
6308      Sample* File::GetSample(uint index) {      Sample* File::GetSample(size_t index, progress_t* pProgress) {
6309          if (!pSamples) LoadSamples();          if (!pSamples) LoadSamples(pProgress);
6310          if (!pSamples) return NULL;          if (!pSamples) return NULL;
6311          DLS::File::SampleList::iterator it = pSamples->begin();          if (index >= pSamples->size()) return NULL;
6312          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 );  
6313      }      }
6314    
6315      /**      /**
# Line 6340  namespace { Line 6371  namespace {
6371          // remove all references to the sample          // remove all references to the sample
6372          for (Instrument* instrument = GetFirstInstrument() ; instrument ;          for (Instrument* instrument = GetFirstInstrument() ; instrument ;
6373               instrument = GetNextInstrument()) {               instrument = GetNextInstrument()) {
6374              for (Region* region = instrument->GetFirstRegion() ; region ;              size_t iRgn = 0;
6375                   region = instrument->GetNextRegion()) {              for (Region* region = instrument->GetRegionAt(iRgn); region;
6376                     region = instrument->GetRegionAt(++iRgn))
6377                {
6378                  if (region->GetSample() == pSample) region->SetSample(NULL);                  if (region->GetSample() == pSample) region->SetSample(NULL);
6379    
6380                  for (int i = 0 ; i < region->DimensionRegions ; i++) {                  for (int i = 0 ; i < region->DimensionRegions ; i++) {
# Line 7234  namespace { Line 7266  namespace {
7266    
7267                  memset(&pData[(instrumentIdx + 1) * sublen + 48], 0, sublen - 48);                  memset(&pData[(instrumentIdx + 1) * sublen + 48], 0, sublen - 48);
7268    
7269                  for (Region* region = instrument->GetFirstRegion() ; region ;                  size_t iRgn = 0;
7270                       region = instrument->GetNextRegion()) {                  for (Region* region = instrument->GetRegionAt(iRgn); region;
7271                         region = instrument->GetRegionAt(++iRgn))
7272                    {
7273                      for (int i = 0 ; i < region->DimensionRegions ; i++) {                      for (int i = 0 ; i < region->DimensionRegions ; i++) {
7274                          gig::DimensionRegion *d = region->pDimensionRegions[i];                          gig::DimensionRegion *d = region->pDimensionRegions[i];
7275                          if (d->pSample) {                          if (d->pSample) {

Legend:
Removed from v.3925  
changed lines
  Added in v.3928

  ViewVC Help
Powered by ViewVC