ref: d1d0328232fe2d358d2e5fce19faa7d5cce10bf8
parent: f4fb11ccb42d5fd6ae7b73b8ed18f53fcad3be26
author: Olav Sørensen <olav.sorensen@live.no>
date: Fri Jul 24 16:18:08 EDT 2020
Fixed a small stuttering issue in the audio/video syncing
--- a/src/pt2_audio.c
+++ b/src/pt2_audio.c
@@ -1275,12 +1275,22 @@
calcAudioLatencyVars(audio.audioBufferSize, audio.outputRate);
- audio.tickTimeLengthTab[0] = UINT64_MAX;
- const double dMul = (editor.dPerfFreq / audio.outputRate) * (UINT32_MAX + 1.0);
- for (int32_t i = 1; i < 256-32; i++)
+ for (int32_t i = 32; i <= 255; i++)
{
+ const double dBpmHz = i / 2.5;
+
// number of samples per tick -> tick length for performance counter (syncing visuals to audio)
- audio.tickTimeLengthTab[i] = (uint64_t)(audio.bpmTab[i] * dMul);
+ double dTimeInt;
+ double dTimeFrac = modf(editor.dPerfFreq / dBpmHz, &dTimeInt);
+ const int32_t timeInt = (int32_t)dTimeInt;
+
+ // fractional part (scaled to 0..2^32-1)
+ dTimeFrac *= UINT32_MAX;
+ dTimeFrac += 0.5;
+ if (dTimeFrac > UINT32_MAX)
+ dTimeFrac = UINT32_MAX;
+
+ audio.tickTimeLengthTab[i-32] = ((uint64_t)timeInt << 32) | (uint32_t)dTimeFrac;
}
audio.resetSyncTickTimeFlag = true;
--- a/src/pt2_header.h
+++ b/src/pt2_header.h
@@ -14,7 +14,7 @@
#include "pt2_unicode.h"
#include "pt2_palette.h"
-#define PROG_VER_STR "1.21"
+#define PROG_VER_STR "1.22"
#ifdef _WIN32
#define DIR_DELIMITER '\\'