/[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 36 by schoenebeck, Wed Mar 10 21:34:28 2004 UTC revision 282 by schoenebeck, Wed Oct 13 20:05:42 2004 UTC
# Line 2  Line 2 
2   *                                                                         *   *                                                                         *
3   *   libgig - C++ cross-platform Gigasampler format file loader library    *   *   libgig - C++ cross-platform Gigasampler format file loader library    *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003 by Christian Schoenebeck                           *   *   Copyright (C) 2003, 2004 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  *
9   *   it under the terms of the GNU General Public License as published by  *   *   it under the terms of the GNU General Public License as published by  *
# Line 680  namespace gig { Line 680  namespace gig {
680          if (!pVelocityTables) pVelocityTables = new VelocityTableMap;          if (!pVelocityTables) pVelocityTables = new VelocityTableMap;
681    
682          RIFF::Chunk* _3ewa = _3ewl->GetSubChunk(CHUNK_ID_3EWA);          RIFF::Chunk* _3ewa = _3ewl->GetSubChunk(CHUNK_ID_3EWA);
683          _3ewa->ReadInt32(); // unknown, allways 0x0000008C ?          _3ewa->ReadInt32(); // unknown, always 0x0000008C ?
684          LFO3Frequency = (double) GIG_EXP_DECODE(_3ewa->ReadInt32());          LFO3Frequency = (double) GIG_EXP_DECODE(_3ewa->ReadInt32());
685          EG3Attack     = (double) GIG_EXP_DECODE(_3ewa->ReadInt32());          EG3Attack     = (double) GIG_EXP_DECODE(_3ewa->ReadInt32());
686          _3ewa->ReadInt16(); // unknown          _3ewa->ReadInt16(); // unknown
# Line 774  namespace gig { Line 774  namespace gig {
774          else if (pitchTrackDimensionBypass & 0x20) DimensionBypass = dim_bypass_ctrl_95;          else if (pitchTrackDimensionBypass & 0x20) DimensionBypass = dim_bypass_ctrl_95;
775          else                                       DimensionBypass = dim_bypass_ctrl_none;          else                                       DimensionBypass = dim_bypass_ctrl_none;
776          uint8_t pan = _3ewa->ReadUint8();          uint8_t pan = _3ewa->ReadUint8();
777          Pan         = (pan < 64) ? pan : (-1) * (int8_t)pan - 63;          Pan         = (pan < 64) ? pan : -((int)pan - 63); // signed 7 bit -> signed 8 bit
778          SelfMask = _3ewa->ReadInt8() & 0x01;          SelfMask = _3ewa->ReadInt8() & 0x01;
779          _3ewa->ReadInt8(); // unknown          _3ewa->ReadInt8(); // unknown
780          uint8_t lfo3ctrl = _3ewa->ReadUint8();          uint8_t lfo3ctrl = _3ewa->ReadUint8();
# Line 841  namespace gig { Line 841  namespace gig {
841                  case curve_type_nonlinear:                  case curve_type_nonlinear:
842                      for (int velocity = 0; velocity < 128; velocity++) {                      for (int velocity = 0; velocity < 128; velocity++) {
843                          pVelocityAttenuationTable[velocity] =                          pVelocityAttenuationTable[velocity] =
844                              GIG_VELOCITY_TRANSFORM_NONLINEAR((double)(velocity+1),(double)(VelocityResponseDepth+1),(double)VelocityResponseCurveScaling);                              GIG_VELOCITY_TRANSFORM_NONLINEAR(((double)velocity),((double)VelocityResponseDepth),((double)VelocityResponseCurveScaling));
845                          if      (pVelocityAttenuationTable[velocity] > 1.0) pVelocityAttenuationTable[velocity] = 1.0;                          if      (pVelocityAttenuationTable[velocity] > 1.0)   pVelocityAttenuationTable[velocity] = 1.0;
846                          else if (pVelocityAttenuationTable[velocity] < 0.0) pVelocityAttenuationTable[velocity] = 0.0;                          else if (pVelocityAttenuationTable[velocity] < 1e-15) pVelocityAttenuationTable[velocity] = 0.0;
847                       }                       }
848                       break;                       break;
849                  case curve_type_linear:                  case curve_type_linear:
850                      for (int velocity = 0; velocity < 128; velocity++) {                      for (int velocity = 0; velocity < 128; velocity++) {
851                          pVelocityAttenuationTable[velocity] =                          pVelocityAttenuationTable[velocity] =
852                              GIG_VELOCITY_TRANSFORM_LINEAR((double)velocity,(double)(VelocityResponseDepth+1),(double)VelocityResponseCurveScaling);                              GIG_VELOCITY_TRANSFORM_LINEAR(((double)velocity),((double)VelocityResponseDepth),((double)VelocityResponseCurveScaling));
853                          if      (pVelocityAttenuationTable[velocity] > 1.0) pVelocityAttenuationTable[velocity] = 1.0;                          if      (pVelocityAttenuationTable[velocity] > 1.0)   pVelocityAttenuationTable[velocity] = 1.0;
854                          else if (pVelocityAttenuationTable[velocity] < 0.0) pVelocityAttenuationTable[velocity] = 0.0;                          else if (pVelocityAttenuationTable[velocity] < 1e-15) pVelocityAttenuationTable[velocity] = 0.0;
855                      }                      }
856                      break;                      break;
857                  case curve_type_special:                  case curve_type_special:
858                      for (int velocity = 0; velocity < 128; velocity++) {                      for (int velocity = 0; velocity < 128; velocity++) {
859                          pVelocityAttenuationTable[velocity] =                          pVelocityAttenuationTable[velocity] =
860                              GIG_VELOCITY_TRANSFORM_SPECIAL((double)(velocity+1),(double)(VelocityResponseDepth+1),(double)VelocityResponseCurveScaling);                              GIG_VELOCITY_TRANSFORM_SPECIAL(((double)velocity),((double)VelocityResponseDepth),((double)VelocityResponseCurveScaling));
861                          if      (pVelocityAttenuationTable[velocity] > 1.0) pVelocityAttenuationTable[velocity] = 1.0;                          if      (pVelocityAttenuationTable[velocity] > 1.0)   pVelocityAttenuationTable[velocity] = 1.0;
862                          else if (pVelocityAttenuationTable[velocity] < 0.0) pVelocityAttenuationTable[velocity] = 0.0;                          else if (pVelocityAttenuationTable[velocity] < 1e-15) pVelocityAttenuationTable[velocity] = 0.0;
863                      }                      }
864                      break;                      break;
865                  case curve_type_unknown:                  case curve_type_unknown:
# Line 869  namespace gig { Line 869  namespace gig {
869              (*pVelocityTables)[tableKey] = pVelocityAttenuationTable; // put the new table into the tables map              (*pVelocityTables)[tableKey] = pVelocityAttenuationTable; // put the new table into the tables map
870          }          }
871      }      }
872        
873      leverage_ctrl_t DimensionRegion::DecodeLeverageController(_lev_ctrl_t EncodedController) {      leverage_ctrl_t DimensionRegion::DecodeLeverageController(_lev_ctrl_t EncodedController) {
874          leverage_ctrl_t decodedcontroller;          leverage_ctrl_t decodedcontroller;
875          switch (EncodedController) {          switch (EncodedController) {
# Line 886  namespace gig { Line 886  namespace gig {
886                  decodedcontroller.type = leverage_ctrl_t::type_channelaftertouch;                  decodedcontroller.type = leverage_ctrl_t::type_channelaftertouch;
887                  decodedcontroller.controller_number = 0;                  decodedcontroller.controller_number = 0;
888                  break;                  break;
889                
890              // ordinary MIDI control change controller              // ordinary MIDI control change controller
891              case _lev_ctrl_modwheel:              case _lev_ctrl_modwheel:
892                  decodedcontroller.type = leverage_ctrl_t::type_controlchange;                  decodedcontroller.type = leverage_ctrl_t::type_controlchange;
# Line 980  namespace gig { Line 980  namespace gig {
980                  decodedcontroller.type = leverage_ctrl_t::type_controlchange;                  decodedcontroller.type = leverage_ctrl_t::type_controlchange;
981                  decodedcontroller.controller_number = 95;                  decodedcontroller.controller_number = 95;
982                  break;                  break;
983                
984              // unknown controller type              // unknown controller type
985              default:              default:
986                  throw gig::Exception("Unknown leverage controller type.");                  throw gig::Exception("Unknown leverage controller type.");
# Line 1029  namespace gig { Line 1029  namespace gig {
1029          for (int i = 0; i < 32; i++) {          for (int i = 0; i < 32; i++) {
1030              pDimensionRegions[i] = NULL;              pDimensionRegions[i] = NULL;
1031          }          }
1032            Layers = 1;
1033    
1034          // Actual Loading          // Actual Loading
1035    
# Line 1053  namespace gig { Line 1054  namespace gig {
1054                      pDimensionDefinitions[i].bits      = bits;                      pDimensionDefinitions[i].bits      = bits;
1055                      pDimensionDefinitions[i].zones     = 0x01 << bits; // = pow(2,bits)                      pDimensionDefinitions[i].zones     = 0x01 << bits; // = pow(2,bits)
1056                      pDimensionDefinitions[i].split_type = (dimension == dimension_layer ||                      pDimensionDefinitions[i].split_type = (dimension == dimension_layer ||
1057                                                             dimension == dimension_samplechannel) ? split_type_bit                                                             dimension == dimension_samplechannel ||
1058                                                                                                   : split_type_normal;                                                             dimension == dimension_releasetrigger) ? split_type_bit
1059                                                                                                      : split_type_normal;
1060                      pDimensionDefinitions[i].ranges = NULL; // it's not possible to check velocity dimensions for custom defined ranges at this point                      pDimensionDefinitions[i].ranges = NULL; // it's not possible to check velocity dimensions for custom defined ranges at this point
1061                      pDimensionDefinitions[i].zone_size  =                      pDimensionDefinitions[i].zone_size  =
1062                          (pDimensionDefinitions[i].split_type == split_type_normal) ? 128 / pDimensionDefinitions[i].zones                          (pDimensionDefinitions[i].split_type == split_type_normal) ? 128 / pDimensionDefinitions[i].zones
1063                                                                                     : 0;                                                                                     : 0;
1064                      Dimensions++;                      Dimensions++;
1065    
1066                        // if this is a layer dimension, remember the amount of layers
1067                        if (dimension == dimension_layer) Layers = pDimensionDefinitions[i].zones;
1068                  }                  }
1069                  _3lnk->SetPos(6, RIFF::stream_curpos); // jump forward to next dimension definition                  _3lnk->SetPos(6, RIFF::stream_curpos); // jump forward to next dimension definition
1070              }              }
# Line 1152  namespace gig { Line 1157  namespace gig {
1157       * @see             Dimensions       * @see             Dimensions
1158       */       */
1159      DimensionRegion* Region::GetDimensionRegionByValue(uint Dim4Val, uint Dim3Val, uint Dim2Val, uint Dim1Val, uint Dim0Val) {      DimensionRegion* Region::GetDimensionRegionByValue(uint Dim4Val, uint Dim3Val, uint Dim2Val, uint Dim1Val, uint Dim0Val) {
1160          unsigned int bits[5] = {Dim0Val,Dim1Val,Dim2Val,Dim3Val,Dim4Val};          uint8_t bits[5] = {Dim0Val,Dim1Val,Dim2Val,Dim3Val,Dim4Val};
1161          for (uint i = 0; i < Dimensions; i++) {          for (uint i = 0; i < Dimensions; i++) {
1162              switch (pDimensionDefinitions[i].split_type) {              switch (pDimensionDefinitions[i].split_type) {
1163                  case split_type_normal:                  case split_type_normal:
# Line 1161  namespace gig { Line 1166  namespace gig {
1166                  case split_type_customvelocity:                  case split_type_customvelocity:
1167                      bits[i] = VelocityTable[bits[i]];                      bits[i] = VelocityTable[bits[i]];
1168                      break;                      break;
1169                  // else the value is already the sought dimension bit number                  case split_type_bit: // the value is already the sought dimension bit number
1170                        const uint8_t limiter_mask = (0xff << pDimensionDefinitions[i].bits) ^ 0xff;
1171                        bits[i] = bits[i] & limiter_mask; // just make sure the value don't uses more bits than allowed
1172                        break;
1173              }              }
1174          }          }
1175          return GetDimensionRegionByBit(bits[4],bits[3],bits[2],bits[1],bits[0]);          return GetDimensionRegionByBit(bits[4],bits[3],bits[2],bits[1],bits[0]);

Legend:
Removed from v.36  
changed lines
  Added in v.282

  ViewVC Help
Powered by ViewVC