/[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 3140 by schoenebeck, Wed May 3 16:19:53 2017 UTC revision 3442 by schoenebeck, Sat Dec 22 18:59:29 2018 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-2017 by Christian Schoenebeck                      *   *   Copyright (C) 2003-2018 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 341  namespace { Line 341  namespace {
341    
342    
343    
344    // *************** eg_opt_t ***************
345    // *
346    
347        eg_opt_t::eg_opt_t() {
348            AttackCancel     = true;
349            AttackHoldCancel = true;
350            Decay1Cancel     = true;
351            Decay2Cancel     = true;
352            ReleaseCancel    = true;
353        }
354    
355        void eg_opt_t::serialize(Serialization::Archive* archive) {
356            SRLZ(AttackCancel);
357            SRLZ(AttackHoldCancel);
358            SRLZ(Decay1Cancel);
359            SRLZ(Decay2Cancel);
360            SRLZ(ReleaseCancel);
361        }
362    
363    
364    
365  // *************** Sample ***************  // *************** Sample ***************
366  // *  // *
367    
# Line 447  namespace { Line 468  namespace {
468          TruncatedBits     = 0;          TruncatedBits     = 0;
469          if (Compressed) {          if (Compressed) {
470              uint32_t version = ewav->ReadInt32();              uint32_t version = ewav->ReadInt32();
471              if (version == 3 && BitDepth == 24) {              if (version > 2 && BitDepth == 24) {
472                  Dithered = ewav->ReadInt32();                  Dithered = ewav->ReadInt32();
473                  ewav->SetPos(Channels == 2 ? 84 : 64);                  ewav->SetPos(Channels == 2 ? 84 : 64);
474                  TruncatedBits = ewav->ReadInt32();                  TruncatedBits = ewav->ReadInt32();
# Line 1711  namespace { Line 1732  namespace {
1732              VCFType                         = vcf_type_lowpass;              VCFType                         = vcf_type_lowpass;
1733              memset(DimensionUpperLimits, 127, 8);              memset(DimensionUpperLimits, 127, 8);
1734          }          }
1735            // chunk for own format extensions, these will *NOT* work with Gigasampler/GigaStudio !
1736            RIFF::Chunk* lsde = _3ewl->GetSubChunk(CHUNK_ID_LSDE);
1737            if (lsde) { // format extension for EG behavior options
1738                eg_opt_t* pEGOpts[2] = { &EG1Options, &EG2Options };
1739                for (int i = 0; i < 2; ++i) { // NOTE: we reserved a 3rd byte for a potential future EG3 option
1740                    unsigned char byte = lsde->ReadUint8();
1741                    pEGOpts[i]->AttackCancel     = byte & 1;
1742                    pEGOpts[i]->AttackHoldCancel = byte & (1 << 1);
1743                    pEGOpts[i]->Decay1Cancel     = byte & (1 << 2);
1744                    pEGOpts[i]->Decay2Cancel     = byte & (1 << 3);
1745                    pEGOpts[i]->ReleaseCancel    = byte & (1 << 4);
1746                }
1747            }
1748            // format extension for sustain pedal up effect on release trigger samples
1749            if (lsde && lsde->GetSize() > 3) { // NOTE: we reserved the 3rd byte for a potential future EG3 option
1750                lsde->SetPos(3);
1751                SustainReleaseTrigger = static_cast<sust_rel_trg_t>(lsde->ReadUint8());
1752            } else SustainReleaseTrigger = sust_rel_trg_none;
1753    
1754          pVelocityAttenuationTable = GetVelocityTable(VelocityResponseCurve,          pVelocityAttenuationTable = GetVelocityTable(VelocityResponseCurve,
1755                                                       VelocityResponseDepth,                                                       VelocityResponseDepth,
# Line 1817  namespace { Line 1856  namespace {
1856      }      }
1857    
1858      void DimensionRegion::serialize(Serialization::Archive* archive) {      void DimensionRegion::serialize(Serialization::Archive* archive) {
1859            // in case this class will become backward incompatible one day,
1860            // then set a version and minimum version for this class like:
1861            //archive->setVersion(*this, 2);
1862            //archive->setMinVersion(*this, 1);
1863    
1864          SRLZ(VelocityUpperLimit);          SRLZ(VelocityUpperLimit);
1865          SRLZ(EG1PreAttack);          SRLZ(EG1PreAttack);
1866          SRLZ(EG1Attack);          SRLZ(EG1Attack);
# Line 1894  namespace { Line 1938  namespace {
1938          SRLZ(MSDecode);          SRLZ(MSDecode);
1939          //SRLZ(SampleStartOffset);          //SRLZ(SampleStartOffset);
1940          SRLZ(SampleAttenuation);          SRLZ(SampleAttenuation);
1941            SRLZ(EG1Options);
1942            SRLZ(EG2Options);
1943            SRLZ(SustainReleaseTrigger);
1944    
1945          // derived attributes from DLS::Sampler          // derived attributes from DLS::Sampler
1946          SRLZ(FineTune);          SRLZ(FineTune);
# Line 1933  namespace { Line 1980  namespace {
1980          RIFF::Chunk* _3ewa = pParentList->GetSubChunk(CHUNK_ID_3EWA);          RIFF::Chunk* _3ewa = pParentList->GetSubChunk(CHUNK_ID_3EWA);
1981          if (!_3ewa) {          if (!_3ewa) {
1982              File* pFile = (File*) GetParent()->GetParent()->GetParent();              File* pFile = (File*) GetParent()->GetParent()->GetParent();
1983              bool version3 = pFile->pVersion && pFile->pVersion->major == 3;              bool versiongt2 = pFile->pVersion && pFile->pVersion->major > 2;
1984              _3ewa = pParentList->AddSubChunk(CHUNK_ID_3EWA, version3 ? 148 : 140);              _3ewa = pParentList->AddSubChunk(CHUNK_ID_3EWA, versiongt2 ? 148 : 140);
1985          }          }
1986          pData = (uint8_t*) _3ewa->LoadChunkData();          pData = (uint8_t*) _3ewa->LoadChunkData();
1987    
# Line 2200  namespace { Line 2247  namespace {
2247          if (chunksize >= 148) {          if (chunksize >= 148) {
2248              memcpy(&pData[140], DimensionUpperLimits, 8);              memcpy(&pData[140], DimensionUpperLimits, 8);
2249          }          }
2250    
2251            // chunk for own format extensions, these will *NOT* work with
2252            // Gigasampler/GigaStudio !
2253            RIFF::Chunk* lsde = pParentList->GetSubChunk(CHUNK_ID_LSDE);
2254            const int lsdeSize = 4; // NOTE: we reserved the 3rd byte for a potential future EG3 option
2255            if (!lsde) {
2256                // only add this "LSDE" chunk if either EG options or sustain
2257                // release trigger option deviate from their default behaviour
2258                eg_opt_t defaultOpt;
2259                if (memcmp(&EG1Options, &defaultOpt, sizeof(eg_opt_t)) ||
2260                    memcmp(&EG2Options, &defaultOpt, sizeof(eg_opt_t)) ||
2261                    SustainReleaseTrigger)
2262                {
2263                    lsde = pParentList->AddSubChunk(CHUNK_ID_LSDE, lsdeSize);
2264                    // move LSDE chunk to the end of parent list
2265                    pParentList->MoveSubChunk(lsde, (RIFF::Chunk*)NULL);
2266                }
2267            }
2268            if (lsde) {
2269                if (lsde->GetNewSize() < lsdeSize)
2270                    lsde->Resize(lsdeSize);
2271                // format extension for EG behavior options
2272                unsigned char* pData = (unsigned char*) lsde->LoadChunkData();
2273                eg_opt_t* pEGOpts[2] = { &EG1Options, &EG2Options };
2274                for (int i = 0; i < 2; ++i) { // NOTE: we reserved the 3rd byte for a potential future EG3 option
2275                    pData[i] =
2276                        (pEGOpts[i]->AttackCancel     ? 1 : 0) |
2277                        (pEGOpts[i]->AttackHoldCancel ? (1<<1) : 0) |
2278                        (pEGOpts[i]->Decay1Cancel     ? (1<<2) : 0) |
2279                        (pEGOpts[i]->Decay2Cancel     ? (1<<3) : 0) |
2280                        (pEGOpts[i]->ReleaseCancel    ? (1<<4) : 0);
2281                }
2282                // format extension for effect of sustain pedal up event on release trigger samples
2283                pData[3] = static_cast<uint8_t>(SustainReleaseTrigger);
2284            }
2285      }      }
2286    
2287      double* DimensionRegion::GetReleaseVelocityTable(curve_type_t releaseVelocityResponseCurve, uint8_t releaseVelocityResponseDepth) {      double* DimensionRegion::GetReleaseVelocityTable(curve_type_t releaseVelocityResponseCurve, uint8_t releaseVelocityResponseDepth) {
# Line 2239  namespace { Line 2321  namespace {
2321      // get the corresponding velocity table from the table map or create & calculate that table if it doesn't exist yet      // get the corresponding velocity table from the table map or create & calculate that table if it doesn't exist yet
2322      double* DimensionRegion::GetVelocityTable(curve_type_t curveType, uint8_t depth, uint8_t scaling)      double* DimensionRegion::GetVelocityTable(curve_type_t curveType, uint8_t depth, uint8_t scaling)
2323      {      {
2324            // sanity check input parameters
2325            // (fallback to some default parameters on ill input)
2326            switch (curveType) {
2327                case curve_type_nonlinear:
2328                case curve_type_linear:
2329                    if (depth > 4) {
2330                        printf("Warning: Invalid depth (0x%x) for velocity curve type (0x%x).\n", depth, curveType);
2331                        depth   = 0;
2332                        scaling = 0;
2333                    }
2334                    break;
2335                case curve_type_special:
2336                    if (depth > 5) {
2337                        printf("Warning: Invalid depth (0x%x) for velocity curve type 'special'.\n", depth);
2338                        depth   = 0;
2339                        scaling = 0;
2340                    }
2341                    break;
2342                case curve_type_unknown:
2343                default:
2344                    printf("Warning: Unknown velocity curve type (0x%x).\n", curveType);
2345                    curveType = curve_type_linear;
2346                    depth     = 0;
2347                    scaling   = 0;
2348                    break;
2349            }
2350    
2351          double* table;          double* table;
2352          uint32_t tableKey = (curveType<<16) | (depth<<8) | scaling;          uint32_t tableKey = (curveType<<16) | (depth<<8) | scaling;
2353          if (pVelocityTables->count(tableKey)) { // if key exists          if (pVelocityTables->count(tableKey)) { // if key exists
# Line 2614  namespace { Line 2723  namespace {
2723    
2724              // unknown controller type              // unknown controller type
2725              default:              default:
2726                  throw gig::Exception("Unknown leverage controller type.");                  decodedcontroller.type = leverage_ctrl_t::type_none;
2727                    decodedcontroller.controller_number = 0;
2728                    printf("Warning: Unknown leverage controller type (0x%x).\n", EncodedController);
2729                    break;
2730          }          }
2731          return decodedcontroller;          return decodedcontroller;
2732      }      }
# Line 3108  namespace { Line 3220  namespace {
3220          }          }
3221          Layers = 1;          Layers = 1;
3222          File* file = (File*) GetParent()->GetParent();          File* file = (File*) GetParent()->GetParent();
3223          int dimensionBits = (file->pVersion && file->pVersion->major == 3) ? 8 : 5;          int dimensionBits = (file->pVersion && file->pVersion->major > 2) ? 8 : 5;
3224    
3225          // Actual Loading          // Actual Loading
3226    
# Line 3152  namespace { Line 3264  namespace {
3264              UpdateVelocityTable();              UpdateVelocityTable();
3265    
3266              // jump to start of the wave pool indices (if not already there)              // jump to start of the wave pool indices (if not already there)
3267              if (file->pVersion && file->pVersion->major == 3)              if (file->pVersion && file->pVersion->major > 2)
3268                  _3lnk->SetPos(68); // version 3 has a different 3lnk structure                  _3lnk->SetPos(68); // version 3 has a different 3lnk structure
3269              else              else
3270                  _3lnk->SetPos(44);                  _3lnk->SetPos(44);
# Line 3161  namespace { Line 3273  namespace {
3273              if (file->GetAutoLoad()) {              if (file->GetAutoLoad()) {
3274                  for (uint i = 0; i < DimensionRegions; i++) {                  for (uint i = 0; i < DimensionRegions; i++) {
3275                      uint32_t wavepoolindex = _3lnk->ReadUint32();                      uint32_t wavepoolindex = _3lnk->ReadUint32();
3276                      if (file->pWavePoolTable) pDimensionRegions[i]->pSample = GetSampleFromWavePool(wavepoolindex);                      if (file->pWavePoolTable && pDimensionRegions[i])
3277                            pDimensionRegions[i]->pSample = GetSampleFromWavePool(wavepoolindex);
3278                  }                  }
3279                  GetSample(); // load global region sample reference                  GetSample(); // load global region sample reference
3280              }              }
# Line 3210  namespace { Line 3323  namespace {
3323          }          }
3324    
3325          File* pFile = (File*) GetParent()->GetParent();          File* pFile = (File*) GetParent()->GetParent();
3326          bool version3 = pFile->pVersion && pFile->pVersion->major == 3;          bool versiongt2 = pFile->pVersion && pFile->pVersion->major > 2;
3327          const int iMaxDimensions =  version3 ? 8 : 5;          const int iMaxDimensions =  versiongt2 ? 8 : 5;
3328          const int iMaxDimensionRegions = version3 ? 256 : 32;          const int iMaxDimensionRegions = versiongt2 ? 256 : 32;
3329    
3330          // make sure '3lnk' chunk exists          // make sure '3lnk' chunk exists
3331          RIFF::Chunk* _3lnk = pCkRegion->GetSubChunk(CHUNK_ID_3LNK);          RIFF::Chunk* _3lnk = pCkRegion->GetSubChunk(CHUNK_ID_3LNK);
3332          if (!_3lnk) {          if (!_3lnk) {
3333              const int _3lnkChunkSize = version3 ? 1092 : 172;              const int _3lnkChunkSize = versiongt2 ? 1092 : 172;
3334              _3lnk = pCkRegion->AddSubChunk(CHUNK_ID_3LNK, _3lnkChunkSize);              _3lnk = pCkRegion->AddSubChunk(CHUNK_ID_3LNK, _3lnkChunkSize);
3335              memset(_3lnk->LoadChunkData(), 0, _3lnkChunkSize);              memset(_3lnk->LoadChunkData(), 0, _3lnkChunkSize);
3336    
# Line 3241  namespace { Line 3354  namespace {
3354          }          }
3355    
3356          // update wave pool table in '3lnk' chunk          // update wave pool table in '3lnk' chunk
3357          const int iWavePoolOffset = version3 ? 68 : 44;          const int iWavePoolOffset = versiongt2 ? 68 : 44;
3358          for (uint i = 0; i < iMaxDimensionRegions; i++) {          for (uint i = 0; i < iMaxDimensionRegions; i++) {
3359              int iWaveIndex = -1;              int iWaveIndex = -1;
3360              if (i < DimensionRegions) {              if (i < DimensionRegions) {
# Line 3384  namespace { Line 3497  namespace {
3497    
3498          // check if max. amount of dimensions reached          // check if max. amount of dimensions reached
3499          File* file = (File*) GetParent()->GetParent();          File* file = (File*) GetParent()->GetParent();
3500          const int iMaxDimensions = (file->pVersion && file->pVersion->major == 3) ? 8 : 5;          const int iMaxDimensions = (file->pVersion && file->pVersion->major > 2) ? 8 : 5;
3501          if (Dimensions >= iMaxDimensions)          if (Dimensions >= iMaxDimensions)
3502              throw gig::Exception("Could not add new dimension, max. amount of " + ToString(iMaxDimensions) + " dimensions already reached");              throw gig::Exception("Could not add new dimension, max. amount of " + ToString(iMaxDimensions) + " dimensions already reached");
3503          // check if max. amount of dimension bits reached          // check if max. amount of dimension bits reached
# Line 4042  namespace { Line 4155  namespace {
4155          if ((int32_t)WavePoolTableIndex == -1) return NULL;          if ((int32_t)WavePoolTableIndex == -1) return NULL;
4156          File* file = (File*) GetParent()->GetParent();          File* file = (File*) GetParent()->GetParent();
4157          if (!file->pWavePoolTable) return NULL;          if (!file->pWavePoolTable) return NULL;
4158            if (WavePoolTableIndex + 1 > file->WavePoolCount) return NULL;
4159          // for new files or files >= 2 GB use 64 bit wave pool offsets          // for new files or files >= 2 GB use 64 bit wave pool offsets
4160          if (file->pRIFF->IsNew() || (file->pRIFF->GetCurrentFileSize() >> 31)) {          if (file->pRIFF->IsNew() || (file->pRIFF->GetCurrentFileSize() >> 31)) {
4161              // use 64 bit wave pool offsets (treating this as large file)              // use 64 bit wave pool offsets (treating this as large file)
# Line 4668  namespace { Line 4782  namespace {
4782          RegionList::iterator end  = pRegions->end();          RegionList::iterator end  = pRegions->end();
4783          for (; iter != end; ++iter) {          for (; iter != end; ++iter) {
4784              gig::Region* pRegion = static_cast<gig::Region*>(*iter);              gig::Region* pRegion = static_cast<gig::Region*>(*iter);
4785              for (int iKey = pRegion->KeyRange.low; iKey <= pRegion->KeyRange.high; iKey++) {              const int low  = std::max(int(pRegion->KeyRange.low), 0);
4786                const int high = std::min(int(pRegion->KeyRange.high), 127);
4787                for (int iKey = low; iKey <= high; iKey++) {
4788                  RegionKeyTable[iKey] = pRegion;                  RegionKeyTable[iKey] = pRegion;
4789              }              }
4790          }          }
# Line 4713  namespace { Line 4829  namespace {
4829              File* pFile = (File*) GetParent();              File* pFile = (File*) GetParent();
4830    
4831              // 3ewg is bigger in gig3, as it includes the iMIDI rules              // 3ewg is bigger in gig3, as it includes the iMIDI rules
4832              int size = (pFile->pVersion && pFile->pVersion->major == 3) ? 16416 : 12;              int size = (pFile->pVersion && pFile->pVersion->major > 2) ? 16416 : 12;
4833              _3ewg = lart->AddSubChunk(CHUNK_ID_3EWG, size);              _3ewg = lart->AddSubChunk(CHUNK_ID_3EWG, size);
4834              memset(_3ewg->LoadChunkData(), 0, size);              memset(_3ewg->LoadChunkData(), 0, size);
4835          }          }
# Line 5295  namespace { Line 5411  namespace {
5411          RIFF::List* _3gnl = _3gri->GetSubList(LIST_TYPE_3GNL);          RIFF::List* _3gnl = _3gri->GetSubList(LIST_TYPE_3GNL);
5412          if (!_3gnl) _3gnl = _3gri->AddSubList(LIST_TYPE_3GNL);          if (!_3gnl) _3gnl = _3gri->AddSubList(LIST_TYPE_3GNL);
5413    
5414          if (!pNameChunk && pFile->pVersion && pFile->pVersion->major == 3) {          if (!pNameChunk && pFile->pVersion && pFile->pVersion->major > 2) {
5415              // v3 has a fixed list of 128 strings, find a free one              // v3 has a fixed list of 128 strings, find a free one
5416              for (RIFF::Chunk* ck = _3gnl->GetFirstSubChunk() ; ck ; ck = _3gnl->GetNextSubChunk()) {              for (RIFF::Chunk* ck = _3gnl->GetFirstSubChunk() ; ck ; ck = _3gnl->GetNextSubChunk()) {
5417                  if (strcmp(static_cast<char*>(ck->LoadChunkData()), "") == 0) {                  if (strcmp(static_cast<char*>(ck->LoadChunkData()), "") == 0) {
# Line 5390  namespace { Line 5506  namespace {
5506          0, 3, 20030331 & 0xffff, 20030331 >> 16          0, 3, 20030331 & 0xffff, 20030331 >> 16
5507      };      };
5508    
5509        /// Reflects Gigasampler file format version 4.0 (2007-10-12).
5510        const DLS::version_t File::VERSION_4 = {
5511            0, 4, 20071012 & 0xffff, 20071012 >> 16
5512        };
5513    
5514      static const DLS::Info::string_length_t _FileFixedStringLengths[] = {      static const DLS::Info::string_length_t _FileFixedStringLengths[] = {
5515          { CHUNK_ID_IARL, 256 },          { CHUNK_ID_IARL, 256 },
5516          { CHUNK_ID_IART, 128 },          { CHUNK_ID_IART, 128 },
# Line 5486  namespace { Line 5607  namespace {
5607          return static_cast<gig::Sample*>( *it );          return static_cast<gig::Sample*>( *it );
5608      }      }
5609    
5610        /**
5611         * Returns the total amount of samples of this gig file.
5612         *
5613         * Note that this method might block for a long time in case it is required
5614         * to load the sample info for the first time.
5615         *
5616         * @returns total amount of samples
5617         */
5618        size_t File::CountSamples() {
5619            if (!pSamples) LoadSamples();
5620            if (!pSamples) return 0;
5621            return pSamples->size();
5622        }
5623    
5624      /** @brief Add a new sample.      /** @brief Add a new sample.
5625       *       *
5626       * This will create a new Sample object for the gig file. You have to       * This will create a new Sample object for the gig file. You have to
# Line 5621  namespace { Line 5756  namespace {
5756      }      }
5757    
5758      /**      /**
5759         * Returns the total amount of instruments of this gig file.
5760         *
5761         * Note that this method might block for a long time in case it is required
5762         * to load the instruments info for the first time.
5763         *
5764         * @returns total amount of instruments
5765         */
5766        size_t File::CountInstruments() {
5767            if (!pInstruments) LoadInstruments();
5768            if (!pInstruments) return 0;
5769            return pInstruments->size();
5770        }
5771    
5772        /**
5773       * Returns the instrument with the given index.       * Returns the instrument with the given index.
5774       *       *
5775       * @param index     - number of the sought instrument (0..n)       * @param index     - number of the sought instrument (0..n)
# Line 5939  namespace { Line 6088  namespace {
6088              _3crc = pRIFF->AddSubChunk(CHUNK_ID_3CRC, pSamples->size() * 8);              _3crc = pRIFF->AddSubChunk(CHUNK_ID_3CRC, pSamples->size() * 8);
6089              // the order of einf and 3crc is not the same in v2 and v3              // the order of einf and 3crc is not the same in v2 and v3
6090              RIFF::Chunk* einf = pRIFF->GetSubChunk(CHUNK_ID_EINF);              RIFF::Chunk* einf = pRIFF->GetSubChunk(CHUNK_ID_EINF);
6091              if (einf && pVersion && pVersion->major == 3) pRIFF->MoveSubChunk(_3crc, einf);              if (einf && pVersion && pVersion->major > 2) pRIFF->MoveSubChunk(_3crc, einf);
6092              bRequiresSave = true;              bRequiresSave = true;
6093          } else if (_3crc->GetNewSize() != pSamples->size() * 8) {          } else if (_3crc->GetNewSize() != pSamples->size() * 8) {
6094              _3crc->Resize(pSamples->size() * 8);              _3crc->Resize(pSamples->size() * 8);
# Line 6088  namespace { Line 6237  namespace {
6237                  RIFF::Chunk* ck = lst3gnl->GetFirstSubChunk();                  RIFF::Chunk* ck = lst3gnl->GetFirstSubChunk();
6238                  while (ck) {                  while (ck) {
6239                      if (ck->GetChunkID() == CHUNK_ID_3GNM) {                      if (ck->GetChunkID() == CHUNK_ID_3GNM) {
6240                          if (pVersion && pVersion->major == 3 &&                          if (pVersion && pVersion->major > 2 &&
6241                              strcmp(static_cast<char*>(ck->LoadChunkData()), "") == 0) break;                              strcmp(static_cast<char*>(ck->LoadChunkData()), "") == 0) break;
6242    
6243                          pGroups->push_back(new Group(this, ck));                          pGroups->push_back(new Group(this, ck));
# Line 6264  namespace { Line 6413  namespace {
6413    
6414              // v3: make sure the file has 128 3gnm chunks              // v3: make sure the file has 128 3gnm chunks
6415              // (before updating the Group chunks)              // (before updating the Group chunks)
6416              if (pVersion && pVersion->major == 3) {              if (pVersion && pVersion->major > 2) {
6417                  RIFF::Chunk* _3gnm = _3gnl->GetFirstSubChunk();                  RIFF::Chunk* _3gnm = _3gnl->GetFirstSubChunk();
6418                  for (int i = 0 ; i < 128 ; i++) {                  for (int i = 0 ; i < 128 ; i++) {
6419                      if (i >= pGroups->size()) ::SaveString(CHUNK_ID_3GNM, _3gnm, _3gnl, "", "", true, 64);                      if (i >= pGroups->size()) ::SaveString(CHUNK_ID_3GNM, _3gnm, _3gnl, "", "", true, 64);
# Line 6410  namespace { Line 6559  namespace {
6559          } else /*if (newFile)*/ {          } else /*if (newFile)*/ {
6560              _3crc = pRIFF->AddSubChunk(CHUNK_ID_3CRC, pSamples->size() * 8);              _3crc = pRIFF->AddSubChunk(CHUNK_ID_3CRC, pSamples->size() * 8);
6561              // the order of einf and 3crc is not the same in v2 and v3              // the order of einf and 3crc is not the same in v2 and v3
6562              if (einf && pVersion && pVersion->major == 3) pRIFF->MoveSubChunk(_3crc, einf);              if (einf && pVersion && pVersion->major > 2) pRIFF->MoveSubChunk(_3crc, einf);
6563          }          }
6564          { // must be performed in RAM here ...          { // must be performed in RAM here ...
6565              uint32_t* pData = (uint32_t*) _3crc->LoadChunkData();              uint32_t* pData = (uint32_t*) _3crc->LoadChunkData();
# Line 6468  namespace { Line 6617  namespace {
6617  // *************** Exception ***************  // *************** Exception ***************
6618  // *  // *
6619    
6620      Exception::Exception(String Message) : DLS::Exception(Message) {      Exception::Exception() : DLS::Exception() {
6621        }
6622    
6623        Exception::Exception(String format, ...) : DLS::Exception() {
6624            va_list arg;
6625            va_start(arg, format);
6626            Message = assemble(format, arg);
6627            va_end(arg);
6628        }
6629    
6630        Exception::Exception(String format, va_list arg) : DLS::Exception() {
6631            Message = assemble(format, arg);
6632      }      }
6633    
6634      void Exception::PrintMessage() {      void Exception::PrintMessage() {

Legend:
Removed from v.3140  
changed lines
  Added in v.3442

  ViewVC Help
Powered by ViewVC