/[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 3924 by schoenebeck, Mon Jun 14 12:07:47 2021 UTC revision 3927 by schoenebeck, Tue Jun 15 11:00:50 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 6340  namespace { Line 6359  namespace {
6359          // remove all references to the sample          // remove all references to the sample
6360          for (Instrument* instrument = GetFirstInstrument() ; instrument ;          for (Instrument* instrument = GetFirstInstrument() ; instrument ;
6361               instrument = GetNextInstrument()) {               instrument = GetNextInstrument()) {
6362              for (Region* region = instrument->GetFirstRegion() ; region ;              size_t iRgn = 0;
6363                   region = instrument->GetNextRegion()) {              for (Region* region = instrument->GetRegionAt(iRgn); region;
6364                     region = instrument->GetRegionAt(++iRgn))
6365                {
6366                  if (region->GetSample() == pSample) region->SetSample(NULL);                  if (region->GetSample() == pSample) region->SetSample(NULL);
6367    
6368                  for (int i = 0 ; i < region->DimensionRegions ; i++) {                  for (int i = 0 ; i < region->DimensionRegions ; i++) {
# Line 6365  namespace { Line 6385  namespace {
6385    
6386          if (!pSamples) pSamples = new SampleList;          if (!pSamples) pSamples = new SampleList;
6387    
         RIFF::File* file = pRIFF;  
   
6388          // just for progress calculation          // just for progress calculation
6389          int iSampleIndex  = 0;          int iSampleIndex  = 0;
6390          int iTotalSamples = WavePoolCount;          int iTotalSamples = WavePoolCount;
# Line 7236  namespace { Line 7254  namespace {
7254    
7255                  memset(&pData[(instrumentIdx + 1) * sublen + 48], 0, sublen - 48);                  memset(&pData[(instrumentIdx + 1) * sublen + 48], 0, sublen - 48);
7256    
7257                  for (Region* region = instrument->GetFirstRegion() ; region ;                  size_t iRgn = 0;
7258                       region = instrument->GetNextRegion()) {                  for (Region* region = instrument->GetRegionAt(iRgn); region;
7259                         region = instrument->GetRegionAt(++iRgn))
7260                    {
7261                      for (int i = 0 ; i < region->DimensionRegions ; i++) {                      for (int i = 0 ; i < region->DimensionRegions ; i++) {
7262                          gig::DimensionRegion *d = region->pDimensionRegions[i];                          gig::DimensionRegion *d = region->pDimensionRegions[i];
7263                          if (d->pSample) {                          if (d->pSample) {

Legend:
Removed from v.3924  
changed lines
  Added in v.3927

  ViewVC Help
Powered by ViewVC