/[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 3945 by schoenebeck, Fri Jun 18 15:46:44 2021 UTC revision 3950 by schoenebeck, Sat Jun 19 09:02:55 2021 UTC
# Line 4801  namespace { Line 4801  namespace {
4801    
4802      ScriptGroup::~ScriptGroup() {      ScriptGroup::~ScriptGroup() {
4803          if (pScripts) {          if (pScripts) {
4804              std::list<Script*>::iterator iter = pScripts->begin();              std::vector<Script*>::iterator iter = pScripts->begin();
4805              std::list<Script*>::iterator end  = pScripts->end();              std::vector<Script*>::iterator end  = pScripts->end();
4806              while (iter != end) {              while (iter != end) {
4807                  delete *iter;                  delete *iter;
4808                  ++iter;                  ++iter;
# Line 4840  namespace { Line 4840  namespace {
4840              // now store the name of this group as <LSNM> chunk as subchunk of the <RTIS> list chunk              // now store the name of this group as <LSNM> chunk as subchunk of the <RTIS> list chunk
4841              ::SaveString(CHUNK_ID_LSNM, NULL, pList, Name, String("Unnamed Group"), true, 64);              ::SaveString(CHUNK_ID_LSNM, NULL, pList, Name, String("Unnamed Group"), true, 64);
4842    
4843              for (std::list<Script*>::iterator it = pScripts->begin();              for (std::vector<Script*>::iterator it = pScripts->begin();
4844                   it != pScripts->end(); ++it)                   it != pScripts->end(); ++it)
4845              {              {
4846                  (*it)->UpdateChunks(pProgress);                  (*it)->UpdateChunks(pProgress);
# Line 4857  namespace { Line 4857  namespace {
4857       */       */
4858      Script* ScriptGroup::GetScript(uint index) {      Script* ScriptGroup::GetScript(uint index) {
4859          if (!pScripts) LoadScripts();          if (!pScripts) LoadScripts();
4860          std::list<Script*>::iterator it = pScripts->begin();          if (index >= pScripts->size()) return NULL;
4861          for (uint i = 0; it != pScripts->end(); ++i, ++it)          return (*pScripts)[index];
             if (i == index) return *it;  
         return NULL;  
4862      }      }
4863    
4864      /** @brief Add new instrument script.      /** @brief Add new instrument script.
# Line 4893  namespace { Line 4891  namespace {
4891       */       */
4892      void ScriptGroup::DeleteScript(Script* pScript) {      void ScriptGroup::DeleteScript(Script* pScript) {
4893          if (!pScripts) LoadScripts();          if (!pScripts) LoadScripts();
4894          std::list<Script*>::iterator iter =          std::vector<Script*>::iterator iter =
4895              find(pScripts->begin(), pScripts->end(), pScript);              find(pScripts->begin(), pScripts->end(), pScript);
4896          if (iter == pScripts->end())          if (iter == pScripts->end())
4897              throw gig::Exception("Could not delete script, could not find given script");              throw gig::Exception("Could not delete script, could not find given script");
# Line 4906  namespace { Line 4904  namespace {
4904    
4905      void ScriptGroup::LoadScripts() {      void ScriptGroup::LoadScripts() {
4906          if (pScripts) return;          if (pScripts) return;
4907          pScripts = new std::list<Script*>;          pScripts = new std::vector<Script*>;
4908          if (!pList) return;          if (!pList) return;
4909    
4910          size_t i = 0;          size_t i = 0;
# Line 5503  namespace { Line 5501  namespace {
5501          File* pFile = (File*) GetParent();          File* pFile = (File*) GetParent();
5502          for (uint k = 0; k < scriptPoolFileOffsets.size(); ++k) {          for (uint k = 0; k < scriptPoolFileOffsets.size(); ++k) {
5503              uint32_t soughtOffset = scriptPoolFileOffsets[k].fileOffset;              uint32_t soughtOffset = scriptPoolFileOffsets[k].fileOffset;
5504              for (uint i = 0; pFile->GetScriptGroup(i); ++i) {              for (size_t i = 0; pFile->GetScriptGroup(i); ++i) {
5505                  ScriptGroup* group = pFile->GetScriptGroup(i);                  ScriptGroup* group = pFile->GetScriptGroup(i);
5506                  for (uint s = 0; group->GetScript(s); ++s) {                  for (uint s = 0; group->GetScript(s); ++s) {
5507                      Script* script = group->GetScript(s);                      Script* script = group->GetScript(s);
# Line 6305  namespace { Line 6303  namespace {
6303              delete pGroups;              delete pGroups;
6304          }          }
6305          if (pScriptGroups) {          if (pScriptGroups) {
6306              std::list<ScriptGroup*>::iterator iter = pScriptGroups->begin();              std::vector<ScriptGroup*>::iterator iter = pScriptGroups->begin();
6307              std::list<ScriptGroup*>::iterator end  = pScriptGroups->end();              std::vector<ScriptGroup*>::iterator end  = pScriptGroups->end();
6308              while (iter != end) {              while (iter != end) {
6309                  delete *iter;                  delete *iter;
6310                  ++iter;                  ++iter;
# Line 6412  namespace { Line 6410  namespace {
6410          pSample->DeleteChunks();          pSample->DeleteChunks();
6411          delete pSample;          delete pSample;
6412    
         SampleList::iterator tmp = SamplesIterator;  
6413          // remove all references to the sample          // remove all references to the sample
6414          size_t iIns = 0;          size_t iIns = 0;
6415          for (Instrument* instrument = GetInstrument(iIns); instrument;          for (Instrument* instrument = GetInstrument(iIns); instrument;
# Line 6430  namespace { Line 6427  namespace {
6427                  }                  }
6428              }              }
6429          }          }
         SamplesIterator = tmp; // restore iterator  
6430      }      }
6431    
6432      void File::LoadSamples() {      void File::LoadSamples() {
# Line 6715  namespace { Line 6711  namespace {
6711          }          }
6712    
6713          // clone script groups and their scripts          // clone script groups and their scripts
6714          for (int iGroup = 0; pFile->GetScriptGroup(iGroup); ++iGroup) {          for (size_t iGroup = 0; pFile->GetScriptGroup(iGroup); ++iGroup) {
6715              ScriptGroup* sg = pFile->GetScriptGroup(iGroup);              ScriptGroup* sg = pFile->GetScriptGroup(iGroup);
6716              ScriptGroup* dg = AddScriptGroup();              ScriptGroup* dg = AddScriptGroup();
6717              dg->Name = "COPY" + ToString(iCallCount) + "_" + sg->Name;              dg->Name = "COPY" + ToString(iCallCount) + "_" + sg->Name;
# Line 7107  namespace { Line 7103  namespace {
7103       * @param index - number of the sought group (0..n)       * @param index - number of the sought group (0..n)
7104       * @returns sought script group or NULL if there's no such group       * @returns sought script group or NULL if there's no such group
7105       */       */
7106      ScriptGroup* File::GetScriptGroup(uint index) {      ScriptGroup* File::GetScriptGroup(size_t index) {
7107          if (!pScriptGroups) LoadScriptGroups();          if (!pScriptGroups) LoadScriptGroups();
7108          std::list<ScriptGroup*>::iterator it = pScriptGroups->begin();          if (index >= pScriptGroups->size()) return NULL;
7109          for (uint i = 0; it != pScriptGroups->end(); ++i, ++it)          return (*pScriptGroups)[index];
             if (i == index) return *it;  
         return NULL;  
7110      }      }
7111    
7112      /** @brief Get instrument script group (by name).      /** @brief Get instrument script group (by name).
# Line 7125  namespace { Line 7119  namespace {
7119       */       */
7120      ScriptGroup* File::GetScriptGroup(const String& name) {      ScriptGroup* File::GetScriptGroup(const String& name) {
7121          if (!pScriptGroups) LoadScriptGroups();          if (!pScriptGroups) LoadScriptGroups();
7122          std::list<ScriptGroup*>::iterator it = pScriptGroups->begin();          for (size_t i = 0; i < pScriptGroups->size(); ++i) {
7123          for (uint i = 0; it != pScriptGroups->end(); ++i, ++it)              ScriptGroup* pGroup = (*pScriptGroups)[i];
7124              if ((*it)->Name == name) return *it;              if (pGroup->Name == name) return pGroup;
7125            }
7126          return NULL;          return NULL;
7127      }      }
7128    
# Line 7160  namespace { Line 7155  namespace {
7155       */       */
7156      void File::DeleteScriptGroup(ScriptGroup* pScriptGroup) {      void File::DeleteScriptGroup(ScriptGroup* pScriptGroup) {
7157          if (!pScriptGroups) LoadScriptGroups();          if (!pScriptGroups) LoadScriptGroups();
7158          std::list<ScriptGroup*>::iterator iter =          std::vector<ScriptGroup*>::iterator iter =
7159              find(pScriptGroups->begin(), pScriptGroups->end(), pScriptGroup);              find(pScriptGroups->begin(), pScriptGroups->end(), pScriptGroup);
7160          if (iter == pScriptGroups->end())          if (iter == pScriptGroups->end())
7161              throw gig::Exception("Could not delete script group, could not find given script group");              throw gig::Exception("Could not delete script group, could not find given script group");
# Line 7175  namespace { Line 7170  namespace {
7170    
7171      void File::LoadScriptGroups() {      void File::LoadScriptGroups() {
7172          if (pScriptGroups) return;          if (pScriptGroups) return;
7173          pScriptGroups = new std::list<ScriptGroup*>;          pScriptGroups = new std::vector<ScriptGroup*>;
7174          RIFF::List* lstLS = pRIFF->GetSubList(LIST_TYPE_3LS);          RIFF::List* lstLS = pRIFF->GetSubList(LIST_TYPE_3LS);
7175          if (lstLS) {          if (lstLS) {
7176              size_t i = 0;              size_t i = 0;
# Line 7220  namespace { Line 7215  namespace {
7215          // of the respective instrument script chunk as reference.          // of the respective instrument script chunk as reference.
7216          if (pScriptGroups) {          if (pScriptGroups) {
7217              // Update instrument script (group) chunks.              // Update instrument script (group) chunks.
7218              for (std::list<ScriptGroup*>::iterator it = pScriptGroups->begin();              for (std::vector<ScriptGroup*>::iterator it = pScriptGroups->begin();
7219                   it != pScriptGroups->end(); ++it)                   it != pScriptGroups->end(); ++it)
7220              {              {
7221                  (*it)->UpdateChunks(pProgress);                  (*it)->UpdateChunks(pProgress);

Legend:
Removed from v.3945  
changed lines
  Added in v.3950

  ViewVC Help
Powered by ViewVC