Browse Source

Fix timing issues, please test

tags/v1.9.9
falkTX 6 years ago
parent
commit
c29529b456
5 changed files with 55 additions and 34 deletions
  1. +4
    -2
      source/backend/engine/CarlaEngine.cpp
  2. +2
    -0
      source/backend/engine/CarlaEngineData.cpp
  3. +43
    -29
      source/backend/engine/CarlaEngineInternal.cpp
  4. +1
    -0
      source/backend/engine/CarlaEngineInternal.hpp
  5. +5
    -3
      source/backend/plugin/CarlaPluginLV2.cpp

+ 4
- 2
source/backend/engine/CarlaEngine.cpp View File

@@ -1308,8 +1308,10 @@ void CarlaEngine::transportPlay() noexcept

void CarlaEngine::transportPause() noexcept
{
pData->timeInfo.playing = false;
pData->time.setNeedsReset();
if (pData->timeInfo.playing)
pData->time.pause();
else
pData->time.setNeedsReset();
}

void CarlaEngine::transportBPM(const double bpm) noexcept


+ 2
- 0
source/backend/engine/CarlaEngineData.cpp View File

@@ -334,6 +334,8 @@ bool EngineTimeInfo::operator==(const EngineTimeInfo& timeInfo) const noexcept
return false;
if (! bbt.valid)
return true;
if (carla_isNotEqual(timeInfo.bbt.beatsPerBar, bbt.beatsPerBar))
return false;
if (carla_isNotEqual(timeInfo.bbt.beatsPerMinute, bbt.beatsPerMinute))
return false;
return true;


+ 43
- 29
source/backend/engine/CarlaEngineInternal.cpp View File

@@ -155,6 +155,13 @@ void EngineInternalTime::setNeedsReset() noexcept
needsReset = true;
}

void EngineInternalTime::pause() noexcept
{
timeInfo.playing = false;
nextFrame = timeInfo.frame;
needsReset = true;
}

void EngineInternalTime::relocate(const uint64_t frame) noexcept
{
timeInfo.frame = frame;
@@ -187,9 +194,8 @@ void EngineInternalTime::fillEngineTimeInfo(const uint32_t newFrames) noexcept
{
if (hylia.timeInfo.beat >= 0.0)
{
const double beat = hylia.timeInfo.beat;
abs_beat = std::floor(beat);
abs_tick = beat * kTicksPerBeat;
abs_beat = hylia.timeInfo.beat;
abs_tick = abs_beat * kTicksPerBeat;
}
else
{
@@ -202,20 +208,21 @@ void EngineInternalTime::fillEngineTimeInfo(const uint32_t newFrames) noexcept
#endif
{
const double min = static_cast<double>(timeInfo.frame) / (sampleRate * 60.0);
abs_tick = min * beatsPerMinute * kTicksPerBeat;
abs_beat = abs_tick / kTicksPerBeat;
abs_beat = min * beatsPerMinute;
abs_tick = abs_beat * kTicksPerBeat;
needsReset = false;
}

timeInfo.bbt.bar = (int32_t)(std::floor(abs_beat / beatsPerBar) + 0.5);
timeInfo.bbt.beat = (int32_t)(abs_beat - (timeInfo.bbt.bar * beatsPerBar) + 1.5);
timeInfo.bbt.barStartTick = timeInfo.bbt.bar * beatsPerBar * kTicksPerBeat;
++timeInfo.bbt.bar;
const double bar = std::floor(abs_beat / beatsPerBar);
const double beat = std::floor(std::fmod(abs_beat, beatsPerBar));

timeInfo.bbt.bar = static_cast<int32_t>(bar) + 1;
timeInfo.bbt.beat = static_cast<int32_t>(beat) + 1;
timeInfo.bbt.barStartTick = ((bar * beatsPerBar) + beat) * kTicksPerBeat;

//ticktmp = abs_tick - timeInfo.bbt.barStartTick;
ticktmp = abs_tick - (abs_beat * timeInfo.bbt.barStartTick);
ticktmp = abs_tick - timeInfo.bbt.barStartTick;
}
else
else if (timeInfo.playing)
{
ticktmp = tick + (newFrames * kTicksPerBeat * beatsPerMinute / (sampleRate * 60));

@@ -225,16 +232,20 @@ void EngineInternalTime::fillEngineTimeInfo(const uint32_t newFrames) noexcept

if (++timeInfo.bbt.beat > beatsPerBar)
{
++timeInfo.bbt.bar;
timeInfo.bbt.beat = 1;
timeInfo.bbt.barStartTick += beatsPerBar * kTicksPerBeat;
++timeInfo.bbt.bar;
}
}
}
else
{
ticktmp = tick;
}

timeInfo.bbt.beatsPerBar = static_cast<float>(beatsPerBar);
timeInfo.bbt.beatsPerMinute = beatsPerMinute;
timeInfo.bbt.tick = (int32_t)(ticktmp + 0.5);
timeInfo.bbt.tick = static_cast<int32_t>(ticktmp);
tick = ticktmp;

if (transportMode == ENGINE_TRANSPORT_MODE_INTERNAL && timeInfo.playing)
@@ -261,9 +272,8 @@ void EngineInternalTime::fillJackTimeInfo(jack_position_t* const pos, const uint
{
if (hylia.timeInfo.beat >= 0.0)
{
const double beat = hylia.timeInfo.beat;
abs_beat = std::floor(beat);
abs_tick = beat * kTicksPerBeat;
abs_beat = hylia.timeInfo.beat;
abs_tick = abs_beat * kTicksPerBeat;
}
else
{
@@ -276,20 +286,20 @@ void EngineInternalTime::fillJackTimeInfo(jack_position_t* const pos, const uint
#endif
{
const double min = static_cast<double>(pos->frame) / (sampleRate * 60.0);
abs_tick = min * beatsPerMinute * kTicksPerBeat;
abs_beat = abs_tick / kTicksPerBeat;
needsReset = false;
abs_beat = min * beatsPerMinute;
abs_tick = abs_beat * kTicksPerBeat;
}

pos->bar = (int32_t)(std::floor(abs_beat / beatsPerBar) + 0.5);
pos->beat = (int32_t)(abs_beat - (pos->bar * beatsPerBar) + 1.5);
pos->bar_start_tick = pos->bar * beatsPerBar * kTicksPerBeat;
++pos->bar;
const double bar = std::floor(abs_beat / beatsPerBar);
const double beat = std::floor(std::fmod(abs_beat, beatsPerBar));

pos->bar = static_cast<int32_t>(bar) + 1;
pos->beat = static_cast<int32_t>(beat) + 1;
pos->bar_start_tick = ((bar * beatsPerBar) + beat) * kTicksPerBeat;

//ticktmp = abs_tick - pos->bar_start_tick;
ticktmp = abs_tick - (abs_beat * pos->ticks_per_beat);
ticktmp = abs_tick - pos->bar_start_tick;
}
else
else if (timeInfo.playing)
{
ticktmp = tick + (newFrames * kTicksPerBeat * beatsPerMinute / (sampleRate * 60.0));

@@ -299,16 +309,20 @@ void EngineInternalTime::fillJackTimeInfo(jack_position_t* const pos, const uint

if (++pos->beat > beatsPerBar)
{
++pos->bar;
pos->beat = 1;
pos->bar_start_tick += beatsPerBar * kTicksPerBeat;
++pos->bar;
}
}
}
else
{
ticktmp = tick;
}

pos->beats_per_bar = static_cast<float>(beatsPerBar);
pos->beats_per_minute = beatsPerMinute;
pos->tick = (int32_t)(ticktmp + 0.5);
pos->tick = static_cast<int32_t>(ticktmp);
tick = ticktmp;
}



+ 1
- 0
source/backend/engine/CarlaEngineInternal.hpp View File

@@ -124,6 +124,7 @@ public:
void enableLink(const bool enable);
void setBPM(const double bpm);
void setNeedsReset() noexcept;
void pause() noexcept;
void relocate(const uint64_t frame) noexcept;

private:


+ 5
- 3
source/backend/plugin/CarlaPluginLV2.cpp View File

@@ -2846,6 +2846,9 @@ public:
bool doPostRt;
int32_t rindex;

const double barBeat = static_cast<double>(timeInfo.bbt.beat - 1)
+ (static_cast<double>(timeInfo.bbt.tick) / timeInfo.bbt.ticksPerBeat);

// update input ports
for (uint32_t k=0; k < pData->param.count; ++k)
{
@@ -2894,8 +2897,7 @@ public:
if (timeInfo.bbt.valid && (fLastTimeInfo.bbt.tick != timeInfo.bbt.tick ||
fLastTimeInfo.bbt.beat != timeInfo.bbt.beat))
{
fParamBuffers[k] = static_cast<float>(static_cast<double>(timeInfo.bbt.beat) - 1.0
+ (static_cast<double>(timeInfo.bbt.tick) / timeInfo.bbt.ticksPerBeat));
fParamBuffers[k] = static_cast<float>(barBeat);
doPostRt = true;
}
break;
@@ -2967,7 +2969,7 @@ public:
lv2_atom_forge_long(&fAtomForge, timeInfo.bbt.bar - 1);

lv2_atom_forge_key(&fAtomForge, kUridTimeBarBeat);
lv2_atom_forge_float(&fAtomForge, static_cast<float>(static_cast<double>(timeInfo.bbt.beat) - 1.0 + (static_cast<double>(timeInfo.bbt.tick) / timeInfo.bbt.ticksPerBeat)));
lv2_atom_forge_float(&fAtomForge, static_cast<float>(barBeat));

lv2_atom_forge_key(&fAtomForge, kUridTimeBeat);
lv2_atom_forge_double(&fAtomForge, timeInfo.bbt.beat - 1);


Loading…
Cancel
Save