668 |
} |
} |
669 |
} |
} |
670 |
|
|
671 |
// get the velocity range for current KORG region |
// only create a velocity dimension if there was really |
672 |
{ |
// more than one velocity split zone defined |
673 |
int from, to; |
if (origVelocitySplits.size() <= 1) { |
674 |
if (parseNumberRange(kmpInstr->Name(), from, to) == kmpInstr->Name()) |
cerr << "WARNING: Velocity split mentioned, but with only one zone, thus ignoring velocity split.\n"; |
675 |
throw Korg::Exception("Internal error: parsing velocity range failed"); |
} else { |
676 |
velRange.low = from; |
// get the velocity range for current KORG region |
677 |
velRange.high = to; |
{ |
678 |
if (velocityCorrectionMap.find(velRange) == velocityCorrectionMap.end()) |
int from, to; |
679 |
throw Korg::Exception("Internal error: inconsistency in velocity split correction map"); |
if (parseNumberRange(kmpInstr->Name(), from, to) == kmpInstr->Name()) |
680 |
velRange = velocityCorrectionMap[velRange]; // corrected |
throw Korg::Exception("Internal error: parsing velocity range failed"); |
681 |
} |
velRange.low = from; |
682 |
|
velRange.high = to; |
683 |
// create velocity split dimension if it doesn't exist already ... |
if (velocityCorrectionMap.find(velRange) == velocityCorrectionMap.end()) |
684 |
iVelocityDimensionIndex = getDimensionIndex(gigRegion, gig::dimension_velocity); |
throw Korg::Exception("Internal error: inconsistency in velocity split correction map"); |
685 |
if (iVelocityDimensionIndex < 0) { |
velRange = velocityCorrectionMap[velRange]; // corrected |
686 |
gig::dimension_def_t dim; |
} |
|
dim.dimension = gig::dimension_velocity; |
|
|
dim.zones = origVelocitySplits.size(); |
|
|
// Find the number of bits required to hold the |
|
|
// specified amount of zones. |
|
|
int zoneBits = dim.zones - 1; |
|
|
for (dim.bits = 0; zoneBits > 1; dim.bits += 2, zoneBits >>= 2); |
|
|
dim.bits += zoneBits; |
|
|
cout << "Adding velocity dimension: zones=" << (int)dim.zones << ", bits=" << (int)dim.bits << endl; |
|
|
gigRegion->AddDimension(&dim); |
|
687 |
|
|
688 |
|
// create velocity split dimension if it doesn't exist already ... |
689 |
iVelocityDimensionIndex = getDimensionIndex(gigRegion, gig::dimension_velocity); |
iVelocityDimensionIndex = getDimensionIndex(gigRegion, gig::dimension_velocity); |
690 |
} |
if (iVelocityDimensionIndex < 0) { |
691 |
|
gig::dimension_def_t dim; |
692 |
|
dim.dimension = gig::dimension_velocity; |
693 |
|
dim.zones = origVelocitySplits.size(); |
694 |
|
// Find the number of bits required to hold the |
695 |
|
// specified amount of zones. |
696 |
|
int zoneBits = dim.zones - 1; |
697 |
|
for (dim.bits = 0; zoneBits > 1; dim.bits += 2, zoneBits >>= 2); |
698 |
|
dim.bits += zoneBits; |
699 |
|
cout << "Adding velocity dimension: zones=" << (int)dim.zones << ", bits=" << (int)dim.bits << endl; |
700 |
|
gigRegion->AddDimension(&dim); |
701 |
|
|
702 |
if (iVelocityDimensionIndex < 0) |
iVelocityDimensionIndex = getDimensionIndex(gigRegion, gig::dimension_velocity); |
703 |
throw gig::Exception("Internal error: Could not resolve target velocity dimension bit"); |
} |
704 |
|
|
705 |
|
if (iVelocityDimensionIndex < 0) |
706 |
|
throw gig::Exception("Internal error: Could not resolve target velocity dimension bit"); |
707 |
|
|
708 |
// find the velocity zone for this one |
// find the velocity zone for this one |
709 |
int iVelocitySplitZone = -1; |
int iVelocitySplitZone = -1; |
|
{ |
|
|
int i = 0; |
|
|
for (map<DLS::range_t,DLS::range_t>::const_iterator itVelSplit = velocityCorrectionMap.begin(); |
|
|
itVelSplit != velocityCorrectionMap.end(); ++itVelSplit, ++i) |
|
710 |
{ |
{ |
711 |
if (itVelSplit->second == velRange) { // already corrected before, thus second, not first |
int i = 0; |
712 |
iVelocitySplitZone = i; |
for (map<DLS::range_t,DLS::range_t>::const_iterator itVelSplit = velocityCorrectionMap.begin(); |
713 |
break; |
itVelSplit != velocityCorrectionMap.end(); ++itVelSplit, ++i) |
714 |
|
{ |
715 |
|
if (itVelSplit->second == velRange) { // already corrected before, thus second, not first |
716 |
|
iVelocitySplitZone = i; |
717 |
|
break; |
718 |
|
} |
719 |
} |
} |
720 |
|
if (iVelocitySplitZone == -1) |
721 |
|
throw gig::Exception("Internal error: Could not resolve target velocity dimension zone"); |
722 |
} |
} |
|
if (iVelocitySplitZone == -1) |
|
|
throw gig::Exception("Internal error: Could not resolve target velocity dimension zone"); |
|
|
} |
|
723 |
|
|
724 |
// select dimension bit for this stereo dimension split |
// select dimension bit for this stereo dimension split |
725 |
iDimBits[iVelocityDimensionIndex] = iVelocitySplitZone; |
iDimBits[iVelocityDimensionIndex] = iVelocitySplitZone; |
726 |
|
} |
727 |
} |
} |
728 |
|
|
729 |
// resolve target gig::DimensionRegion for the left/right and velocity split zone detected above |
// resolve target gig::DimensionRegion for the left/right and velocity split zone detected above |