/[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 2584 by schoenebeck, Sat May 31 20:54:39 2014 UTC revision 2599 by schoenebeck, Sat Jun 7 00:00:10 2014 UTC
# Line 3759  namespace { Line 3759  namespace {
3759          return dimreg;          return dimreg;
3760      }      }
3761    
3762        int Region::GetDimensionRegionIndexByValue(const uint DimValues[8]) {
3763            uint8_t bits;
3764            int veldim = -1;
3765            int velbitpos;
3766            int bitpos = 0;
3767            int dimregidx = 0;
3768            for (uint i = 0; i < Dimensions; i++) {
3769                if (pDimensionDefinitions[i].dimension == dimension_velocity) {
3770                    // the velocity dimension must be handled after the other dimensions
3771                    veldim = i;
3772                    velbitpos = bitpos;
3773                } else {
3774                    switch (pDimensionDefinitions[i].split_type) {
3775                        case split_type_normal:
3776                            if (pDimensionRegions[0]->DimensionUpperLimits[i]) {
3777                                // gig3: all normal dimensions (not just the velocity dimension) have custom zone ranges
3778                                for (bits = 0 ; bits < pDimensionDefinitions[i].zones ; bits++) {
3779                                    if (DimValues[i] <= pDimensionRegions[bits << bitpos]->DimensionUpperLimits[i]) break;
3780                                }
3781                            } else {
3782                                // gig2: evenly sized zones
3783                                bits = uint8_t(DimValues[i] / pDimensionDefinitions[i].zone_size);
3784                            }
3785                            break;
3786                        case split_type_bit: // the value is already the sought dimension bit number
3787                            const uint8_t limiter_mask = (0xff << pDimensionDefinitions[i].bits) ^ 0xff;
3788                            bits = DimValues[i] & limiter_mask; // just make sure the value doesn't use more bits than allowed
3789                            break;
3790                    }
3791                    dimregidx |= bits << bitpos;
3792                }
3793                bitpos += pDimensionDefinitions[i].bits;
3794            }
3795            dimregidx &= 255;
3796            DimensionRegion* dimreg = pDimensionRegions[dimregidx];
3797            if (!dimreg) return -1;
3798            if (veldim != -1) {
3799                // (dimreg is now the dimension region for the lowest velocity)
3800                if (dimreg->VelocityTable) // custom defined zone ranges
3801                    bits = dimreg->VelocityTable[DimValues[veldim] & 127];
3802                else // normal split type
3803                    bits = uint8_t((DimValues[veldim] & 127) / pDimensionDefinitions[veldim].zone_size);
3804    
3805                const uint8_t limiter_mask = (1 << pDimensionDefinitions[veldim].bits) - 1;
3806                dimregidx |= (bits & limiter_mask) << velbitpos;
3807                dimregidx &= 255;
3808            }
3809            return dimregidx;
3810        }
3811    
3812      /**      /**
3813       * Returns the appropriate DimensionRegion for the given dimension bit       * Returns the appropriate DimensionRegion for the given dimension bit
3814       * numbers (zone index). You usually use <i>GetDimensionRegionByValue</i>       * numbers (zone index). You usually use <i>GetDimensionRegionByValue</i>
# Line 4610  namespace { Line 4660  namespace {
4660          scriptPoolFileOffsets.clear();          scriptPoolFileOffsets.clear();
4661      }      }
4662    
4663      /** @brief Add new instrument script slot (gig format extension)      /** @brief Get instrument script (gig format extension).
4664         *
4665         * Returns the real-time instrument script of instrument script slot
4666         * @a index.
4667         *
4668         * @note This is an own format extension which did not exist i.e. in the
4669         * GigaStudio 4 software. It will currently only work with LinuxSampler and
4670         * gigedit.
4671         *
4672         * @param index - instrument script slot index
4673         * @returns script or NULL if index is out of bounds
4674         */
4675        Script* Instrument::GetScriptOfSlot(uint index) {
4676            LoadScripts();
4677            if (index >= pScriptRefs->size()) return NULL;
4678            return pScriptRefs->at(index).script;
4679        }
4680    
4681        /** @brief Add new instrument script slot (gig format extension).
4682       *       *
4683       * Add the given real-time instrument script reference to this instrument,       * Add the given real-time instrument script reference to this instrument,
4684       * which shall be executed by the sampler for for this instrument. The       * which shall be executed by the sampler for for this instrument. The

Legend:
Removed from v.2584  
changed lines
  Added in v.2599

  ViewVC Help
Powered by ViewVC