Browse Source

Tweaks to transport code, still not quite there yet...

tags/1.9.8
falkTX 7 years ago
parent
commit
e3c4017168
2 changed files with 25 additions and 17 deletions
  1. +1
    -1
      resources/ui/carla_host.ui
  2. +24
    -16
      source/backend/engine/CarlaEngineInternal.cpp

+ 1
- 1
resources/ui/carla_host.ui View File

@@ -611,7 +611,7 @@
</font> </font>
</property> </property>
<property name="text"> <property name="text">
<string>000|00|000</string>
<string>000|00|0000</string>
</property> </property>
</widget> </widget>
</item> </item>


+ 24
- 16
source/backend/engine/CarlaEngineInternal.cpp View File

@@ -153,6 +153,8 @@ void EngineInternalTime::fillEngineTimeInfo(const uint32_t newFrames) noexcept
CARLA_SAFE_ASSERT_RETURN(carla_isNotZero(sampleRate),); CARLA_SAFE_ASSERT_RETURN(carla_isNotZero(sampleRate),);
CARLA_SAFE_ASSERT_RETURN(newFrames > 0,); CARLA_SAFE_ASSERT_RETURN(newFrames > 0,);


double ticktmp;

timeInfo.usecs = 0; timeInfo.usecs = 0;


if (transportMode == ENGINE_TRANSPORT_MODE_INTERNAL) if (transportMode == ENGINE_TRANSPORT_MODE_INTERNAL)
@@ -194,30 +196,32 @@ void EngineInternalTime::fillEngineTimeInfo(const uint32_t newFrames) noexcept
} }


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


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


while (tick >= kTicksPerBeat)
while (ticktmp >= kTicksPerBeat)
{ {
tick -= kTicksPerBeat;
ticktmp -= kTicksPerBeat;


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


timeInfo.bbt.tick = (int32_t)(tick + 0.5);
timeInfo.bbt.tick = (int32_t)(ticktmp + 0.5);
tick = ticktmp;


if (transportMode == ENGINE_TRANSPORT_MODE_INTERNAL && timeInfo.playing) if (transportMode == ENGINE_TRANSPORT_MODE_INTERNAL && timeInfo.playing)
nextFrame += newFrames; nextFrame += newFrames;
@@ -228,6 +232,8 @@ void EngineInternalTime::fillJackTimeInfo(jack_position_t* const pos, const uint
CARLA_SAFE_ASSERT_RETURN(carla_isNotZero(sampleRate),); CARLA_SAFE_ASSERT_RETURN(carla_isNotZero(sampleRate),);
CARLA_SAFE_ASSERT_RETURN(newFrames > 0,); CARLA_SAFE_ASSERT_RETURN(newFrames > 0,);


double ticktmp;

if (needsReset) if (needsReset)
{ {
pos->valid = JackPositionBBT; pos->valid = JackPositionBBT;
@@ -264,30 +270,32 @@ void EngineInternalTime::fillJackTimeInfo(jack_position_t* const pos, const uint
} }


pos->bar = (int32_t)(std::floor(abs_beat / pos->beats_per_bar) + 0.5); pos->bar = (int32_t)(std::floor(abs_beat / pos->beats_per_bar) + 0.5);
pos->beat = abs_beat - (pos->bar * pos->beats_per_bar) + 1;
pos->beat = (int32_t)(abs_beat - (pos->bar * pos->beats_per_bar) + 1.5);
pos->bar_start_tick = pos->bar * pos->beats_per_bar * kTicksPerBeat; pos->bar_start_tick = pos->bar * pos->beats_per_bar * kTicksPerBeat;
pos->bar++;
++pos->bar;


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


while (tick >= kTicksPerBeat)
while (ticktmp >= kTicksPerBeat)
{ {
tick -= kTicksPerBeat;
ticktmp -= kTicksPerBeat;


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


pos->tick = (int32_t)(tick + 0.5);
pos->tick = (int32_t)(ticktmp + 0.5);
tick = ticktmp;
} }


void EngineInternalTime::preProcess(const uint32_t numFrames) void EngineInternalTime::preProcess(const uint32_t numFrames)


Loading…
Cancel
Save