/[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 1218 by persson, Fri Jun 1 19:19:28 2007 UTC revision 1247 by persson, Fri Jun 22 09:59:57 2007 UTC
# Line 1256  namespace { Line 1256  namespace {
1256    
1257          pSample = NULL;          pSample = NULL;
1258    
1259          memcpy(&Crossfade, &SamplerOptions, 4);          if (_3ewl->GetSubChunk(CHUNK_ID_WSMP)) memcpy(&Crossfade, &SamplerOptions, 4);
1260            else memset(&Crossfade, 0, 4);
1261    
1262          if (!pVelocityTables) pVelocityTables = new VelocityTableMap;          if (!pVelocityTables) pVelocityTables = new VelocityTableMap;
1263    
1264          RIFF::Chunk* _3ewa = _3ewl->GetSubChunk(CHUNK_ID_3EWA);          RIFF::Chunk* _3ewa = _3ewl->GetSubChunk(CHUNK_ID_3EWA);
# Line 1491  namespace { Line 1493  namespace {
1493              VCFVelocityDynamicRange         = 0x04;              VCFVelocityDynamicRange         = 0x04;
1494              VCFVelocityCurve                = curve_type_linear;              VCFVelocityCurve                = curve_type_linear;
1495              VCFType                         = vcf_type_lowpass;              VCFType                         = vcf_type_lowpass;
1496              memset(DimensionUpperLimits, 0, 8);              memset(DimensionUpperLimits, 127, 8);
1497          }          }
1498    
1499          pVelocityAttenuationTable = GetVelocityTable(VelocityResponseCurve,          pVelocityAttenuationTable = GetVelocityTable(VelocityResponseCurve,
# Line 1540  namespace { Line 1542  namespace {
1542          // first update base class's chunk          // first update base class's chunk
1543          DLS::Sampler::UpdateChunks();          DLS::Sampler::UpdateChunks();
1544    
1545            RIFF::Chunk* wsmp = pParentList->GetSubChunk(CHUNK_ID_WSMP);
1546            uint8_t* pData = (uint8_t*) wsmp->LoadChunkData();
1547            pData[12] = Crossfade.in_start;
1548            pData[13] = Crossfade.in_end;
1549            pData[14] = Crossfade.out_start;
1550            pData[15] = Crossfade.out_end;
1551    
1552          // make sure '3ewa' chunk exists          // make sure '3ewa' chunk exists
1553          RIFF::Chunk* _3ewa = pParentList->GetSubChunk(CHUNK_ID_3EWA);          RIFF::Chunk* _3ewa = pParentList->GetSubChunk(CHUNK_ID_3EWA);
1554          if (!_3ewa)  _3ewa = pParentList->AddSubChunk(CHUNK_ID_3EWA, 140);          if (!_3ewa)  _3ewa = pParentList->AddSubChunk(CHUNK_ID_3EWA, 140);
1555          uint8_t* pData = (uint8_t*) _3ewa->LoadChunkData();          pData = (uint8_t*) _3ewa->LoadChunkData();
1556    
1557          // update '3ewa' chunk with DimensionRegion's current settings          // update '3ewa' chunk with DimensionRegion's current settings
1558    
# Line 2247  namespace { Line 2256  namespace {
2256          // first update base class's chunks          // first update base class's chunks
2257          DLS::Region::UpdateChunks();          DLS::Region::UpdateChunks();
2258    
2259            File* pFile = (File*) GetParent()->GetParent();
2260            bool version3 = pFile->pVersion && pFile->pVersion->major == 3;
2261    
2262          // update dimension region's chunks          // update dimension region's chunks
2263          for (int i = 0; i < DimensionRegions; i++) {          for (int i = 0; i < DimensionRegions; i++) {
2264              pDimensionRegions[i]->UpdateChunks();              DimensionRegion* d = pDimensionRegions[i];
2265    
2266                // make sure '3ewa' chunk exists (we need to this before
2267                // calling DimensionRegion::UpdateChunks, as
2268                // DimensionRegion doesn't know which file version it is)
2269                RIFF::Chunk* _3ewa = d->pParentList->GetSubChunk(CHUNK_ID_3EWA);
2270                if (!_3ewa) d->pParentList->AddSubChunk(CHUNK_ID_3EWA, version3 ? 148 : 140);
2271    
2272                d->UpdateChunks();
2273          }          }
2274    
2275          File* pFile = (File*) GetParent()->GetParent();          const int iMaxDimensions =  version3 ? 8 : 5;
2276          const int iMaxDimensions = (pFile->pVersion && pFile->pVersion->major == 3) ? 8 : 5;          const int iMaxDimensionRegions = version3 ? 256 : 32;
         const int iMaxDimensionRegions = (pFile->pVersion && pFile->pVersion->major == 3) ? 256 : 32;  
2277    
2278          // make sure '3lnk' chunk exists          // make sure '3lnk' chunk exists
2279          RIFF::Chunk* _3lnk = pCkRegion->GetSubChunk(CHUNK_ID_3LNK);          RIFF::Chunk* _3lnk = pCkRegion->GetSubChunk(CHUNK_ID_3LNK);
2280          if (!_3lnk) {          if (!_3lnk) {
2281              const int _3lnkChunkSize = (pFile->pVersion && pFile->pVersion->major == 3) ? 1092 : 172;              const int _3lnkChunkSize = version3 ? 1092 : 172;
2282              _3lnk = pCkRegion->AddSubChunk(CHUNK_ID_3LNK, _3lnkChunkSize);              _3lnk = pCkRegion->AddSubChunk(CHUNK_ID_3LNK, _3lnkChunkSize);
2283              memset(_3lnk->LoadChunkData(), 0, _3lnkChunkSize);              memset(_3lnk->LoadChunkData(), 0, _3lnkChunkSize);
2284    
# Line 2283  namespace { Line 2302  namespace {
2302          }          }
2303    
2304          // update wave pool table in '3lnk' chunk          // update wave pool table in '3lnk' chunk
2305          const int iWavePoolOffset = (pFile->pVersion && pFile->pVersion->major == 3) ? 68 : 44;          const int iWavePoolOffset = version3 ? 68 : 44;
2306          for (uint i = 0; i < iMaxDimensionRegions; i++) {          for (uint i = 0; i < iMaxDimensionRegions; i++) {
2307              int iWaveIndex = -1;              int iWaveIndex = -1;
2308              if (i < DimensionRegions) {              if (i < DimensionRegions) {
# Line 2438  namespace { Line 2457  namespace {
2457              RIFF::List* _3prg = pCkRegion->GetSubList(LIST_TYPE_3PRG);              RIFF::List* _3prg = pCkRegion->GetSubList(LIST_TYPE_3PRG);
2458              RIFF::List* pNewDimRgnListChunk = _3prg->AddSubList(LIST_TYPE_3EWL);              RIFF::List* pNewDimRgnListChunk = _3prg->AddSubList(LIST_TYPE_3EWL);
2459              pDimensionRegions[i] = new DimensionRegion(pNewDimRgnListChunk);              pDimensionRegions[i] = new DimensionRegion(pNewDimRgnListChunk);
2460    
2461                // copy the upper limits for the other dimensions
2462                memcpy(pDimensionRegions[i]->DimensionUpperLimits,
2463                       pDimensionRegions[i & ((1 << iCurrentBits) - 1)]->DimensionUpperLimits, 8);
2464    
2465              DimensionRegions++;              DimensionRegions++;
2466          }          }
2467    
2468            // initialize the upper limits for this dimension
2469            for (int z = 0, j = 0 ; z < pDimDef->zones ; z++, j += 1 << iCurrentBits) {
2470                uint8_t upperLimit = (z + 1) * 128.0 / pDimDef->zones - 1;
2471                for (int i = 0 ; i < 1 << iCurrentBits ; i++) {
2472                    pDimensionRegions[j + i]->DimensionUpperLimits[Dimensions] = upperLimit;
2473                }
2474            }
2475    
2476          Dimensions++;          Dimensions++;
2477    
2478          // if this is a layer dimension, update 'Layers' attribute          // if this is a layer dimension, update 'Layers' attribute
# Line 2481  namespace { Line 2513  namespace {
2513          for (int i = iDimensionNr + 1; i < Dimensions; i++)          for (int i = iDimensionNr + 1; i < Dimensions; i++)
2514              iUpperBits += pDimensionDefinitions[i].bits;              iUpperBits += pDimensionDefinitions[i].bits;
2515    
2516            RIFF::List* _3prg = pCkRegion->GetSubList(LIST_TYPE_3PRG);
2517    
2518          // delete dimension regions which belong to the given dimension          // delete dimension regions which belong to the given dimension
2519          // (that is where the dimension's bit > 0)          // (that is where the dimension's bit > 0)
2520          for (int iUpperBit = 0; iUpperBit < 1 << iUpperBits; iUpperBit++) {          for (int iUpperBit = 0; iUpperBit < 1 << iUpperBits; iUpperBit++) {
# Line 2489  namespace { Line 2523  namespace {
2523                      int iToDelete = iUpperBit    << (pDimensionDefinitions[iDimensionNr].bits + iLowerBits) |                      int iToDelete = iUpperBit    << (pDimensionDefinitions[iDimensionNr].bits + iLowerBits) |
2524                                      iObsoleteBit << iLowerBits |                                      iObsoleteBit << iLowerBits |
2525                                      iLowerBit;                                      iLowerBit;
2526    
2527                        _3prg->DeleteSubChunk(pDimensionRegions[iToDelete]->pParentList);
2528                      delete pDimensionRegions[iToDelete];                      delete pDimensionRegions[iToDelete];
2529                      pDimensionRegions[iToDelete] = NULL;                      pDimensionRegions[iToDelete] = NULL;
2530                      DimensionRegions--;                      DimensionRegions--;
# Line 2509  namespace { Line 2545  namespace {
2545              }              }
2546          }          }
2547    
2548            // remove the this dimension from the upper limits arrays
2549            for (int j = 0 ; j < 256 && pDimensionRegions[j] ; j++) {
2550                DimensionRegion* d = pDimensionRegions[j];
2551                for (int i = iDimensionNr + 1; i < Dimensions; i++) {
2552                    d->DimensionUpperLimits[i - 1] = d->DimensionUpperLimits[i];
2553                }
2554                d->DimensionUpperLimits[Dimensions - 1] = 127;
2555            }
2556    
2557          // 'remove' dimension definition          // 'remove' dimension definition
2558          for (int i = iDimensionNr + 1; i < Dimensions; i++) {          for (int i = iDimensionNr + 1; i < Dimensions; i++) {
2559              pDimensionDefinitions[i - 1] = pDimensionDefinitions[i];              pDimensionDefinitions[i - 1] = pDimensionDefinitions[i];
# Line 3377  namespace { Line 3422  namespace {
3422      void File::UpdateChunks() {      void File::UpdateChunks() {
3423          bool newFile = pRIFF->GetSubList(LIST_TYPE_INFO) == NULL;          bool newFile = pRIFF->GetSubList(LIST_TYPE_INFO) == NULL;
3424    
3425            b64BitWavePoolOffsets = pVersion && pVersion->major == 3;
3426    
3427          // first update base class's chunks          // first update base class's chunks
3428          DLS::File::UpdateChunks();          DLS::File::UpdateChunks();
3429    

Legend:
Removed from v.1218  
changed lines
  Added in v.1247

  ViewVC Help
Powered by ViewVC