/[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 3487 by schoenebeck, Fri Feb 22 12:12:50 2019 UTC revision 3488 by schoenebeck, Thu Feb 28 17:49:07 2019 UTC
# Line 4789  namespace { Line 4789  namespace {
4789                  RIFF::List* rgn = lrgn->GetFirstSubList();                  RIFF::List* rgn = lrgn->GetFirstSubList();
4790                  while (rgn) {                  while (rgn) {
4791                      if (rgn->GetListType() == LIST_TYPE_RGN) {                      if (rgn->GetListType() == LIST_TYPE_RGN) {
4792                          __notify_progress(pProgress, (float) pRegions->size() / (float) Regions);                          if (pProgress)
4793                                __notify_progress(pProgress, (float) pRegions->size() / (float) Regions);
4794                          pRegions->push_back(new Region(this, rgn));                          pRegions->push_back(new Region(this, rgn));
4795                      }                      }
4796                      rgn = lrgn->GetNextSubList();                      rgn = lrgn->GetNextSubList();
# Line 4823  namespace { Line 4824  namespace {
4824              }              }
4825          }          }
4826    
4827          __notify_progress(pProgress, 1.0f); // notify done          if (pProgress)
4828                __notify_progress(pProgress, 1.0f); // notify done
4829      }      }
4830    
4831      void Instrument::UpdateRegionKeyTable() {      void Instrument::UpdateRegionKeyTable() {
# Line 5841  namespace { Line 5843  namespace {
5843                  while (wave) {                  while (wave) {
5844                      if (wave->GetListType() == LIST_TYPE_WAVE) {                      if (wave->GetListType() == LIST_TYPE_WAVE) {
5845                          // notify current progress                          // notify current progress
5846                          const float subprogress = (float) iSampleIndex / (float) iTotalSamples;                          if (pProgress) {
5847                          __notify_progress(pProgress, subprogress);                              const float subprogress = (float) iSampleIndex / (float) iTotalSamples;
5848                                __notify_progress(pProgress, subprogress);
5849                            }
5850    
5851                          file_offset_t waveFileOffset = wave->GetFilePos();                          file_offset_t waveFileOffset = wave->GetFilePos();
5852                          pSamples->push_back(new Sample(this, wave, waveFileOffset - wvplFileOffset, i, iSampleIndex));                          pSamples->push_back(new Sample(this, wave, waveFileOffset - wvplFileOffset, i, iSampleIndex));
# Line 5854  namespace { Line 5858  namespace {
5858              }              }
5859          }          }
5860    
5861          __notify_progress(pProgress, 1.0); // notify done          if (pProgress)
5862                __notify_progress(pProgress, 1.0); // notify done
5863      }      }
5864    
5865      Instrument* File::GetFirstInstrument() {      Instrument* File::GetFirstInstrument() {
# Line 5895  namespace { Line 5900  namespace {
5900          if (!pInstruments) {          if (!pInstruments) {
5901              // TODO: hack - we simply load ALL samples here, it would have been done in the Region constructor anyway (ATM)              // TODO: hack - we simply load ALL samples here, it would have been done in the Region constructor anyway (ATM)
5902    
5903              // sample loading subtask              if (pProgress) {
5904              progress_t subprogress;                  // sample loading subtask
5905              __divide_progress(pProgress, &subprogress, 3.0f, 0.0f); // randomly schedule 33% for this subtask                  progress_t subprogress;
5906              __notify_progress(&subprogress, 0.0f);                  __divide_progress(pProgress, &subprogress, 3.0f, 0.0f); // randomly schedule 33% for this subtask
5907              if (GetAutoLoad())                  __notify_progress(&subprogress, 0.0f);
5908                  GetFirstSample(&subprogress); // now force all samples to be loaded                  if (GetAutoLoad())
5909              __notify_progress(&subprogress, 1.0f);                      GetFirstSample(&subprogress); // now force all samples to be loaded
5910                    __notify_progress(&subprogress, 1.0f);
5911              // instrument loading subtask  
5912              if (pProgress && pProgress->callback) {                  // instrument loading subtask
5913                  subprogress.__range_min = subprogress.__range_max;                  if (pProgress->callback) {
5914                  subprogress.__range_max = pProgress->__range_max; // schedule remaining percentage for this subtask                      subprogress.__range_min = subprogress.__range_max;
5915                        subprogress.__range_max = pProgress->__range_max; // schedule remaining percentage for this subtask
5916                    }
5917                    __notify_progress(&subprogress, 0.0f);
5918                    LoadInstruments(&subprogress);
5919                    __notify_progress(&subprogress, 1.0f);
5920                } else {
5921                    // sample loading subtask
5922                    if (GetAutoLoad())
5923                        GetFirstSample(); // now force all samples to be loaded
5924    
5925                    // instrument loading subtask
5926                    LoadInstruments();
5927              }              }
             __notify_progress(&subprogress, 0.0f);  
             LoadInstruments(&subprogress);  
             __notify_progress(&subprogress, 1.0f);  
5928          }          }
5929          if (!pInstruments) return NULL;          if (!pInstruments) return NULL;
5930          InstrumentsIterator = pInstruments->begin();          InstrumentsIterator = pInstruments->begin();
# Line 6075  namespace { Line 6089  namespace {
6089              RIFF::List* lstInstr = lstInstruments->GetFirstSubList();              RIFF::List* lstInstr = lstInstruments->GetFirstSubList();
6090              while (lstInstr) {              while (lstInstr) {
6091                  if (lstInstr->GetListType() == LIST_TYPE_INS) {                  if (lstInstr->GetListType() == LIST_TYPE_INS) {
6092                      // notify current progress                      if (pProgress) {
6093                      const float localProgress = (float) iInstrumentIndex / (float) Instruments;                          // notify current progress
6094                      __notify_progress(pProgress, localProgress);                          const float localProgress = (float) iInstrumentIndex / (float) Instruments;
6095                            __notify_progress(pProgress, localProgress);
                     // divide local progress into subprogress for loading current Instrument  
                     progress_t subprogress;  
                     __divide_progress(pProgress, &subprogress, Instruments, iInstrumentIndex);  
6096    
6097                      pInstruments->push_back(new Instrument(this, lstInstr, &subprogress));                          // divide local progress into subprogress for loading current Instrument
6098                            progress_t subprogress;
6099                            __divide_progress(pProgress, &subprogress, Instruments, iInstrumentIndex);
6100    
6101                            pInstruments->push_back(new Instrument(this, lstInstr, &subprogress));
6102                        } else {
6103                            pInstruments->push_back(new Instrument(this, lstInstr));
6104                        }
6105    
6106                      iInstrumentIndex++;                      iInstrumentIndex++;
6107                  }                  }
6108                  lstInstr = lstInstruments->GetNextSubList();                  lstInstr = lstInstruments->GetNextSubList();
6109              }              }
6110              __notify_progress(pProgress, 1.0); // notify done              if (pProgress)
6111                    __notify_progress(pProgress, 1.0); // notify done
6112          }          }
6113      }      }
6114    

Legend:
Removed from v.3487  
changed lines
  Added in v.3488

  ViewVC Help
Powered by ViewVC