/[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 1050 by schoenebeck, Fri Mar 2 01:04:45 2007 UTC revision 1070 by persson, Mon Mar 5 17:42:35 2007 UTC
# Line 1338  namespace { Line 1338  namespace {
1338                  if (lfo3ctrl & 0x40) // bit 6                  if (lfo3ctrl & 0x40) // bit 6
1339                      VCFType = vcf_type_lowpassturbo;                      VCFType = vcf_type_lowpassturbo;
1340              }              }
1341                if (_3ewa->RemainingBytes() >= 8) {
1342                    _3ewa->Read(DimensionUpperLimits, 1, 8);
1343                } else {
1344                    memset(DimensionUpperLimits, 0, 8);
1345                }
1346          } else { // '3ewa' chunk does not exist yet          } else { // '3ewa' chunk does not exist yet
1347              // use default values              // use default values
1348              LFO3Frequency                   = 1.0;              LFO3Frequency                   = 1.0;
# Line 1418  namespace { Line 1423  namespace {
1423              VCFVelocityDynamicRange         = 0x04;              VCFVelocityDynamicRange         = 0x04;
1424              VCFVelocityCurve                = curve_type_linear;              VCFVelocityCurve                = curve_type_linear;
1425              VCFType                         = vcf_type_lowpass;              VCFType                         = vcf_type_lowpass;
1426                memset(DimensionUpperLimits, 0, 8);
1427          }          }
1428    
1429          pVelocityAttenuationTable = GetVelocityTable(VelocityResponseCurve,          pVelocityAttenuationTable = GetVelocityTable(VelocityResponseCurve,
# Line 1473  namespace { Line 1479  namespace {
1479    
1480          // update '3ewa' chunk with DimensionRegion's current settings          // update '3ewa' chunk with DimensionRegion's current settings
1481    
1482          const uint32_t unknown = _3ewa->GetSize(); // unknown, always chunk size ?          const uint32_t chunksize = _3ewa->GetSize();
1483          memcpy(&pData[0], &unknown, 4);          memcpy(&pData[0], &chunksize, 4); // unknown, always chunk size?
1484    
1485          const int32_t lfo3freq = (int32_t) GIG_EXP_ENCODE(LFO3Frequency);          const int32_t lfo3freq = (int32_t) GIG_EXP_ENCODE(LFO3Frequency);
1486          memcpy(&pData[4], &lfo3freq, 4);          memcpy(&pData[4], &lfo3freq, 4);
# Line 1729  namespace { Line 1735  namespace {
1735    
1736          const uint8_t vcftype = (VCFType == vcf_type_lowpassturbo) ? vcf_type_lowpass : VCFType;          const uint8_t vcftype = (VCFType == vcf_type_lowpassturbo) ? vcf_type_lowpass : VCFType;
1737          memcpy(&pData[139], &vcftype, 1);          memcpy(&pData[139], &vcftype, 1);
1738    
1739            if (chunksize >= 148) {
1740                memcpy(&pData[140], DimensionUpperLimits, 8);
1741            }
1742      }      }
1743    
1744      // 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
# Line 2248  namespace { Line 2258  namespace {
2258          int dim[8] = { 0 };          int dim[8] = { 0 };
2259          for (int i = 0 ; i < DimensionRegions ; i++) {          for (int i = 0 ; i < DimensionRegions ; i++) {
2260    
2261              if (pDimensionRegions[i]->VelocityUpperLimit) {              if (pDimensionRegions[i]->DimensionUpperLimits[veldim] ||
2262                    pDimensionRegions[i]->VelocityUpperLimit) {
2263                  // create the velocity table                  // create the velocity table
2264                  uint8_t* table = pDimensionRegions[i]->VelocityTable;                  uint8_t* table = pDimensionRegions[i]->VelocityTable;
2265                  if (!table) {                  if (!table) {
# Line 2257  namespace { Line 2268  namespace {
2268                  }                  }
2269                  int tableidx = 0;                  int tableidx = 0;
2270                  int velocityZone = 0;                  int velocityZone = 0;
2271                  for (int k = i ; k < end ; k += step) {                  if (pDimensionRegions[i]->DimensionUpperLimits[veldim]) { // gig3
2272                      DimensionRegion *d = pDimensionRegions[k];                      for (int k = i ; k < end ; k += step) {
2273                      for (; tableidx <= d->VelocityUpperLimit ; tableidx++) table[tableidx] = velocityZone;                          DimensionRegion *d = pDimensionRegions[k];
2274                      velocityZone++;                          for (; tableidx <= d->DimensionUpperLimits[veldim] ; tableidx++) table[tableidx] = velocityZone;
2275                            velocityZone++;
2276                        }
2277                    } else { // gig2
2278                        for (int k = i ; k < end ; k += step) {
2279                            DimensionRegion *d = pDimensionRegions[k];
2280                            for (; tableidx <= d->VelocityUpperLimit ; tableidx++) table[tableidx] = velocityZone;
2281                            velocityZone++;
2282                        }
2283                  }                  }
2284              } else {              } else {
2285                  if (pDimensionRegions[i]->VelocityTable) {                  if (pDimensionRegions[i]->VelocityTable) {
# Line 2455  namespace { Line 2474  namespace {
2474              } else {              } else {
2475                  switch (pDimensionDefinitions[i].split_type) {                  switch (pDimensionDefinitions[i].split_type) {
2476                      case split_type_normal:                      case split_type_normal:
2477                          bits = uint8_t(DimValues[i] / pDimensionDefinitions[i].zone_size);                          if (pDimensionRegions[0]->DimensionUpperLimits[i]) {
2478                                // gig3: all normal dimensions (not just the velocity dimension) have custom zone ranges
2479                                for (bits = 0 ; bits < pDimensionDefinitions[i].zones ; bits++) {
2480                                    if (DimValues[i] <= pDimensionRegions[bits << bitpos]->DimensionUpperLimits[i]) break;
2481                                }
2482                            } else {
2483                                // gig2: evenly sized zones
2484                                bits = uint8_t(DimValues[i] / pDimensionDefinitions[i].zone_size);
2485                            }
2486                          break;                          break;
2487                      case split_type_bit: // the value is already the sought dimension bit number                      case split_type_bit: // the value is already the sought dimension bit number
2488                          const uint8_t limiter_mask = (0xff << pDimensionDefinitions[i].bits) ^ 0xff;                          const uint8_t limiter_mask = (0xff << pDimensionDefinitions[i].bits) ^ 0xff;
# Line 2469  namespace { Line 2496  namespace {
2496          DimensionRegion* dimreg = pDimensionRegions[dimregidx];          DimensionRegion* dimreg = pDimensionRegions[dimregidx];
2497          if (veldim != -1) {          if (veldim != -1) {
2498              // (dimreg is now the dimension region for the lowest velocity)              // (dimreg is now the dimension region for the lowest velocity)
2499              if (dimreg->VelocityUpperLimit) // custom defined zone ranges              if (dimreg->VelocityTable) // custom defined zone ranges
2500                  bits = dimreg->VelocityTable[DimValues[veldim]];                  bits = dimreg->VelocityTable[DimValues[veldim]];
2501              else // normal split type              else // normal split type
2502                  bits = uint8_t(DimValues[veldim] / pDimensionDefinitions[veldim].zone_size);                  bits = uint8_t(DimValues[veldim] / pDimensionDefinitions[veldim].zone_size);

Legend:
Removed from v.1050  
changed lines
  Added in v.1070

  ViewVC Help
Powered by ViewVC