51 |
|
|
52 |
namespace gig { |
namespace gig { |
53 |
|
|
|
// *************** dimension_def_t *************** |
|
|
// * |
|
|
|
|
|
dimension_def_t& dimension_def_t::operator=(const dimension_def_t& arg) { |
|
|
dimension = arg.dimension; |
|
|
bits = arg.bits; |
|
|
zones = arg.zones; |
|
|
split_type = arg.split_type; |
|
|
ranges = arg.ranges; |
|
|
zone_size = arg.zone_size; |
|
|
if (ranges) { |
|
|
ranges = new range_t[zones]; |
|
|
for (int i = 0; i < zones; i++) |
|
|
ranges[i] = arg.ranges[i]; |
|
|
} |
|
|
return *this; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
54 |
// *************** progress_t *************** |
// *************** progress_t *************** |
55 |
// * |
// * |
56 |
|
|
1429 |
VCFCutoffController <= vcf_cutoff_ctrl_none2 ? VCFVelocityScale : 0); |
VCFCutoffController <= vcf_cutoff_ctrl_none2 ? VCFVelocityScale : 0); |
1430 |
|
|
1431 |
SampleAttenuation = pow(10.0, -Gain / (20.0 * 655360)); |
SampleAttenuation = pow(10.0, -Gain / (20.0 * 655360)); |
1432 |
|
VelocityTable = 0; |
1433 |
} |
} |
1434 |
|
|
1435 |
/** |
/** |
1949 |
delete pVelocityTables; |
delete pVelocityTables; |
1950 |
pVelocityTables = NULL; |
pVelocityTables = NULL; |
1951 |
} |
} |
1952 |
|
if (VelocityTable) delete[] VelocityTable; |
1953 |
} |
} |
1954 |
|
|
1955 |
/** |
/** |
2074 |
pDimensionDefinitions[i].bits = 0; |
pDimensionDefinitions[i].bits = 0; |
2075 |
pDimensionDefinitions[i].zones = 0; |
pDimensionDefinitions[i].zones = 0; |
2076 |
pDimensionDefinitions[i].split_type = split_type_bit; |
pDimensionDefinitions[i].split_type = split_type_bit; |
|
pDimensionDefinitions[i].ranges = NULL; |
|
2077 |
pDimensionDefinitions[i].zone_size = 0; |
pDimensionDefinitions[i].zone_size = 0; |
2078 |
} |
} |
2079 |
else { // active dimension |
else { // active dimension |
2086 |
dimension == dimension_roundrobin || |
dimension == dimension_roundrobin || |
2087 |
dimension == dimension_random) ? split_type_bit |
dimension == dimension_random) ? split_type_bit |
2088 |
: split_type_normal; |
: split_type_normal; |
|
pDimensionDefinitions[i].ranges = NULL; // it's not possible to check velocity dimensions for custom defined ranges at this point |
|
2089 |
pDimensionDefinitions[i].zone_size = |
pDimensionDefinitions[i].zone_size = |
2090 |
(pDimensionDefinitions[i].split_type == split_type_normal) ? 128.0 / pDimensionDefinitions[i].zones |
(pDimensionDefinitions[i].split_type == split_type_normal) ? 128.0 / pDimensionDefinitions[i].zones |
2091 |
: 0; |
: 0; |
2098 |
} |
} |
2099 |
for (int i = dimensionBits ; i < 8 ; i++) pDimensionDefinitions[i].bits = 0; |
for (int i = dimensionBits ; i < 8 ; i++) pDimensionDefinitions[i].bits = 0; |
2100 |
|
|
2101 |
// check velocity dimension (if there is one) for custom defined zone ranges |
// if there's a velocity dimension and custom velocity zone splits are used, |
2102 |
for (uint i = 0; i < Dimensions; i++) { |
// update the VelocityTables in the dimension regions |
2103 |
dimension_def_t* pDimDef = pDimensionDefinitions + i; |
UpdateVelocityTable(); |
|
if (pDimDef->dimension == dimension_velocity) { |
|
|
if (pDimensionRegions[0]->VelocityUpperLimit == 0) { |
|
|
// no custom defined ranges |
|
|
pDimDef->split_type = split_type_normal; |
|
|
pDimDef->ranges = NULL; |
|
|
} |
|
|
else { // custom defined ranges |
|
|
pDimDef->split_type = split_type_customvelocity; |
|
|
pDimDef->ranges = new range_t[pDimDef->zones]; |
|
|
UpdateVelocityTable(pDimDef); |
|
|
} |
|
|
} |
|
|
} |
|
2104 |
|
|
2105 |
// jump to start of the wave pool indices (if not already there) |
// jump to start of the wave pool indices (if not already there) |
|
File* file = (File*) GetParent()->GetParent(); |
|
2106 |
if (file->pVersion && file->pVersion->major == 3) |
if (file->pVersion && file->pVersion->major == 3) |
2107 |
_3lnk->SetPos(68); // version 3 has a different 3lnk structure |
_3lnk->SetPos(68); // version 3 has a different 3lnk structure |
2108 |
else |
else |
2200 |
} |
} |
2201 |
} |
} |
2202 |
|
|
2203 |
void Region::UpdateVelocityTable(dimension_def_t* pDimDef) { |
void Region::UpdateVelocityTable() { |
2204 |
// get dimension's index |
// get velocity dimension's index |
2205 |
int iDimensionNr = -1; |
int veldim = -1; |
2206 |
for (int i = 0; i < Dimensions; i++) { |
for (int i = 0 ; i < Dimensions ; i++) { |
2207 |
if (&pDimensionDefinitions[i] == pDimDef) { |
if (pDimensionDefinitions[i].dimension == gig::dimension_velocity) { |
2208 |
iDimensionNr = i; |
veldim = i; |
2209 |
break; |
break; |
2210 |
} |
} |
2211 |
} |
} |
2212 |
if (iDimensionNr < 0) throw gig::Exception("Invalid dimension_def_t pointer"); |
if (veldim == -1) return; |
2213 |
|
|
2214 |
|
int step = 1; |
2215 |
|
for (int i = 0 ; i < veldim ; i++) step <<= pDimensionDefinitions[i].bits; |
2216 |
|
int skipveldim = (step << pDimensionDefinitions[veldim].bits) - step; |
2217 |
|
int end = step * pDimensionDefinitions[veldim].zones; |
2218 |
|
|
2219 |
|
// loop through all dimension regions for all dimensions except the velocity dimension |
2220 |
|
int dim[8] = { 0 }; |
2221 |
|
for (int i = 0 ; i < DimensionRegions ; i++) { |
2222 |
|
|
2223 |
|
if (pDimensionRegions[i]->VelocityUpperLimit) { |
2224 |
|
// create the velocity table |
2225 |
|
uint8_t* table = pDimensionRegions[i]->VelocityTable; |
2226 |
|
if (!table) { |
2227 |
|
table = new uint8_t[128]; |
2228 |
|
pDimensionRegions[i]->VelocityTable = table; |
2229 |
|
} |
2230 |
|
int tableidx = 0; |
2231 |
|
int velocityZone = 0; |
2232 |
|
for (int k = i ; k < end ; k += step) { |
2233 |
|
DimensionRegion *d = pDimensionRegions[k]; |
2234 |
|
for (; tableidx <= d->VelocityUpperLimit ; tableidx++) table[tableidx] = velocityZone; |
2235 |
|
velocityZone++; |
2236 |
|
} |
2237 |
|
} else { |
2238 |
|
if (pDimensionRegions[i]->VelocityTable) { |
2239 |
|
delete[] pDimensionRegions[i]->VelocityTable; |
2240 |
|
pDimensionRegions[i]->VelocityTable = 0; |
2241 |
|
} |
2242 |
|
} |
2243 |
|
|
2244 |
uint8_t bits[8] = { 0 }; |
int j; |
2245 |
int previousUpperLimit = -1; |
int shift = 0; |
2246 |
for (int velocityZone = 0; velocityZone < pDimDef->zones; velocityZone++) { |
for (j = 0 ; j < Dimensions ; j++) { |
2247 |
bits[iDimensionNr] = velocityZone; |
if (j == veldim) i += skipveldim; // skip velocity dimension |
2248 |
DimensionRegion* pDimRegion = GetDimensionRegionByBit(bits); |
else { |
2249 |
|
dim[j]++; |
2250 |
pDimDef->ranges[velocityZone].low = previousUpperLimit + 1; |
if (dim[j] < pDimensionDefinitions[j].zones) break; |
2251 |
pDimDef->ranges[velocityZone].high = pDimRegion->VelocityUpperLimit; |
else { |
2252 |
previousUpperLimit = pDimDef->ranges[velocityZone].high; |
// skip unused dimension regions |
2253 |
// fill velocity table |
dim[j] = 0; |
2254 |
for (int i = pDimDef->ranges[velocityZone].low; i <= pDimDef->ranges[velocityZone].high; i++) { |
i += ((1 << pDimensionDefinitions[j].bits) - |
2255 |
VelocityTable[i] = velocityZone; |
pDimensionDefinitions[j].zones) << shift; |
2256 |
|
} |
2257 |
|
} |
2258 |
|
shift += pDimensionDefinitions[j].bits; |
2259 |
} |
} |
2260 |
|
if (j == Dimensions) break; |
2261 |
} |
} |
2262 |
} |
} |
2263 |
|
|
2312 |
// if this is a layer dimension, update 'Layers' attribute |
// if this is a layer dimension, update 'Layers' attribute |
2313 |
if (pDimDef->dimension == dimension_layer) Layers = pDimDef->zones; |
if (pDimDef->dimension == dimension_layer) Layers = pDimDef->zones; |
2314 |
|
|
2315 |
// if this is velocity dimension and got custom defined ranges, update velocity table |
UpdateVelocityTable(); |
|
if (pDimDef->dimension == dimension_velocity && |
|
|
pDimDef->split_type == split_type_customvelocity) { |
|
|
UpdateVelocityTable(pDimDef); |
|
|
} |
|
2316 |
} |
} |
2317 |
|
|
2318 |
/** @brief Delete an existing dimension. |
/** @brief Delete an existing dimension. |
2382 |
pDimensionDefinitions[Dimensions - 1].dimension = dimension_none; |
pDimensionDefinitions[Dimensions - 1].dimension = dimension_none; |
2383 |
pDimensionDefinitions[Dimensions - 1].bits = 0; |
pDimensionDefinitions[Dimensions - 1].bits = 0; |
2384 |
pDimensionDefinitions[Dimensions - 1].zones = 0; |
pDimensionDefinitions[Dimensions - 1].zones = 0; |
|
if (pDimensionDefinitions[Dimensions - 1].ranges) { |
|
|
delete[] pDimensionDefinitions[Dimensions - 1].ranges; |
|
|
pDimensionDefinitions[Dimensions - 1].ranges = NULL; |
|
|
} |
|
2385 |
|
|
2386 |
Dimensions--; |
Dimensions--; |
2387 |
|
|
2390 |
} |
} |
2391 |
|
|
2392 |
Region::~Region() { |
Region::~Region() { |
|
for (uint i = 0; i < Dimensions; i++) { |
|
|
if (pDimensionDefinitions[i].ranges) delete[] pDimensionDefinitions[i].ranges; |
|
|
} |
|
2393 |
for (int i = 0; i < 256; i++) { |
for (int i = 0; i < 256; i++) { |
2394 |
if (pDimensionRegions[i]) delete pDimensionRegions[i]; |
if (pDimensionRegions[i]) delete pDimensionRegions[i]; |
2395 |
} |
} |
2414 |
* @see Dimensions |
* @see Dimensions |
2415 |
*/ |
*/ |
2416 |
DimensionRegion* Region::GetDimensionRegionByValue(const uint DimValues[8]) { |
DimensionRegion* Region::GetDimensionRegionByValue(const uint DimValues[8]) { |
2417 |
uint8_t bits[8] = { 0 }; |
uint8_t bits; |
2418 |
|
int veldim = -1; |
2419 |
|
int velbitpos; |
2420 |
|
int bitpos = 0; |
2421 |
|
int dimregidx = 0; |
2422 |
for (uint i = 0; i < Dimensions; i++) { |
for (uint i = 0; i < Dimensions; i++) { |
2423 |
bits[i] = DimValues[i]; |
if (pDimensionDefinitions[i].dimension == dimension_velocity) { |
2424 |
switch (pDimensionDefinitions[i].split_type) { |
// the velocity dimension must be handled after the other dimensions |
2425 |
case split_type_normal: |
veldim = i; |
2426 |
bits[i] = uint8_t(bits[i] / pDimensionDefinitions[i].zone_size); |
velbitpos = bitpos; |
2427 |
break; |
} else { |
2428 |
case split_type_customvelocity: |
switch (pDimensionDefinitions[i].split_type) { |
2429 |
bits[i] = VelocityTable[bits[i]]; |
case split_type_normal: |
2430 |
break; |
bits = uint8_t(DimValues[i] / pDimensionDefinitions[i].zone_size); |
2431 |
case split_type_bit: // the value is already the sought dimension bit number |
break; |
2432 |
const uint8_t limiter_mask = (0xff << pDimensionDefinitions[i].bits) ^ 0xff; |
case split_type_bit: // the value is already the sought dimension bit number |
2433 |
bits[i] = bits[i] & limiter_mask; // just make sure the value don't uses more bits than allowed |
const uint8_t limiter_mask = (0xff << pDimensionDefinitions[i].bits) ^ 0xff; |
2434 |
break; |
bits = DimValues[i] & limiter_mask; // just make sure the value doesn't use more bits than allowed |
2435 |
|
break; |
2436 |
|
} |
2437 |
|
dimregidx |= bits << bitpos; |
2438 |
} |
} |
2439 |
|
bitpos += pDimensionDefinitions[i].bits; |
2440 |
|
} |
2441 |
|
DimensionRegion* dimreg = pDimensionRegions[dimregidx]; |
2442 |
|
if (veldim != -1) { |
2443 |
|
// (dimreg is now the dimension region for the lowest velocity) |
2444 |
|
if (dimreg->VelocityUpperLimit) // custom defined zone ranges |
2445 |
|
bits = dimreg->VelocityTable[DimValues[veldim]]; |
2446 |
|
else // normal split type |
2447 |
|
bits = uint8_t(DimValues[veldim] / pDimensionDefinitions[veldim].zone_size); |
2448 |
|
|
2449 |
|
dimregidx |= bits << velbitpos; |
2450 |
|
dimreg = pDimensionRegions[dimregidx]; |
2451 |
} |
} |
2452 |
return GetDimensionRegionByBit(bits); |
return dimreg; |
2453 |
} |
} |
2454 |
|
|
2455 |
/** |
/** |