Browse Source

carla-vst: rework vst time info sync, same as DPF (needs testing)

Signed-off-by: falkTX <falktx@falktx.com>
tags/v2.1-alpha2
falkTX 5 years ago
parent
commit
e6889de2c8
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
1 changed files with 13 additions and 5 deletions
  1. +13
    -5
      source/plugin/carla-vst.cpp

+ 13
- 5
source/plugin/carla-vst.cpp View File

@@ -457,15 +457,23 @@ public:

if (vstTimeInfo->flags & (kVstPpqPosValid|kVstTimeSigValid))
{
const int ppqPerBar = vstTimeInfo->timeSigNumerator * 4 / vstTimeInfo->timeSigDenominator;
const double barBeats = (std::fmod(vstTimeInfo->ppqPos, ppqPerBar) / ppqPerBar) * vstTimeInfo->timeSigDenominator;
const double ppqPos = std::abs(vstTimeInfo->ppqPos);
const double ppqPerBar = static_cast<double>(vstTimeInfo->timeSigNumerator * 4) / vstTimeInfo->timeSigDenominator;
const double barBeats = (std::fmod(ppqPos, ppqPerBar) / ppqPerBar) * vstTimeInfo->timeSigNumerator;
const double rest = std::fmod(barBeats, 1.0);

fTimeInfo.bbt.bar = static_cast<int32_t>(vstTimeInfo->ppqPos)/ppqPerBar + 1;
fTimeInfo.bbt.beat = static_cast<int32_t>(barBeats-rest+1.0);
fTimeInfo.bbt.tick = static_cast<int32_t>(rest*fTimeInfo.bbt.ticksPerBeat+0.5);
fTimeInfo.bbt.bar = static_cast<int32_t>(ppqPos / ppqPerBar + 0.5) + 1;
fTimeInfo.bbt.beat = static_cast<int32_t>(barBeats + 0.5) + 1;
fTimeInfo.bbt.tick = static_cast<int32_t>(rest * fTimeInfo.bbt.ticksPerBeat + 0.5);
fTimeInfo.bbt.beatsPerBar = static_cast<float>(vstTimeInfo->timeSigNumerator);
fTimeInfo.bbt.beatType = static_cast<float>(vstTimeInfo->timeSigDenominator);

if (vstTimeInfo->ppqPos < 0.0)
{
--fTimeInfo.bbt.bar;
fTimeInfo.bbt.beat = vstTimeInfo->timeSigNumerator - fTimeInfo.bbt.beat + 1;
fTimeInfo.bbt.tick = fTimeInfo.bbt.ticksPerBeat - fTimeInfo.bbt.tick - 1;
}
}
else
{


Loading…
Cancel
Save