/[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 3958 by schoenebeck, Sat Jun 19 10:48:12 2021 UTC revision 3975 by schoenebeck, Sat Jul 17 21:10:19 2021 UTC
# Line 1346  namespace { Line 1346  namespace {
1346    
1347          // if this is the last write, update the checksum chunk in the          // if this is the last write, update the checksum chunk in the
1348          // file          // file
1349          if (pCkData->GetPos() == pCkData->GetSize()) {          if (pCkData->GetPos() == std::min(pCkData->GetSize(), pCkData->GetNewSize())) {
1350              __finalizeCRC(crc);              __finalizeCRC(crc);
1351              File* pFile = static_cast<File*>(GetParent());              File* pFile = static_cast<File*>(GetParent());
1352              pFile->SetSampleChecksum(this, crc);              pFile->SetSampleChecksum(this, crc);
# Line 5308  namespace { Line 5308  namespace {
5308       * @param pos - position of sought Region in region list       * @param pos - position of sought Region in region list
5309       * @returns pointer address to requested region or @c NULL if @a pos is       * @returns pointer address to requested region or @c NULL if @a pos is
5310       *          out of bounds       *          out of bounds
5311         * @see CountRegions()
5312       */       */
5313      Region* Instrument::GetRegionAt(size_t pos) {      Region* Instrument::GetRegionAt(size_t pos) {
5314          if (!pRegions) return NULL;          if (!pRegions) return NULL;
# Line 5776  namespace { Line 5777  namespace {
5777       *       *
5778       * @param slot - script slot index of the variable to be retrieved       * @param slot - script slot index of the variable to be retrieved
5779       */       */
5780      std::map<String,String> Instrument::GetScriptPatchVariables(int slot) {      std::map<String,String> Instrument::GetScriptPatchVariables(size_t slot) {
5781          Script* script = GetScriptOfSlot(slot);          Script* script = GetScriptOfSlot(slot);
5782          if (!script) return std::map<String,String>();          if (!script) return std::map<String,String>();
5783          const _UUID uuid = _UUIDFromCArray(&script->Uuid[0]);          const _UUID uuid = _UUIDFromCArray(&script->Uuid[0]);
# Line 5808  namespace { Line 5809  namespace {
5809       * @param slot - script slot index of the variable to be retrieved       * @param slot - script slot index of the variable to be retrieved
5810       * @param variable - name of the 'patch' variable in that script       * @param variable - name of the 'patch' variable in that script
5811       */       */
5812      String Instrument::GetScriptPatchVariable(int slot, String variable) {      String Instrument::GetScriptPatchVariable(size_t slot, String variable) {
5813          std::map<String,String> vars = GetScriptPatchVariables(slot);          std::map<String,String> vars = GetScriptPatchVariables(slot);
5814          return (vars.count(variable)) ? vars.find(variable)->second : "";          return (vars.count(variable)) ? vars.find(variable)->second : "";
5815      }      }
# Line 5835  namespace { Line 5836  namespace {
5836       * @throws gig::Exception if given script @p slot index is invalid or given       * @throws gig::Exception if given script @p slot index is invalid or given
5837       *         @p variable name is empty       *         @p variable name is empty
5838       */       */
5839      void Instrument::SetScriptPatchVariable(int slot, String variable, String value) {      void Instrument::SetScriptPatchVariable(size_t slot, String variable, String value) {
5840          if (variable.empty())          if (variable.empty())
5841              throw Exception("Variable name must not be empty");              throw Exception("Variable name must not be empty");
5842          Script* script = GetScriptOfSlot(slot);          Script* script = GetScriptOfSlot(slot);
# Line 5876  namespace { Line 5877  namespace {
5877       * @param slot - script slot index of the variable to be unset       * @param slot - script slot index of the variable to be unset
5878       * @param variable - name of the 'patch' variable in that script       * @param variable - name of the 'patch' variable in that script
5879       */       */
5880      void Instrument::UnsetScriptPatchVariable(int slot, String variable) {      void Instrument::UnsetScriptPatchVariable(ssize_t slot, String variable) {
5881          Script* script = GetScriptOfSlot(slot);          Script* script = GetScriptOfSlot(slot);
5882    
5883          // option 1: unset a particular variable of one particular script slot          // option 1: unset a particular variable of one particular script slot
# Line 6388  namespace { Line 6389  namespace {
6389         wave->AddSubChunk(CHUNK_ID_FMT, 16);         wave->AddSubChunk(CHUNK_ID_FMT, 16);
6390         wave->AddSubList(LIST_TYPE_INFO);         wave->AddSubList(LIST_TYPE_INFO);
6391    
6392           const size_t idxIt = SamplesIterator - pSamples->begin();
6393         pSamples->push_back(pSample);         pSamples->push_back(pSample);
6394           SamplesIterator = pSamples->begin() + std::min(idxIt, pSamples->size()); // avoid iterator invalidation
6395         return pSample;         return pSample;
6396      }      }
6397    
# Line 6405  namespace { Line 6408  namespace {
6408          if (!pSamples || !pSamples->size()) throw gig::Exception("Could not delete sample as there are no samples");          if (!pSamples || !pSamples->size()) throw gig::Exception("Could not delete sample as there are no samples");
6409          SampleList::iterator iter = find(pSamples->begin(), pSamples->end(), (DLS::Sample*) pSample);          SampleList::iterator iter = find(pSamples->begin(), pSamples->end(), (DLS::Sample*) pSample);
6410          if (iter == pSamples->end()) throw gig::Exception("Could not delete sample, could not find given sample");          if (iter == pSamples->end()) throw gig::Exception("Could not delete sample, could not find given sample");
6411          if (SamplesIterator != pSamples->end() && *SamplesIterator == pSample) ++SamplesIterator; // avoid iterator invalidation          const size_t idxIt = SamplesIterator - pSamples->begin();
6412          pSamples->erase(iter);          pSamples->erase(iter);
6413            SamplesIterator = pSamples->begin() + std::min(idxIt, pSamples->size()); // avoid iterator invalidation
6414          pSample->DeleteChunks();          pSample->DeleteChunks();
6415          delete pSample;          delete pSample;
6416    
# Line 6513  namespace { Line 6517  namespace {
6517              ExtensionFiles.push_back(pExtFile);              ExtensionFiles.push_back(pExtFile);
6518          }          }
6519    
6520          // load samples from extension files (if required)          // load all samples (both from this/main .gig file as well as from
6521            // extension files if required)
6522          for (int i = 0; i < poolFiles.size(); i++) {          for (int i = 0; i < poolFiles.size(); i++) {
6523              RIFF::File* file = poolFiles[i];              RIFF::File* file = poolFiles[i];
6524              RIFF::List* wvpl = file->GetSubList(LIST_TYPE_WVPL);              RIFF::List* wvpl = file->GetSubList(LIST_TYPE_WVPL);
6525              if (wvpl) {              if (wvpl) {
6526                  file_offset_t wvplFileOffset = wvpl->GetFilePos() -                  file_offset_t wvplFileOffset = wvpl->GetFilePos() -
6527                                                 wvpl->GetPos(); // should be zero, but just to be sure                                                 wvpl->GetPos(); // should be zero, but just to be sure
6528                  size_t i = 0;                  size_t iWaveCk = 0;
6529                  for (RIFF::List* wave = wvpl->GetSubListAt(i); wave;                  for (RIFF::List* wave = wvpl->GetSubListAt(iWaveCk); wave;
6530                       wave = wvpl->GetSubListAt(++i))                       wave = wvpl->GetSubListAt(++iWaveCk))
6531                  {                  {
6532                      if (wave->GetListType() == LIST_TYPE_WAVE) {                      if (wave->GetListType() == LIST_TYPE_WAVE) {
6533                          // notify current progress                          // notify current progress

Legend:
Removed from v.3958  
changed lines
  Added in v.3975

  ViewVC Help
Powered by ViewVC