/[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 3904 by schoenebeck, Wed May 12 18:55:31 2021 UTC revision 3933 by schoenebeck, Thu Jun 17 09:21:11 2021 UTC
# Line 482  namespace { Line 482  namespace {
482              ScanCompressedSample();              ScanCompressedSample();
483          }          }
484    
485          // we use a buffer for decompression and for truncating 24 bit samples to 16 bit          // we use a buffer for decompression only
486          if ((Compressed || BitDepth == 24) && !InternalDecompressionBuffer.Size) {          if (Compressed && !InternalDecompressionBuffer.Size) {
487              InternalDecompressionBuffer.pStart = new unsigned char[INITIAL_SAMPLE_BUFFER_SIZE];              InternalDecompressionBuffer.pStart = new unsigned char[INITIAL_SAMPLE_BUFFER_SIZE];
488              InternalDecompressionBuffer.Size   = INITIAL_SAMPLE_BUFFER_SIZE;              InternalDecompressionBuffer.Size   = INITIAL_SAMPLE_BUFFER_SIZE;
489          }          }
# Line 3498  namespace { Line 3498  namespace {
3498          RIFF::List* _3prg = rgn->GetSubList(LIST_TYPE_3PRG);          RIFF::List* _3prg = rgn->GetSubList(LIST_TYPE_3PRG);
3499          if (_3prg) {          if (_3prg) {
3500              int dimensionRegionNr = 0;              int dimensionRegionNr = 0;
3501              RIFF::List* _3ewl = _3prg->GetFirstSubList();              size_t i = 0;
3502              while (_3ewl) {              for (RIFF::List* _3ewl = _3prg->GetSubListAt(i); _3ewl;
3503                     _3ewl = _3prg->GetSubListAt(++i))
3504                {
3505                  if (_3ewl->GetListType() == LIST_TYPE_3EWL) {                  if (_3ewl->GetListType() == LIST_TYPE_3EWL) {
3506                      pDimensionRegions[dimensionRegionNr] = new DimensionRegion(this, _3ewl);                      pDimensionRegions[dimensionRegionNr] = new DimensionRegion(this, _3ewl);
3507                      dimensionRegionNr++;                      dimensionRegionNr++;
3508                  }                  }
                 _3ewl = _3prg->GetNextSubList();  
3509              }              }
3510              if (dimensionRegionNr == 0) throw gig::Exception("No dimension region found.");              if (dimensionRegionNr == 0) throw gig::Exception("No dimension region found.");
3511          }          }
# Line 4324  namespace { Line 4325  namespace {
4325              uint64_t soughtoffset =              uint64_t soughtoffset =
4326                  uint64_t(file->pWavePoolTable[WavePoolTableIndex]) |                  uint64_t(file->pWavePoolTable[WavePoolTableIndex]) |
4327                  uint64_t(file->pWavePoolTableHi[WavePoolTableIndex]) << 32;                  uint64_t(file->pWavePoolTableHi[WavePoolTableIndex]) << 32;
4328              Sample* sample = file->GetFirstSample(pProgress);              size_t i = 0;
4329              while (sample) {              for (Sample* sample = file->GetSample(i, pProgress); sample;
4330                             sample = file->GetSample(++i))
4331                {
4332                  if (sample->ullWavePoolOffset == soughtoffset)                  if (sample->ullWavePoolOffset == soughtoffset)
4333                      return static_cast<gig::Sample*>(sample);                      return sample;
                 sample = file->GetNextSample();  
4334              }              }
4335          } else {          } else {
4336              // use extension files and 32 bit wave pool offsets              // use extension files and 32 bit wave pool offsets
4337              file_offset_t soughtoffset = file->pWavePoolTable[WavePoolTableIndex];              file_offset_t soughtoffset = file->pWavePoolTable[WavePoolTableIndex];
4338              file_offset_t soughtfileno = file->pWavePoolTableHi[WavePoolTableIndex];              file_offset_t soughtfileno = file->pWavePoolTableHi[WavePoolTableIndex];
4339              Sample* sample = file->GetFirstSample(pProgress);              size_t i = 0;
4340              while (sample) {              for (Sample* sample = file->GetSample(i, pProgress); sample;
4341                             sample = file->GetSample(++i))
4342                {
4343                  if (sample->ullWavePoolOffset == soughtoffset &&                  if (sample->ullWavePoolOffset == soughtoffset &&
4344                      sample->FileNo == soughtfileno) return static_cast<gig::Sample*>(sample);                      sample->FileNo == soughtfileno) return sample;
                 sample = file->GetNextSample();  
4345              }              }
4346          }          }
4347          return NULL;          return NULL;
# Line 4906  namespace { Line 4909  namespace {
4909          pScripts = new std::list<Script*>;          pScripts = new std::list<Script*>;
4910          if (!pList) return;          if (!pList) return;
4911    
4912          for (RIFF::Chunk* ck = pList->GetFirstSubChunk(); ck;          size_t i = 0;
4913               ck = pList->GetNextSubChunk())          for (RIFF::Chunk* ck = pList->GetSubChunkAt(i); ck;
4914                 ck = pList->GetSubChunkAt(++i))
4915          {          {
4916              if (ck->GetChunkID() == CHUNK_ID_SCRI) {              if (ck->GetChunkID() == CHUNK_ID_SCRI) {
4917                  pScripts->push_back(new Script(this, ck));                  pScripts->push_back(new Script(this, ck));
# Line 4987  namespace { Line 4991  namespace {
4991              if (!pRegions) pRegions = new RegionList;              if (!pRegions) pRegions = new RegionList;
4992              RIFF::List* lrgn = insList->GetSubList(LIST_TYPE_LRGN);              RIFF::List* lrgn = insList->GetSubList(LIST_TYPE_LRGN);
4993              if (lrgn) {              if (lrgn) {
4994                  RIFF::List* rgn = lrgn->GetFirstSubList();                  size_t i = 0;
4995                  while (rgn) {                  for (RIFF::List* rgn = lrgn->GetSubListAt(i); rgn;
4996                         rgn = lrgn->GetSubListAt(++i))
4997                    {
4998                      if (rgn->GetListType() == LIST_TYPE_RGN) {                      if (rgn->GetListType() == LIST_TYPE_RGN) {
4999                          if (pProgress)                          if (pProgress)
5000                              __notify_progress(pProgress, (float) pRegions->size() / (float) Regions);                              __notify_progress(pProgress, (float) pRegions->size() / (float) Regions);
5001                          pRegions->push_back(new Region(this, rgn));                          pRegions->push_back(new Region(this, rgn));
5002                      }                      }
                     rgn = lrgn->GetNextSubList();  
5003                  }                  }
5004                  // Creating Region Key Table for fast lookup                  // Creating Region Key Table for fast lookup
5005                  UpdateRegionKeyTable();                  UpdateRegionKeyTable();
# Line 5298  namespace { Line 5303  namespace {
5303      }      }
5304    
5305      /**      /**
5306         * Returns Region at supplied @a pos position within the region list of
5307         * this instrument. If supplied @a pos is out of bounds then @c NULL is
5308         * returned.
5309         *
5310         * @param pos - position of sought Region in region list
5311         * @returns pointer address to requested region or @c NULL if @a pos is
5312         *          out of bounds
5313         */
5314        Region* Instrument::GetRegionAt(size_t pos) {
5315            if (!pRegions) return NULL;
5316            if (pos >= pRegions->size()) return NULL;
5317            return static_cast<gig::Region*>( (*pRegions)[pos] );
5318        }
5319    
5320        /**
5321       * Returns the first Region of the instrument. You have to call this       * Returns the first Region of the instrument. You have to call this
5322       * method once before you use GetNextRegion().       * method once before you use GetNextRegion().
5323       *       *
5324       * @returns  pointer address to first region or NULL if there is none       * @returns  pointer address to first region or NULL if there is none
5325       * @see      GetNextRegion()       * @see      GetNextRegion()
5326         * @deprecated  This method is not reentrant-safe, use GetRegionAt()
5327         *              instead.
5328       */       */
5329      Region* Instrument::GetFirstRegion() {      Region* Instrument::GetFirstRegion() {
5330          if (!pRegions) return NULL;          if (!pRegions) return NULL;
# Line 5317  namespace { Line 5339  namespace {
5339       *       *
5340       * @returns  pointer address to the next region or NULL if end reached       * @returns  pointer address to the next region or NULL if end reached
5341       * @see      GetFirstRegion()       * @see      GetFirstRegion()
5342         * @deprecated  This method is not reentrant-safe, use GetRegionAt()
5343         *              instead.
5344       */       */
5345      Region* Instrument::GetNextRegion() {      Region* Instrument::GetNextRegion() {
5346          if (!pRegions) return NULL;          if (!pRegions) return NULL;
# Line 5983  namespace { Line 6007  namespace {
6007          pMidiRules[0] = NULL;          pMidiRules[0] = NULL;
6008                    
6009          // delete all old regions          // delete all old regions
6010          while (Regions) DeleteRegion(GetFirstRegion());          while (Regions) DeleteRegion(GetRegionAt(0));
6011          // create new regions and copy them from original          // create new regions and copy them from original
6012          {          {
6013              RegionList::const_iterator it = orig->pRegions->begin();              RegionList::const_iterator it = orig->pRegions->begin();
# Line 6039  namespace { Line 6063  namespace {
6063      Group::Group(File* file, RIFF::Chunk* ck3gnm) {      Group::Group(File* file, RIFF::Chunk* ck3gnm) {
6064          pFile      = file;          pFile      = file;
6065          pNameChunk = ck3gnm;          pNameChunk = ck3gnm;
6066            SamplesIterator = 0;
6067          ::LoadString(pNameChunk, Name);          ::LoadString(pNameChunk, Name);
6068      }      }
6069    
# Line 6083  namespace { Line 6108  namespace {
6108    
6109          if (!pNameChunk && pFile->pVersion && pFile->pVersion->major > 2) {          if (!pNameChunk && pFile->pVersion && pFile->pVersion->major > 2) {
6110              // v3 has a fixed list of 128 strings, find a free one              // v3 has a fixed list of 128 strings, find a free one
6111              for (RIFF::Chunk* ck = _3gnl->GetFirstSubChunk() ; ck ; ck = _3gnl->GetNextSubChunk()) {              size_t i = 0;
6112                for (RIFF::Chunk* ck = _3gnl->GetSubChunkAt(i); ck; ck = _3gnl->GetSubChunkAt(++i)) {
6113                  if (strcmp(static_cast<char*>(ck->LoadChunkData()), "") == 0) {                  if (strcmp(static_cast<char*>(ck->LoadChunkData()), "") == 0) {
6114                      pNameChunk = ck;                      pNameChunk = ck;
6115                      break;                      break;
# Line 6096  namespace { Line 6122  namespace {
6122      }      }
6123    
6124      /**      /**
6125         * Returns Sample object at @a index of this sample group.
6126         *
6127         * @param index - position of sample in this sample group's sample list
6128         *                (0..n)
6129         * @returns sample object or NULL if index is out of bounds
6130         */
6131        Sample* Group::GetSample(size_t index) {
6132            if (pFile->pSamples && index >= pFile->pSamples->size()) return NULL;
6133            size_t indexInFile = 0;
6134            size_t indexInGroup = 0;
6135            for (Sample* pSample = pFile->GetSample(indexInFile); pSample;
6136                         pSample = pFile->GetSample(++indexInFile))
6137            {
6138                if (pSample->GetGroup() != this) continue;
6139                if (indexInGroup++ == index) return pSample;
6140            }
6141            return NULL;
6142        }
6143    
6144        /**
6145       * Returns the first Sample of this Group. You have to call this method       * Returns the first Sample of this Group. You have to call this method
6146       * once before you use GetNextSample().       * once before you use GetNextSample().
6147       *       *
# Line 6105  namespace { Line 6151  namespace {
6151       * @returns  pointer address to first Sample or NULL if there is none       * @returns  pointer address to first Sample or NULL if there is none
6152       *           applied to this Group       *           applied to this Group
6153       * @see      GetNextSample()       * @see      GetNextSample()
6154         * @deprecated  This method is not reentrant-safe, use GetSample()
6155         *              instead.
6156       */       */
6157      Sample* Group::GetFirstSample() {      Sample* Group::GetFirstSample() {
6158          // FIXME: lazy und unsafe implementation, should be an autonomous iterator          size_t& i = this->SamplesIterator;
6159          for (Sample* pSample = pFile->GetFirstSample(); pSample; pSample = pFile->GetNextSample()) {          i = 0;
6160              if (pSample->GetGroup() == this) return pSample;          for (Sample* pSample = pFile->GetSample(i); pSample;
6161                         pSample = pFile->GetSample(++i))
6162            {
6163                if (pSample->GetGroup() == this)
6164                    return pSample;
6165          }          }
6166          return NULL;          return NULL;
6167      }      }
# Line 6123  namespace { Line 6175  namespace {
6175       * @returns  pointer address to the next Sample of this Group or NULL if       * @returns  pointer address to the next Sample of this Group or NULL if
6176       *           end reached       *           end reached
6177       * @see      GetFirstSample()       * @see      GetFirstSample()
6178         * @deprecated  This method is not reentrant-safe, use GetSample()
6179         *              instead.
6180       */       */
6181      Sample* Group::GetNextSample() {      Sample* Group::GetNextSample() {
6182          // FIXME: lazy und unsafe implementation, should be an autonomous iterator          size_t& i = this->SamplesIterator;
6183          for (Sample* pSample = pFile->GetNextSample(); pSample; pSample = pFile->GetNextSample()) {          for (Sample* pSample = pFile->GetSample(++i); pSample;
6184              if (pSample->GetGroup() == this) return pSample;                       pSample = pFile->GetSample(++i))
6185            {
6186                if (pSample->GetGroup() == this)
6187                    return pSample;
6188          }          }
6189          return NULL;          return NULL;
6190      }      }
# Line 6247  namespace { Line 6304  namespace {
6304          }          }
6305      }      }
6306    
6307        /**
6308         * Returns a pointer to the first <i>Sample</i> object of the file,
6309         * <i>NULL</i> otherwise.
6310         *
6311         * @param pProgress - optional: callback function for progress notification
6312         * @deprecated  This method is not reentrant-safe, use GetSample()
6313         *              instead.
6314         */
6315      Sample* File::GetFirstSample(progress_t* pProgress) {      Sample* File::GetFirstSample(progress_t* pProgress) {
6316          if (!pSamples) LoadSamples(pProgress);          if (!pSamples) LoadSamples(pProgress);
6317          if (!pSamples) return NULL;          if (!pSamples) return NULL;
# Line 6254  namespace { Line 6319  namespace {
6319          return static_cast<gig::Sample*>( (SamplesIterator != pSamples->end()) ? *SamplesIterator : NULL );          return static_cast<gig::Sample*>( (SamplesIterator != pSamples->end()) ? *SamplesIterator : NULL );
6320      }      }
6321    
6322        /**
6323         * Returns a pointer to the next <i>Sample</i> object of the file,
6324         * <i>NULL</i> otherwise.
6325         *
6326         * @deprecated  This method is not reentrant-safe, use GetSample()
6327         *              instead.
6328         */
6329      Sample* File::GetNextSample() {      Sample* File::GetNextSample() {
6330          if (!pSamples) return NULL;          if (!pSamples) return NULL;
6331          SamplesIterator++;          SamplesIterator++;
# Line 6263  namespace { Line 6335  namespace {
6335      /**      /**
6336       * Returns Sample object of @a index.       * Returns Sample object of @a index.
6337       *       *
6338         * @param index - position of sample in sample list (0..n)
6339         * @param pProgress - optional: callback function for progress notification
6340       * @returns sample object or NULL if index is out of bounds       * @returns sample object or NULL if index is out of bounds
6341       */       */
6342      Sample* File::GetSample(uint index) {      Sample* File::GetSample(size_t index, progress_t* pProgress) {
6343          if (!pSamples) LoadSamples();          if (!pSamples) LoadSamples(pProgress);
6344          if (!pSamples) return NULL;          if (!pSamples) return NULL;
6345          DLS::File::SampleList::iterator it = pSamples->begin();          if (index >= pSamples->size()) return NULL;
6346          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 );  
6347      }      }
6348    
6349      /**      /**
# Line 6336  namespace { Line 6405  namespace {
6405          // remove all references to the sample          // remove all references to the sample
6406          for (Instrument* instrument = GetFirstInstrument() ; instrument ;          for (Instrument* instrument = GetFirstInstrument() ; instrument ;
6407               instrument = GetNextInstrument()) {               instrument = GetNextInstrument()) {
6408              for (Region* region = instrument->GetFirstRegion() ; region ;              size_t iRgn = 0;
6409                   region = instrument->GetNextRegion()) {              for (Region* region = instrument->GetRegionAt(iRgn); region;
6410                     region = instrument->GetRegionAt(++iRgn))
6411                {
6412                  if (region->GetSample() == pSample) region->SetSample(NULL);                  if (region->GetSample() == pSample) region->SetSample(NULL);
6413    
6414                  for (int i = 0 ; i < region->DimensionRegions ; i++) {                  for (int i = 0 ; i < region->DimensionRegions ; i++) {
# Line 6361  namespace { Line 6431  namespace {
6431    
6432          if (!pSamples) pSamples = new SampleList;          if (!pSamples) pSamples = new SampleList;
6433    
         RIFF::File* file = pRIFF;  
   
6434          // just for progress calculation          // just for progress calculation
6435          int iSampleIndex  = 0;          int iSampleIndex  = 0;
6436          int iTotalSamples = WavePoolCount;          int iTotalSamples = WavePoolCount;
# Line 6443  namespace { Line 6511  namespace {
6511              if (wvpl) {              if (wvpl) {
6512                  file_offset_t wvplFileOffset = wvpl->GetFilePos() -                  file_offset_t wvplFileOffset = wvpl->GetFilePos() -
6513                                                 wvpl->GetPos(); // should be zero, but just to be sure                                                 wvpl->GetPos(); // should be zero, but just to be sure
6514                  RIFF::List* wave = wvpl->GetFirstSubList();                  size_t i = 0;
6515                  while (wave) {                  for (RIFF::List* wave = wvpl->GetSubListAt(i); wave;
6516                         wave = wvpl->GetSubListAt(++i))
6517                    {
6518                      if (wave->GetListType() == LIST_TYPE_WAVE) {                      if (wave->GetListType() == LIST_TYPE_WAVE) {
6519                          // notify current progress                          // notify current progress
6520                          if (pProgress) {                          if (pProgress) {
# Line 6457  namespace { Line 6527  namespace {
6527    
6528                          iSampleIndex++;                          iSampleIndex++;
6529                      }                      }
                     wave = wvpl->GetNextSubList();  
6530                  }                  }
6531              }              }
6532          }          }
# Line 6510  namespace { Line 6579  namespace {
6579                  __divide_progress(pProgress, &subprogress, 3.0f, 0.0f); // randomly schedule 33% for this subtask                  __divide_progress(pProgress, &subprogress, 3.0f, 0.0f); // randomly schedule 33% for this subtask
6580                  __notify_progress(&subprogress, 0.0f);                  __notify_progress(&subprogress, 0.0f);
6581                  if (GetAutoLoad())                  if (GetAutoLoad())
6582                      GetFirstSample(&subprogress); // now force all samples to be loaded                      GetSample(0, &subprogress); // now force all samples to be loaded
6583                  __notify_progress(&subprogress, 1.0f);                  __notify_progress(&subprogress, 1.0f);
6584    
6585                  // instrument loading subtask                  // instrument loading subtask
# Line 6524  namespace { Line 6593  namespace {
6593              } else {              } else {
6594                  // sample loading subtask                  // sample loading subtask
6595                  if (GetAutoLoad())                  if (GetAutoLoad())
6596                      GetFirstSample(); // now force all samples to be loaded                      GetSample(0); // now force all samples to be loaded
6597    
6598                  // instrument loading subtask                  // instrument loading subtask
6599                  LoadInstruments();                  LoadInstruments();
# Line 6690  namespace { Line 6759  namespace {
6759          RIFF::List* lstInstruments = pRIFF->GetSubList(LIST_TYPE_LINS);          RIFF::List* lstInstruments = pRIFF->GetSubList(LIST_TYPE_LINS);
6760          if (lstInstruments) {          if (lstInstruments) {
6761              int iInstrumentIndex = 0;              int iInstrumentIndex = 0;
6762              RIFF::List* lstInstr = lstInstruments->GetFirstSubList();              size_t i = 0;
6763              while (lstInstr) {              for (RIFF::List* lstInstr = lstInstruments->GetSubListAt(i);
6764                     lstInstr; lstInstr = lstInstruments->GetSubListAt(++i))
6765                {
6766                  if (lstInstr->GetListType() == LIST_TYPE_INS) {                  if (lstInstr->GetListType() == LIST_TYPE_INS) {
6767                      if (pProgress) {                      if (pProgress) {
6768                          // notify current progress                          // notify current progress
# Line 6709  namespace { Line 6780  namespace {
6780    
6781                      iInstrumentIndex++;                      iInstrumentIndex++;
6782                  }                  }
                 lstInstr = lstInstruments->GetNextSubList();  
6783              }              }
6784              if (pProgress)              if (pProgress)
6785                  __notify_progress(pProgress, 1.0); // notify done                  __notify_progress(pProgress, 1.0); // notify done
# Line 6763  namespace { Line 6833  namespace {
6833      }      }
6834    
6835      int File::GetWaveTableIndexOf(gig::Sample* pSample) {      int File::GetWaveTableIndexOf(gig::Sample* pSample) {
6836          if (!pSamples) GetFirstSample(); // make sure sample chunks were scanned          if (!pSamples) GetSample(0); // make sure sample chunks were scanned
6837          File::SampleList::iterator iter = pSamples->begin();          File::SampleList::iterator iter = pSamples->begin();
6838          File::SampleList::iterator end  = pSamples->end();          File::SampleList::iterator end  = pSamples->end();
6839          for (int index = 0; iter != end; ++iter, ++index)          for (int index = 0; iter != end; ++iter, ++index)
# Line 6783  namespace { Line 6853  namespace {
6853          if (!_3crc) return false;          if (!_3crc) return false;
6854          if (_3crc->GetNewSize() <= 0) return false;          if (_3crc->GetNewSize() <= 0) return false;
6855          if (_3crc->GetNewSize() % 8) return false;          if (_3crc->GetNewSize() % 8) return false;
6856          if (!pSamples) GetFirstSample(); // make sure sample chunks were scanned          if (!pSamples) GetSample(0); // make sure sample chunks were scanned
6857          if (_3crc->GetNewSize() != pSamples->size() * 8) return false;          if (_3crc->GetNewSize() != pSamples->size() * 8) return false;
6858    
6859          const file_offset_t n = _3crc->GetNewSize() / 8;          const file_offset_t n = _3crc->GetNewSize() / 8;
# Line 6817  namespace { Line 6887  namespace {
6887       */       */
6888      bool File::RebuildSampleChecksumTable() {      bool File::RebuildSampleChecksumTable() {
6889          // make sure sample chunks were scanned          // make sure sample chunks were scanned
6890          if (!pSamples) GetFirstSample();          if (!pSamples) GetSample(0);
6891    
6892          bool bRequiresSave = false;          bool bRequiresSave = false;
6893    
# Line 6975  namespace { Line 7045  namespace {
7045          if (lst3gri) {          if (lst3gri) {
7046              RIFF::List* lst3gnl = lst3gri->GetSubList(LIST_TYPE_3GNL);              RIFF::List* lst3gnl = lst3gri->GetSubList(LIST_TYPE_3GNL);
7047              if (lst3gnl) {              if (lst3gnl) {
7048                  RIFF::Chunk* ck = lst3gnl->GetFirstSubChunk();                  size_t i = 0;
7049                  while (ck) {                  for (RIFF::Chunk* ck = lst3gnl->GetSubChunkAt(i); ck;
7050                         ck = lst3gnl->GetSubChunkAt(++i))
7051                    {
7052                      if (ck->GetChunkID() == CHUNK_ID_3GNM) {                      if (ck->GetChunkID() == CHUNK_ID_3GNM) {
7053                          if (pVersion && pVersion->major > 2 &&                          if (pVersion && pVersion->major > 2 &&
7054                              strcmp(static_cast<char*>(ck->LoadChunkData()), "") == 0) break;                              strcmp(static_cast<char*>(ck->LoadChunkData()), "") == 0) break;
7055    
7056                          pGroups->push_back(new Group(this, ck));                          pGroups->push_back(new Group(this, ck));
7057                      }                      }
                     ck = lst3gnl->GetNextSubChunk();  
7058                  }                  }
7059              }              }
7060          }          }
# Line 7073  namespace { Line 7144  namespace {
7144          pScriptGroups = new std::list<ScriptGroup*>;          pScriptGroups = new std::list<ScriptGroup*>;
7145          RIFF::List* lstLS = pRIFF->GetSubList(LIST_TYPE_3LS);          RIFF::List* lstLS = pRIFF->GetSubList(LIST_TYPE_3LS);
7146          if (lstLS) {          if (lstLS) {
7147              for (RIFF::List* lst = lstLS->GetFirstSubList(); lst;              size_t i = 0;
7148                   lst = lstLS->GetNextSubList())              for (RIFF::List* lst = lstLS->GetSubListAt(i); lst;
7149                     lst = lstLS->GetSubListAt(++i))
7150              {              {
7151                  if (lst->GetListType() == LIST_TYPE_RTIS) {                  if (lst->GetListType() == LIST_TYPE_RTIS) {
7152                      pScriptGroups->push_back(new ScriptGroup(this, lst));                      pScriptGroups->push_back(new ScriptGroup(this, lst));
# Line 7135  namespace { Line 7207  namespace {
7207              // INFO was added by Resource::UpdateChunks - make sure it              // INFO was added by Resource::UpdateChunks - make sure it
7208              // is placed first in file              // is placed first in file
7209              RIFF::Chunk* info = pRIFF->GetSubList(LIST_TYPE_INFO);              RIFF::Chunk* info = pRIFF->GetSubList(LIST_TYPE_INFO);
7210              RIFF::Chunk* first = pRIFF->GetFirstSubChunk();              RIFF::Chunk* first = pRIFF->GetSubChunkAt(0);
7211              if (first != info) {              if (first != info) {
7212                  pRIFF->MoveSubChunk(info, first);                  pRIFF->MoveSubChunk(info, first);
7213              }              }
# Line 7156  namespace { Line 7228  namespace {
7228              // v3: make sure the file has 128 3gnm chunks              // v3: make sure the file has 128 3gnm chunks
7229              // (before updating the Group chunks)              // (before updating the Group chunks)
7230              if (pVersion && pVersion->major > 2) {              if (pVersion && pVersion->major > 2) {
7231                  RIFF::Chunk* _3gnm = _3gnl->GetFirstSubChunk();                  size_t i = 0;
7232                  for (int i = 0 ; i < 128 ; i++) {                  for (RIFF::Chunk* _3gnm = _3gnl->GetSubChunkAt(i); i < 128;
7233                         _3gnm = _3gnl->GetSubChunkAt(++i))
7234                    {
7235                      // create 128 empty placeholder strings which will either                      // create 128 empty placeholder strings which will either
7236                      // be filled by Group::UpdateChunks below or left empty.                      // be filled by Group::UpdateChunks below or left empty.
7237                      ::SaveString(CHUNK_ID_3GNM, _3gnm, _3gnl, "", "", true, 64);                      ::SaveString(CHUNK_ID_3GNM, _3gnm, _3gnl, "", "", true, 64);
                     if (_3gnm) _3gnm = _3gnl->GetNextSubChunk();  
7238                  }                  }
7239              }              }
7240    
# Line 7204  namespace { Line 7277  namespace {
7277              uint8_t* pData = (uint8_t*) einf->LoadChunkData();              uint8_t* pData = (uint8_t*) einf->LoadChunkData();
7278    
7279              std::map<gig::Sample*,int> sampleMap;              std::map<gig::Sample*,int> sampleMap;
7280              int sampleIdx = 0;              size_t sampleIdx = 0;
7281              for (Sample* pSample = GetFirstSample(); pSample; pSample = GetNextSample()) {              for (Sample* pSample = GetSample(0); pSample;
7282                  sampleMap[pSample] = sampleIdx++;                           pSample = GetSample(++sampleIdx))
7283                {
7284                    sampleMap[pSample] = sampleIdx;
7285              }              }
7286    
7287              int totnbusedsamples = 0;              int totnbusedsamples = 0;
# Line 7227  namespace { Line 7302  namespace {
7302    
7303                  memset(&pData[(instrumentIdx + 1) * sublen + 48], 0, sublen - 48);                  memset(&pData[(instrumentIdx + 1) * sublen + 48], 0, sublen - 48);
7304    
7305                  for (Region* region = instrument->GetFirstRegion() ; region ;                  size_t iRgn = 0;
7306                       region = instrument->GetNextRegion()) {                  for (Region* region = instrument->GetRegionAt(iRgn); region;
7307                         region = instrument->GetRegionAt(++iRgn))
7308                    {
7309                      for (int i = 0 ; i < region->DimensionRegions ; i++) {                      for (int i = 0 ; i < region->DimensionRegions ; i++) {
7310                          gig::DimensionRegion *d = region->pDimensionRegions[i];                          gig::DimensionRegion *d = region->pDimensionRegions[i];
7311                          if (d->pSample) {                          if (d->pSample) {

Legend:
Removed from v.3904  
changed lines
  Added in v.3933

  ViewVC Help
Powered by ViewVC