/[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 345 by schoenebeck, Fri Jan 21 16:40:37 2005 UTC revision 347 by schoenebeck, Sun Jan 23 20:47:18 2005 UTC
# Line 1083  namespace gig { Line 1083  namespace gig {
1083      Region::Region(Instrument* pInstrument, RIFF::List* rgnList) : DLS::Region((DLS::Instrument*) pInstrument, rgnList) {      Region::Region(Instrument* pInstrument, RIFF::List* rgnList) : DLS::Region((DLS::Instrument*) pInstrument, rgnList) {
1084          // Initialization          // Initialization
1085          Dimensions = 0;          Dimensions = 0;
1086          for (int i = 0; i < 32; i++) {          for (int i = 0; i < 256; i++) {
1087              pDimensionRegions[i] = NULL;              pDimensionRegions[i] = NULL;
1088          }          }
1089          Layers = 1;          Layers = 1;
1090            File* file = (File*) GetParent()->GetParent();
1091            int dimensionBits = (file->pVersion && file->pVersion->major == 3) ? 8 : 5;
1092    
1093          // Actual Loading          // Actual Loading
1094    
# Line 1095  namespace gig { Line 1097  namespace gig {
1097          RIFF::Chunk* _3lnk = rgnList->GetSubChunk(CHUNK_ID_3LNK);          RIFF::Chunk* _3lnk = rgnList->GetSubChunk(CHUNK_ID_3LNK);
1098          if (_3lnk) {          if (_3lnk) {
1099              DimensionRegions = _3lnk->ReadUint32();              DimensionRegions = _3lnk->ReadUint32();
1100              for (int i = 0; i < 5; i++) {              for (int i = 0; i < dimensionBits; i++) {
1101                  dimension_t dimension = static_cast<dimension_t>(_3lnk->ReadUint8());                  dimension_t dimension = static_cast<dimension_t>(_3lnk->ReadUint8());
1102                  uint8_t     bits      = _3lnk->ReadUint8();                  uint8_t     bits      = _3lnk->ReadUint8();
1103                  if (dimension == dimension_none) { // inactive dimension                  if (dimension == dimension_none) { // inactive dimension
# Line 1138  namespace gig { Line 1140  namespace gig {
1140                      else { // custom defined ranges                      else { // custom defined ranges
1141                          pDimDef->split_type = split_type_customvelocity;                          pDimDef->split_type = split_type_customvelocity;
1142                          pDimDef->ranges     = new range_t[pDimDef->zones];                          pDimDef->ranges     = new range_t[pDimDef->zones];
1143                          unsigned int bits[5] = {0,0,0,0,0};                          uint8_t bits[8] = { 0 };
1144                          int previousUpperLimit = -1;                          int previousUpperLimit = -1;
1145                          for (int velocityZone = 0; velocityZone < pDimDef->zones; velocityZone++) {                          for (int velocityZone = 0; velocityZone < pDimDef->zones; velocityZone++) {
1146                              bits[i] = velocityZone;                              bits[i] = velocityZone;
1147                              DimensionRegion* pDimRegion = GetDimensionRegionByBit(bits[4],bits[3],bits[2],bits[1],bits[0]);                              DimensionRegion* pDimRegion = GetDimensionRegionByBit(bits);
1148    
1149                              pDimDef->ranges[velocityZone].low  = previousUpperLimit + 1;                              pDimDef->ranges[velocityZone].low  = previousUpperLimit + 1;
1150                              pDimDef->ranges[velocityZone].high = pDimRegion->VelocityUpperLimit;                              pDimDef->ranges[velocityZone].high = pDimRegion->VelocityUpperLimit;
# Line 1210  namespace gig { Line 1212  namespace gig {
1212       * left channel, 1 for right channel or 0 for layer 0, 1 for layer 1,       * left channel, 1 for right channel or 0 for layer 0, 1 for layer 1,
1213       * etc.).       * etc.).
1214       *       *
1215       * @param  Dim4Val  MIDI controller value (0-127) for dimension 4       * @param  DimValues  MIDI controller values (0-127) for dimension 0 to 7
      * @param  Dim3Val  MIDI controller value (0-127) for dimension 3  
      * @param  Dim2Val  MIDI controller value (0-127) for dimension 2  
      * @param  Dim1Val  MIDI controller value (0-127) for dimension 1  
      * @param  Dim0Val  MIDI controller value (0-127) for dimension 0  
1216       * @returns         adress to the DimensionRegion for the given situation       * @returns         adress to the DimensionRegion for the given situation
1217       * @see             pDimensionDefinitions       * @see             pDimensionDefinitions
1218       * @see             Dimensions       * @see             Dimensions
1219       */       */
1220      DimensionRegion* Region::GetDimensionRegionByValue(uint Dim4Val, uint Dim3Val, uint Dim2Val, uint Dim1Val, uint Dim0Val) {      DimensionRegion* Region::GetDimensionRegionByValue(const uint DimValues[8]) {
1221          uint8_t bits[5] = {Dim0Val,Dim1Val,Dim2Val,Dim3Val,Dim4Val};          uint8_t bits[8] = { 0 };
1222          for (uint i = 0; i < Dimensions; i++) {          for (uint i = 0; i < Dimensions; i++) {
1223                bits[i] = DimValues[i];
1224              switch (pDimensionDefinitions[i].split_type) {              switch (pDimensionDefinitions[i].split_type) {
1225                  case split_type_normal:                  case split_type_normal:
1226                      bits[i] /= pDimensionDefinitions[i].zone_size;                      bits[i] /= pDimensionDefinitions[i].zone_size;
# Line 1235  namespace gig { Line 1234  namespace gig {
1234                      break;                      break;
1235              }              }
1236          }          }
1237          return GetDimensionRegionByBit(bits[4],bits[3],bits[2],bits[1],bits[0]);          return GetDimensionRegionByBit(bits);
1238      }      }
1239    
1240      /**      /**
# Line 1243  namespace gig { Line 1242  namespace gig {
1242       * numbers (zone index). You usually use <i>GetDimensionRegionByValue</i>       * numbers (zone index). You usually use <i>GetDimensionRegionByValue</i>
1243       * instead of calling this method directly!       * instead of calling this method directly!
1244       *       *
1245       * @param Dim4Bit  Bit number for dimension 4       * @param DimBits  Bit numbers for dimension 0 to 7
      * @param Dim3Bit  Bit number for dimension 3  
      * @param Dim2Bit  Bit number for dimension 2  
      * @param Dim1Bit  Bit number for dimension 1  
      * @param Dim0Bit  Bit number for dimension 0  
1246       * @returns        adress to the DimensionRegion for the given dimension       * @returns        adress to the DimensionRegion for the given dimension
1247       *                 bit numbers       *                 bit numbers
1248       * @see            GetDimensionRegionByValue()       * @see            GetDimensionRegionByValue()
1249       */       */
1250      DimensionRegion* Region::GetDimensionRegionByBit(uint8_t Dim4Bit, uint8_t Dim3Bit, uint8_t Dim2Bit, uint8_t Dim1Bit, uint8_t Dim0Bit) {      DimensionRegion* Region::GetDimensionRegionByBit(const uint8_t DimBits[8]) {
1251          return *(pDimensionRegions + ((((((((Dim4Bit << pDimensionDefinitions[3].bits) | Dim3Bit)          return pDimensionRegions[((((((DimBits[7] << pDimensionDefinitions[6].bits | DimBits[6])
1252                                                       << pDimensionDefinitions[2].bits) | Dim2Bit)                                                    << pDimensionDefinitions[5].bits | DimBits[5])
1253                                                       << pDimensionDefinitions[1].bits) | Dim1Bit)                                                    << pDimensionDefinitions[4].bits | DimBits[4])
1254                                                       << pDimensionDefinitions[0].bits) | Dim0Bit) );                                                    << pDimensionDefinitions[3].bits | DimBits[3])
1255                                                      << pDimensionDefinitions[2].bits | DimBits[2])
1256                                                      << pDimensionDefinitions[1].bits | DimBits[1])
1257                                                      << pDimensionDefinitions[0].bits | DimBits[0]];
1258      }      }
1259    
1260      /**      /**

Legend:
Removed from v.345  
changed lines
  Added in v.347

  ViewVC Help
Powered by ViewVC