/[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 2989 by schoenebeck, Sat Sep 24 14:00:46 2016 UTC revision 3138 by schoenebeck, Wed May 3 14:41:58 2017 UTC
# Line 2  Line 2 
2   *                                                                         *   *                                                                         *
3   *   libgig - C++ cross-platform Gigasampler format file access library    *   *   libgig - C++ cross-platform Gigasampler format file access library    *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003-2016 by Christian Schoenebeck                      *   *   Copyright (C) 2003-2017 by Christian Schoenebeck                      *
6   *                              <cuse@users.sourceforge.net>               *   *                              <cuse@users.sourceforge.net>               *
7   *                                                                         *   *                                                                         *
8   *   This library is free software; you can redistribute it and/or modify  *   *   This library is free software; you can redistribute it and/or modify  *
# Line 55  Line 55 
55  #define GIG_EG_CTR_DECAY_INFLUENCE_ENCODE(x)    ((x & 0x03) << 3)  #define GIG_EG_CTR_DECAY_INFLUENCE_ENCODE(x)    ((x & 0x03) << 3)
56  #define GIG_EG_CTR_RELEASE_INFLUENCE_ENCODE(x)  ((x & 0x03) << 5)  #define GIG_EG_CTR_RELEASE_INFLUENCE_ENCODE(x)  ((x & 0x03) << 5)
57    
58    #define SRLZ(member) \
59        archive->serializeMember(*this, member, #member);
60    
61  namespace gig {  namespace gig {
62    
63  // *************** Internal functions for sample decompression ***************  // *************** Internal functions for sample decompression ***************
# Line 269  namespace { Line 272  namespace {
272       * steps.       * steps.
273       *       *
274       * Once the whole data was processed by __calculateCRC(), one should       * Once the whole data was processed by __calculateCRC(), one should
275       * call __encodeCRC() to get the final CRC result.       * call __finalizeCRC() to get the final CRC result.
276       *       *
277       * @param buf     - pointer to data the CRC shall be calculated of       * @param buf     - pointer to data the CRC shall be calculated of
278       * @param bufSize - size of the data to be processed       * @param bufSize - size of the data to be processed
279       * @param crc     - variable the CRC sum shall be stored to       * @param crc     - variable the CRC sum shall be stored to
280       */       */
281      static void __calculateCRC(unsigned char* buf, int bufSize, uint32_t& crc) {      static void __calculateCRC(unsigned char* buf, size_t bufSize, uint32_t& crc) {
282          for (int i = 0 ; i < bufSize ; i++) {          for (size_t i = 0 ; i < bufSize ; i++) {
283              crc = __CRCTable[(crc ^ buf[i]) & 0xff] ^ (crc >> 8);              crc = __CRCTable[(crc ^ buf[i]) & 0xff] ^ (crc >> 8);
284          }          }
285      }      }
# Line 286  namespace { Line 289  namespace {
289       *       *
290       * @param crc - variable previously passed to __calculateCRC()       * @param crc - variable previously passed to __calculateCRC()
291       */       */
292      inline static uint32_t __encodeCRC(const uint32_t& crc) {      inline static void __finalizeCRC(uint32_t& crc) {
293          return crc ^ 0xffffffff;          crc ^= 0xffffffff;
294      }      }
295    
296    
# Line 315  namespace { Line 318  namespace {
318    
319    
320    
321    // *************** leverage_ctrl_t ***************
322    // *
323    
324        void leverage_ctrl_t::serialize(Serialization::Archive* archive) {
325            SRLZ(type);
326            SRLZ(controller_number);
327        }
328    
329    
330    
331    // *************** crossfade_t ***************
332    // *
333    
334        void crossfade_t::serialize(Serialization::Archive* archive) {
335            SRLZ(in_start);
336            SRLZ(in_end);
337            SRLZ(out_start);
338            SRLZ(out_end);
339        }
340    
341    
342    
343  // *************** Sample ***************  // *************** Sample ***************
344  // *  // *
345    
# Line 1294  namespace { Line 1319  namespace {
1319          // if this is the last write, update the checksum chunk in the          // if this is the last write, update the checksum chunk in the
1320          // file          // file
1321          if (pCkData->GetPos() == pCkData->GetSize()) {          if (pCkData->GetPos() == pCkData->GetSize()) {
1322                __finalizeCRC(crc);
1323              File* pFile = static_cast<File*>(GetParent());              File* pFile = static_cast<File*>(GetParent());
1324              pFile->SetSampleChecksum(this, __encodeCRC(crc));              pFile->SetSampleChecksum(this, crc);
1325          }          }
1326          return res;          return res;
1327      }      }
# Line 1396  namespace { Line 1422  namespace {
1422       * @see GetWaveDataCRC32Checksum()       * @see GetWaveDataCRC32Checksum()
1423       */       */
1424      bool Sample::VerifyWaveData(uint32_t* pActually) {      bool Sample::VerifyWaveData(uint32_t* pActually) {
1425          File* pFile = static_cast<File*>(GetParent());          //File* pFile = static_cast<File*>(GetParent());
1426          uint32_t crc = CalculateWaveDataChecksum();          uint32_t crc = CalculateWaveDataChecksum();
1427          if (pActually) *pActually = crc;          if (pActually) *pActually = crc;
1428          return crc == this->crc;          return crc == this->crc;
# Line 1416  namespace { Line 1442  namespace {
1442              if (nRead <= 0) break;              if (nRead <= 0) break;
1443              __calculateCRC(&buffer[0], nRead * FrameSize, crc);              __calculateCRC(&buffer[0], nRead * FrameSize, crc);
1444          }          }
1445          __encodeCRC(crc);          __finalizeCRC(crc);
1446          return crc;          return crc;
1447      }      }
1448    
# Line 1630  namespace { Line 1656  namespace {
1656              EG2Attack                       = 0.0;              EG2Attack                       = 0.0;
1657              EG2Decay1                       = 0.005;              EG2Decay1                       = 0.005;
1658              EG2Sustain                      = 1000;              EG2Sustain                      = 1000;
1659              EG2Release                      = 0.3;              EG2Release                      = 60;
1660              LFO2ControlDepth                = 0;              LFO2ControlDepth                = 0;
1661              LFO2Frequency                   = 1.0;              LFO2Frequency                   = 1.0;
1662              LFO2InternalDepth               = 0;              LFO2InternalDepth               = 0;
# Line 1789  namespace { Line 1815  namespace {
1815          }          }
1816      }      }
1817    
1818        void DimensionRegion::serialize(Serialization::Archive* archive) {
1819            SRLZ(VelocityUpperLimit);
1820            SRLZ(EG1PreAttack);
1821            SRLZ(EG1Attack);
1822            SRLZ(EG1Decay1);
1823            SRLZ(EG1Decay2);
1824            SRLZ(EG1InfiniteSustain);
1825            SRLZ(EG1Sustain);
1826            SRLZ(EG1Release);
1827            SRLZ(EG1Hold);
1828            SRLZ(EG1Controller);
1829            SRLZ(EG1ControllerInvert);
1830            SRLZ(EG1ControllerAttackInfluence);
1831            SRLZ(EG1ControllerDecayInfluence);
1832            SRLZ(EG1ControllerReleaseInfluence);
1833            SRLZ(LFO1Frequency);
1834            SRLZ(LFO1InternalDepth);
1835            SRLZ(LFO1ControlDepth);
1836            SRLZ(LFO1Controller);
1837            SRLZ(LFO1FlipPhase);
1838            SRLZ(LFO1Sync);
1839            SRLZ(EG2PreAttack);
1840            SRLZ(EG2Attack);
1841            SRLZ(EG2Decay1);
1842            SRLZ(EG2Decay2);
1843            SRLZ(EG2InfiniteSustain);
1844            SRLZ(EG2Sustain);
1845            SRLZ(EG2Release);
1846            SRLZ(EG2Controller);
1847            SRLZ(EG2ControllerInvert);
1848            SRLZ(EG2ControllerAttackInfluence);
1849            SRLZ(EG2ControllerDecayInfluence);
1850            SRLZ(EG2ControllerReleaseInfluence);
1851            SRLZ(LFO2Frequency);
1852            SRLZ(LFO2InternalDepth);
1853            SRLZ(LFO2ControlDepth);
1854            SRLZ(LFO2Controller);
1855            SRLZ(LFO2FlipPhase);
1856            SRLZ(LFO2Sync);
1857            SRLZ(EG3Attack);
1858            SRLZ(EG3Depth);
1859            SRLZ(LFO3Frequency);
1860            SRLZ(LFO3InternalDepth);
1861            SRLZ(LFO3ControlDepth);
1862            SRLZ(LFO3Controller);
1863            SRLZ(LFO3Sync);
1864            SRLZ(VCFEnabled);
1865            SRLZ(VCFType);
1866            SRLZ(VCFCutoffController);
1867            SRLZ(VCFCutoffControllerInvert);
1868            SRLZ(VCFCutoff);
1869            SRLZ(VCFVelocityCurve);
1870            SRLZ(VCFVelocityScale);
1871            SRLZ(VCFVelocityDynamicRange);
1872            SRLZ(VCFResonance);
1873            SRLZ(VCFResonanceDynamic);
1874            SRLZ(VCFResonanceController);
1875            SRLZ(VCFKeyboardTracking);
1876            SRLZ(VCFKeyboardTrackingBreakpoint);
1877            SRLZ(VelocityResponseCurve);
1878            SRLZ(VelocityResponseDepth);
1879            SRLZ(VelocityResponseCurveScaling);
1880            SRLZ(ReleaseVelocityResponseCurve);
1881            SRLZ(ReleaseVelocityResponseDepth);
1882            SRLZ(ReleaseTriggerDecay);
1883            SRLZ(Crossfade);
1884            SRLZ(PitchTrack);
1885            SRLZ(DimensionBypass);
1886            SRLZ(Pan);
1887            SRLZ(SelfMask);
1888            SRLZ(AttenuationController);
1889            SRLZ(InvertAttenuationController);
1890            SRLZ(AttenuationControllerThreshold);
1891            SRLZ(ChannelOffset);
1892            SRLZ(SustainDefeat);
1893            SRLZ(MSDecode);
1894            //SRLZ(SampleStartOffset);
1895            SRLZ(SampleAttenuation);
1896    
1897            // derived attributes from DLS::Sampler
1898            SRLZ(FineTune);
1899            SRLZ(Gain);
1900        }
1901    
1902      /**      /**
1903       * Updates the respective member variable and updates @c SampleAttenuation       * Updates the respective member variable and updates @c SampleAttenuation
1904       * which depends on this value.       * which depends on this value.
# Line 1829  namespace { Line 1939  namespace {
1939    
1940          // update '3ewa' chunk with DimensionRegion's current settings          // update '3ewa' chunk with DimensionRegion's current settings
1941    
1942          const uint32_t chunksize = _3ewa->GetNewSize();          const uint32_t chunksize = (uint32_t) _3ewa->GetNewSize();
1943          store32(&pData[0], chunksize); // unknown, always chunk size?          store32(&pData[0], chunksize); // unknown, always chunk size?
1944    
1945          const int32_t lfo3freq = (int32_t) GIG_EXP_ENCODE(LFO3Frequency);          const int32_t lfo3freq = (int32_t) GIG_EXP_ENCODE(LFO3Frequency);
# Line 3797  namespace { Line 3907  namespace {
3907      DimensionRegion* Region::GetDimensionRegionByValue(const uint DimValues[8]) {      DimensionRegion* Region::GetDimensionRegionByValue(const uint DimValues[8]) {
3908          uint8_t bits;          uint8_t bits;
3909          int veldim = -1;          int veldim = -1;
3910          int velbitpos;          int velbitpos = 0;
3911          int bitpos = 0;          int bitpos = 0;
3912          int dimregidx = 0;          int dimregidx = 0;
3913          for (uint i = 0; i < Dimensions; i++) {          for (uint i = 0; i < Dimensions; i++) {
# Line 3846  namespace { Line 3956  namespace {
3956      int Region::GetDimensionRegionIndexByValue(const uint DimValues[8]) {      int Region::GetDimensionRegionIndexByValue(const uint DimValues[8]) {
3957          uint8_t bits;          uint8_t bits;
3958          int veldim = -1;          int veldim = -1;
3959          int velbitpos;          int velbitpos = 0;
3960          int bitpos = 0;          int bitpos = 0;
3961          int dimregidx = 0;          int dimregidx = 0;
3962          for (uint i = 0; i < Dimensions; i++) {          for (uint i = 0; i < Dimensions; i++) {
# Line 4195  namespace { Line 4305  namespace {
4305              // to handle potential future extensions of the header              // to handle potential future extensions of the header
4306              ckScri->SetPos(sizeof(int32_t) + headerSize);              ckScri->SetPos(sizeof(int32_t) + headerSize);
4307              // read actual script data              // read actual script data
4308              uint32_t scriptSize = ckScri->GetSize() - ckScri->GetPos();              uint32_t scriptSize = uint32_t(ckScri->GetSize() - ckScri->GetPos());
4309              data.resize(scriptSize);              data.resize(scriptSize);
4310              for (int i = 0; i < scriptSize; ++i)              for (int i = 0; i < scriptSize; ++i)
4311                  data[i] = ckScri->ReadUint8();                  data[i] = ckScri->ReadUint8();
# Line 4246  namespace { Line 4356  namespace {
4356          // recalculate CRC32 check sum          // recalculate CRC32 check sum
4357          __resetCRC(crc);          __resetCRC(crc);
4358          __calculateCRC(&data[0], data.size(), crc);          __calculateCRC(&data[0], data.size(), crc);
4359          __encodeCRC(crc);          __finalizeCRC(crc);
4360          // make sure chunk exists and has the required size          // make sure chunk exists and has the required size
4361          const int chunkSize = 7*sizeof(int32_t) + Name.size() + data.size();          const file_offset_t chunkSize = (file_offset_t) 7*sizeof(int32_t) + Name.size() + data.size();
4362          if (!pChunk) pChunk = pGroup->pList->AddSubChunk(CHUNK_ID_SCRI, chunkSize);          if (!pChunk) pChunk = pGroup->pList->AddSubChunk(CHUNK_ID_SCRI, chunkSize);
4363          else pChunk->Resize(chunkSize);          else pChunk->Resize(chunkSize);
4364          // fill the chunk data to be written to disk          // fill the chunk data to be written to disk
4365          uint8_t* pData = (uint8_t*) pChunk->LoadChunkData();          uint8_t* pData = (uint8_t*) pChunk->LoadChunkData();
4366          int pos = 0;          int pos = 0;
4367          store32(&pData[pos], 6*sizeof(int32_t) + Name.size()); // total header size          store32(&pData[pos], uint32_t(6*sizeof(int32_t) + Name.size())); // total header size
4368          pos += sizeof(int32_t);          pos += sizeof(int32_t);
4369          store32(&pData[pos], Compression);          store32(&pData[pos], Compression);
4370          pos += sizeof(int32_t);          pos += sizeof(int32_t);
# Line 4266  namespace { Line 4376  namespace {
4376          pos += sizeof(int32_t);          pos += sizeof(int32_t);
4377          store32(&pData[pos], crc);          store32(&pData[pos], crc);
4378          pos += sizeof(int32_t);          pos += sizeof(int32_t);
4379          store32(&pData[pos], Name.size());          store32(&pData[pos], (uint32_t) Name.size());
4380          pos += sizeof(int32_t);          pos += sizeof(int32_t);
4381          for (int i = 0; i < Name.size(); ++i, ++pos)          for (int i = 0; i < Name.size(); ++i, ++pos)
4382              pData[pos] = Name[i];              pData[pos] = Name[i];
# Line 4297  namespace { Line 4407  namespace {
4407          return pGroup;          return pGroup;
4408      }      }
4409    
4410        /**
4411         * Make a (semi) deep copy of the Script object given by @a orig
4412         * and assign it to this object. Note: the ScriptGroup this Script
4413         * object belongs to remains untouched by this call.
4414         *
4415         * @param orig - original Script object to be copied from
4416         */
4417        void Script::CopyAssign(const Script* orig) {
4418            Name        = orig->Name;
4419            Compression = orig->Compression;
4420            Encoding    = orig->Encoding;
4421            Language    = orig->Language;
4422            Bypass      = orig->Bypass;
4423            data        = orig->data;
4424        }
4425    
4426      void Script::RemoveAllScriptReferences() {      void Script::RemoveAllScriptReferences() {
4427          File* pFile = pGroup->pFile;          File* pFile = pGroup->pFile;
4428          for (int i = 0; pFile->GetInstrument(i); ++i) {          for (int i = 0; pFile->GetInstrument(i); ++i) {
# Line 4443  namespace { Line 4569  namespace {
4569          EffectSend = 0;          EffectSend = 0;
4570          Attenuation = 0;          Attenuation = 0;
4571          FineTune = 0;          FineTune = 0;
4572          PitchbendRange = 0;          PitchbendRange = 2;
4573          PianoReleaseMode = false;          PianoReleaseMode = false;
4574          DimensionKeyRange.low = 0;          DimensionKeyRange.low = 0;
4575          DimensionKeyRange.high = 0;          DimensionKeyRange.high = 0;
# Line 4618  namespace { Line 4744  namespace {
4744    
4745             RIFF::List* lst3LS = pCkInstrument->GetSubList(LIST_TYPE_3LS);             RIFF::List* lst3LS = pCkInstrument->GetSubList(LIST_TYPE_3LS);
4746             if (!lst3LS) lst3LS = pCkInstrument->AddSubList(LIST_TYPE_3LS);             if (!lst3LS) lst3LS = pCkInstrument->AddSubList(LIST_TYPE_3LS);
4747             const int slotCount = pScriptRefs->size();             const int slotCount = (int) pScriptRefs->size();
4748             const int headerSize = 3 * sizeof(uint32_t);             const int headerSize = 3 * sizeof(uint32_t);
4749             const int slotSize  = 2 * sizeof(uint32_t);             const int slotSize  = 2 * sizeof(uint32_t);
4750             const int totalChunkSize = headerSize + slotCount * slotSize;             const int totalChunkSize = headerSize + slotCount * slotSize;
# Line 4654  namespace { Line 4780  namespace {
4780         if (pScriptRefs && pScriptRefs->size() > 0) {         if (pScriptRefs && pScriptRefs->size() > 0) {
4781             RIFF::List* lst3LS = pCkInstrument->GetSubList(LIST_TYPE_3LS);             RIFF::List* lst3LS = pCkInstrument->GetSubList(LIST_TYPE_3LS);
4782             RIFF::Chunk* ckSCSL = lst3LS->GetSubChunk(CHUNK_ID_SCSL);             RIFF::Chunk* ckSCSL = lst3LS->GetSubChunk(CHUNK_ID_SCSL);
4783             const int slotCount = pScriptRefs->size();             const int slotCount = (int) pScriptRefs->size();
4784             const int headerSize = 3 * sizeof(uint32_t);             const int headerSize = 3 * sizeof(uint32_t);
4785             ckSCSL->SetPos(headerSize);             ckSCSL->SetPos(headerSize);
4786             for (int i = 0; i < slotCount; ++i) {             for (int i = 0; i < slotCount; ++i) {
4787                 uint32_t fileOffset =                 uint32_t fileOffset = uint32_t(
4788                      (*pScriptRefs)[i].script->pChunk->GetFilePos() -                      (*pScriptRefs)[i].script->pChunk->GetFilePos() -
4789                      (*pScriptRefs)[i].script->pChunk->GetPos() -                      (*pScriptRefs)[i].script->pChunk->GetPos() -
4790                      CHUNK_HEADER_SIZE(ckSCSL->GetFile()->GetFileOffsetSize());                      CHUNK_HEADER_SIZE(ckSCSL->GetFile()->GetFileOffsetSize())
4791                   );
4792                 ckSCSL->WriteUint32(&fileOffset);                 ckSCSL->WriteUint32(&fileOffset);
4793                 // jump over flags entry (containing the bypass flag)                 // jump over flags entry (containing the bypass flag)
4794                 ckSCSL->SetPos(sizeof(uint32_t), RIFF::stream_curpos);                 ckSCSL->SetPos(sizeof(uint32_t), RIFF::stream_curpos);
# Line 4721  namespace { Line 4848  namespace {
4848          RIFF::List* rgn = lrgn->AddSubList(LIST_TYPE_RGN);          RIFF::List* rgn = lrgn->AddSubList(LIST_TYPE_RGN);
4849          Region* pNewRegion = new Region(this, rgn);          Region* pNewRegion = new Region(this, rgn);
4850          pRegions->push_back(pNewRegion);          pRegions->push_back(pNewRegion);
4851          Regions = pRegions->size();          Regions = (uint32_t) pRegions->size();
4852          // update Region key table for fast lookup          // update Region key table for fast lookup
4853          UpdateRegionKeyTable();          UpdateRegionKeyTable();
4854          // done          // done
# Line 4867  namespace { Line 4994  namespace {
4994                  for (uint s = 0; group->GetScript(s); ++s) {                  for (uint s = 0; group->GetScript(s); ++s) {
4995                      Script* script = group->GetScript(s);                      Script* script = group->GetScript(s);
4996                      if (script->pChunk) {                      if (script->pChunk) {
4997                          uint32_t offset = script->pChunk->GetFilePos() -                          uint32_t offset = uint32_t(
4998                                            script->pChunk->GetPos() -                              script->pChunk->GetFilePos() -
4999                                            CHUNK_HEADER_SIZE(script->pChunk->GetFile()->GetFileOffsetSize());                              script->pChunk->GetPos() -
5000                                CHUNK_HEADER_SIZE(script->pChunk->GetFile()->GetFileOffsetSize())
5001                            );
5002                          if (offset == soughtOffset)                          if (offset == soughtOffset)
5003                          {                          {
5004                              _ScriptPooolRef ref;                              _ScriptPooolRef ref;
# Line 4994  namespace { Line 5123  namespace {
5123       */       */
5124      void Instrument::RemoveScript(Script* pScript) {      void Instrument::RemoveScript(Script* pScript) {
5125          LoadScripts();          LoadScripts();
5126          for (int i = pScriptRefs->size() - 1; i >= 0; --i) {          for (ssize_t i = pScriptRefs->size() - 1; i >= 0; --i) {
5127              if ((*pScriptRefs)[i].script == pScript) {              if ((*pScriptRefs)[i].script == pScript) {
5128                  pScriptRefs->erase( pScriptRefs->begin() + i );                  pScriptRefs->erase( pScriptRefs->begin() + i );
5129              }              }
# Line 5016  namespace { Line 5145  namespace {
5145       * gigedit.       * gigedit.
5146       */       */
5147      uint Instrument::ScriptSlotCount() const {      uint Instrument::ScriptSlotCount() const {
5148          return pScriptRefs ? pScriptRefs->size() : scriptPoolFileOffsets.size();          return uint(pScriptRefs ? pScriptRefs->size() : scriptPoolFileOffsets.size());
5149      }      }
5150    
5151      /** @brief Whether script execution shall be skipped.      /** @brief Whether script execution shall be skipped.
# Line 5440  namespace { Line 5569  namespace {
5569              }              }
5570          }          }
5571          String name(pRIFF->GetFileName());          String name(pRIFF->GetFileName());
5572          int nameLen = name.length();          int nameLen = (int) name.length();
5573          char suffix[6];          char suffix[6];
5574          if (nameLen > 4 && name.substr(nameLen - 4) == ".gig") nameLen -= 4;          if (nameLen > 4 && name.substr(nameLen - 4) == ".gig") nameLen -= 4;
5575    
# Line 5609  namespace { Line 5738  namespace {
5738              mGroups[pFile->GetSample(i)->GetGroup()]->AddSample(s);              mGroups[pFile->GetSample(i)->GetGroup()]->AddSample(s);
5739              mSamples[pFile->GetSample(i)] = s;              mSamples[pFile->GetSample(i)] = s;
5740          }          }
5741            
5742            // clone script groups and their scripts
5743            for (int iGroup = 0; pFile->GetScriptGroup(iGroup); ++iGroup) {
5744                ScriptGroup* sg = pFile->GetScriptGroup(iGroup);
5745                ScriptGroup* dg = AddScriptGroup();
5746                dg->Name = "COPY" + ToString(iCallCount) + "_" + sg->Name;
5747                for (int iScript = 0; sg->GetScript(iScript); ++iScript) {
5748                    Script* ss = sg->GetScript(iScript);
5749                    Script* ds = dg->AddScript();
5750                    ds->CopyAssign(ss);
5751                }
5752            }
5753    
5754          //BUG: For some reason this method only works with this additional          //BUG: For some reason this method only works with this additional
5755          //     Save() call in between here.          //     Save() call in between here.
5756          //          //
# Line 5756  namespace { Line 5897  namespace {
5897          if (!pSamples) GetFirstSample(); // make sure sample chunks were scanned          if (!pSamples) GetFirstSample(); // make sure sample chunks were scanned
5898          if (_3crc->GetNewSize() != pSamples->size() * 8) return false;          if (_3crc->GetNewSize() != pSamples->size() * 8) return false;
5899    
5900          const int n = _3crc->GetNewSize() / 8;          const file_offset_t n = _3crc->GetNewSize() / 8;
5901    
5902          uint32_t* pData = (uint32_t*) _3crc->LoadChunkData();          uint32_t* pData = (uint32_t*) _3crc->LoadChunkData();
5903          if (!pData) return false;          if (!pData) return false;
5904    
5905          for (int i = 0; i < n; ++i) {          for (file_offset_t i = 0; i < n; ++i) {
5906              uint32_t one = pData[i*2];              uint32_t one = pData[i*2];
5907              if (one != 1) return false;              if (one != 1) return false;
5908          }          }
# Line 6153  namespace { Line 6294  namespace {
6294          // Note that there are several fields with unknown use. These          // Note that there are several fields with unknown use. These
6295          // are set to zero.          // are set to zero.
6296    
6297          int sublen = pSamples->size() / 8 + 49;          int sublen = int(pSamples->size() / 8 + 49);
6298          int einfSize = (Instruments + 1) * sublen;          int einfSize = (Instruments + 1) * sublen;
6299    
6300          RIFF::Chunk* einf = pRIFF->GetSubChunk(CHUNK_ID_EINF);          RIFF::Chunk* einf = pRIFF->GetSubChunk(CHUNK_ID_EINF);
# Line 6226  namespace { Line 6367  namespace {
6367                  store32(&pData[(instrumentIdx + 1) * sublen + 24], nbloops);                  store32(&pData[(instrumentIdx + 1) * sublen + 24], nbloops);
6368                  // next 8 bytes unknown                  // next 8 bytes unknown
6369                  store32(&pData[(instrumentIdx + 1) * sublen + 36], instrumentIdx);                  store32(&pData[(instrumentIdx + 1) * sublen + 36], instrumentIdx);
6370                  store32(&pData[(instrumentIdx + 1) * sublen + 40], pSamples->size());                  store32(&pData[(instrumentIdx + 1) * sublen + 40], (uint32_t) pSamples->size());
6371                  // next 4 bytes unknown                  // next 4 bytes unknown
6372    
6373                  totnbregions += instrument->Regions;                  totnbregions += instrument->Regions;
# Line 6244  namespace { Line 6385  namespace {
6385              store32(&pData[24], totnbloops);              store32(&pData[24], totnbloops);
6386              // next 8 bytes unknown              // next 8 bytes unknown
6387              // next 4 bytes unknown, not always 0              // next 4 bytes unknown, not always 0
6388              store32(&pData[40], pSamples->size());              store32(&pData[40], (uint32_t) pSamples->size());
6389              // next 4 bytes unknown              // next 4 bytes unknown
6390          }          }
6391    

Legend:
Removed from v.2989  
changed lines
  Added in v.3138

  ViewVC Help
Powered by ViewVC