Logging and bug in the gain computations
This commit is contained in:
parent
29488f5d40
commit
4cd9665b48
2 changed files with 8 additions and 3 deletions
|
|
@ -627,7 +627,7 @@ float sfz::Region::getBaseVolumedB() noexcept
|
||||||
|
|
||||||
float sfz::Region::getBaseGain() noexcept
|
float sfz::Region::getBaseGain() noexcept
|
||||||
{
|
{
|
||||||
return amplitude;
|
return normalizePercents(amplitude);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t sfz::Region::getOffset() noexcept
|
uint32_t sfz::Region::getOffset() noexcept
|
||||||
|
|
@ -695,7 +695,7 @@ float crossfadeOut(const Range<T>& crossfadeRange, U value, SfzCrossfadeCurve cu
|
||||||
|
|
||||||
float sfz::Region::getNoteGain(int noteNumber, uint8_t velocity) noexcept
|
float sfz::Region::getNoteGain(int noteNumber, uint8_t velocity) noexcept
|
||||||
{
|
{
|
||||||
float baseGain { 1.0 };
|
float baseGain { 1.0f };
|
||||||
|
|
||||||
// Amplitude key tracking
|
// Amplitude key tracking
|
||||||
baseGain *= db2mag(ampKeytrack * static_cast<float>(noteNumber - ampKeycenter));
|
baseGain *= db2mag(ampKeytrack * static_cast<float>(noteNumber - ampKeycenter));
|
||||||
|
|
@ -739,7 +739,7 @@ float sfz::Region::getCrossfadeGain(const sfz::CCValueArray& ccState) noexcept
|
||||||
|
|
||||||
float sfz::Region::velocityCurve(uint8_t velocity) const noexcept
|
float sfz::Region::velocityCurve(uint8_t velocity) const noexcept
|
||||||
{
|
{
|
||||||
float gain { 1.0 };
|
float gain { 1.0f };
|
||||||
|
|
||||||
if (velocityPoints.size() > 0) { // Custom velocity curve
|
if (velocityPoints.size() > 0) { // Custom velocity curve
|
||||||
auto after = std::find_if(velocityPoints.begin(), velocityPoints.end(), [velocity](auto& val) { return val.first >= velocity; });
|
auto after = std::find_if(velocityPoints.begin(), velocityPoints.end(), [velocity](auto& val) { return val.first >= velocity; });
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@ void sfz::Voice::startVoice(Region* region, int delay, int channel, int number,
|
||||||
if (region->volumeCC)
|
if (region->volumeCC)
|
||||||
volumedB += normalizeCC(ccState[region->volumeCC->first]) * region->volumeCC->second;
|
volumedB += normalizeCC(ccState[region->volumeCC->first]) * region->volumeCC->second;
|
||||||
volumeEnvelope.reset(db2mag(volumedB));
|
volumeEnvelope.reset(db2mag(volumedB));
|
||||||
|
DBG("Base volume: " << baseVolumedB << " dB - with modifier: " << volumedB << " dB");
|
||||||
|
|
||||||
baseGain = region->getBaseGain();
|
baseGain = region->getBaseGain();
|
||||||
baseGain *= region->getCrossfadeGain(ccState);
|
baseGain *= region->getCrossfadeGain(ccState);
|
||||||
|
|
@ -68,24 +69,28 @@ void sfz::Voice::startVoice(Region* region, int delay, int channel, int number,
|
||||||
if (region->amplitudeCC)
|
if (region->amplitudeCC)
|
||||||
gain *= normalizeCC(ccState[region->amplitudeCC->first]) * normalizePercents(region->amplitudeCC->second);
|
gain *= normalizeCC(ccState[region->amplitudeCC->first]) * normalizePercents(region->amplitudeCC->second);
|
||||||
amplitudeEnvelope.reset(gain);
|
amplitudeEnvelope.reset(gain);
|
||||||
|
DBG("Base gain: " << baseGain << " - with modifier: " << gain);
|
||||||
|
|
||||||
basePan = normalizeNegativePercents(region->pan);
|
basePan = normalizeNegativePercents(region->pan);
|
||||||
auto pan = basePan;
|
auto pan = basePan;
|
||||||
if (region->panCC)
|
if (region->panCC)
|
||||||
pan += normalizeCC(ccState[region->panCC->first]) * normalizeNegativePercents(region->panCC->second);
|
pan += normalizeCC(ccState[region->panCC->first]) * normalizeNegativePercents(region->panCC->second);
|
||||||
panEnvelope.reset(pan);
|
panEnvelope.reset(pan);
|
||||||
|
DBG("Base pan: " << basePan << " - with modifier: " << pan);
|
||||||
|
|
||||||
basePosition = normalizeNegativePercents(region->position);
|
basePosition = normalizeNegativePercents(region->position);
|
||||||
auto position = basePosition;
|
auto position = basePosition;
|
||||||
if (region->positionCC)
|
if (region->positionCC)
|
||||||
position += normalizeCC(ccState[region->positionCC->first]) * normalizeNegativePercents(region->positionCC->second);
|
position += normalizeCC(ccState[region->positionCC->first]) * normalizeNegativePercents(region->positionCC->second);
|
||||||
positionEnvelope.reset(position);
|
positionEnvelope.reset(position);
|
||||||
|
DBG("Base position: " << basePosition << " - with modifier: " << position);
|
||||||
|
|
||||||
baseWidth = normalizeNegativePercents(region->width);
|
baseWidth = normalizeNegativePercents(region->width);
|
||||||
auto width = baseWidth;
|
auto width = baseWidth;
|
||||||
if (region->widthCC)
|
if (region->widthCC)
|
||||||
width += normalizeCC(ccState[region->widthCC->first]) * normalizeNegativePercents(region->widthCC->second);
|
width += normalizeCC(ccState[region->widthCC->first]) * normalizeNegativePercents(region->widthCC->second);
|
||||||
widthEnvelope.reset(width);
|
widthEnvelope.reset(width);
|
||||||
|
DBG("Base width: " << baseWidth << " - with modifier: " << width);
|
||||||
|
|
||||||
sourcePosition = region->getOffset();
|
sourcePosition = region->getOffset();
|
||||||
floatPosition = static_cast<float>(sourcePosition);
|
floatPosition = static_cast<float>(sourcePosition);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue