Skip to content

Commit

Permalink
dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ak5k committed Dec 23, 2021
1 parent fd1b3e5 commit b20def6
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 10 deletions.
17 changes: 13 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,19 @@ if(NOT EXISTS ${PROJECT_SOURCE_DIR}/vendor/reaper-sdk/WDL)
find_package(Git QUIET)
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
file(CREATE_LINK
${PROJECT_SOURCE_DIR}/vendor/WDL/WDL
${PROJECT_SOURCE_DIR}/vendor/reaper-sdk/WDL
SYMBOLIC)
if(NOT CMAKE_SYSTEM_NAME MATCHES Windows)
file(CREATE_LINK
${PROJECT_SOURCE_DIR}/vendor/WDL/WDL
${PROJECT_SOURCE_DIR}/vendor/reaper-sdk/WDL
SYMBOLIC)
else()
file(COPY
${PROJECT_SOURCE_DIR}/vendor/WDL/WDL
DESTINATION
${PROJECT_SOURCE_DIR}/vendor/reaper-sdk/
)
endif(NOT CMAKE_SYSTEM_NAME MATCHES Windows)

endif()

if (CMAKE_SYSTEM_NAME MATCHES Windows)
Expand Down
4 changes: 4 additions & 0 deletions scripts/ReaBlink_Monitor.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
header = "enabled | num peers | quantum | start stop sync | tempo | beats(QN) | metro\n"
gfx.init("ReaBlink Monitor", 640, 32)

if reaper.GetToggleCommandState(40531) ~= 0 then
reaper.Main_OnCommand(40531,0)
end

if not reaper.Blink_GetEnabled() then
reaper.Blink_SetEnabled(true)
end
Expand Down
8 changes: 6 additions & 2 deletions source/reablink/BlinkEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@ void BlinkEngine::AudioCallback(const std::chrono::microseconds& hostTime)
(host_start_time.count() - session_start_time.count()) / 1.0e6;
frameCountDown++;
timepos += startOffset;
std::thread(OnStopButton).detach();
std::thread([timepos]() {
OnStopButton();
SetEditCurPos(timepos, false, true);
}).detach();
}
Expand Down Expand Up @@ -437,7 +437,10 @@ void BlinkEngine::AudioCallback(const std::chrono::microseconds& hostTime)
!engineData.isMaster && sessionState.isPlaying() &&
playbackFrameCount > playbackFrameSafe && diff > syncTolerance &&
diff < qLen - ceil((frameTime.count() / 1.0e3) * 2)) {
syncCorrection = true;
if (syncCorrection == false) {
syncTolerance--;
syncCorrection = true;
}
if (hostBeat - sessionBeat > 0) {
// slow_down
std::thread([]() { Main_OnCommand(40525, 0); }).detach();
Expand All @@ -450,6 +453,7 @@ void BlinkEngine::AudioCallback(const std::chrono::microseconds& hostTime)
else if (syncCorrection) {
std::thread(Main_OnCommand, 40521, 0).detach();
syncCorrection = false;
syncTolerance++;
}
}

Expand Down
7 changes: 4 additions & 3 deletions source/reablink/BlinkEngine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
// Make sure to define this before <cmath> is included for Windows
#define _USE_MATH_DEFINES
#define ASIO_NO_EXCEPTIONS
// #define htonll(x) (((uint64_t)htonl((x)&0xFFFFFFFF) << 32) | htonl((x) >> 32))
// #define ntohll(x) (((uint64_t)ntohl((x)&0xFFFFFFFF) << 32) | ntohl((x) >> 32))
// #define htonll(x) (((uint64_t)htonl((x)&0xFFFFFFFF) << 32) | htonl((x) >>
// 32)) #define ntohll(x) (((uint64_t)ntohl((x)&0xFFFFFFFF) << 32) | ntohl((x)
// >> 32))
#endif

#include <ableton/Link.hpp>
Expand Down Expand Up @@ -128,7 +129,7 @@ class BlinkEngine {

static constexpr auto beatTolerance = 0.02;
static constexpr auto playbackFrameSafe = 16;
static constexpr auto syncTolerance = 3;
int syncTolerance = 3;
static constexpr auto tempoTolerance = 0.005;

std::mutex m;
Expand Down
18 changes: 17 additions & 1 deletion source/reablink/ReaBlink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,22 @@ bool runCommand(int command, int flag)
res = true;
startStop();
}
if (command == 40073) {
res = true;
startStop();
}
if (command == 1007) {
res = true;
startStop();
}
if (command == 1008) {
res = true;
startStop();
}
if (command == 1016) {
res = true;
blinkEngine.StopPlaying();
}
if (command == 41130) {
res = true;
const auto tempo = GetTempo();
Expand All @@ -458,7 +474,7 @@ void SetCaptureTransportCommands(bool enable)
}
const char* defstring_SetCaptureTransportCommands =
"void\0bool\0enable\0"
"Captures REAPER 'Transport: Play/stop' and 'Tempo: Increase/Decrease "
"Captures REAPER Transport commands and 'Tempo: Increase/Decrease "
"current project tempo by 01 BPM' commands and broadcasts them into Link "
"session. When used with Master or Puppet mode enabled, provides better "
"integration between REAPER and Link session transport and tempos.";
Expand Down

0 comments on commit b20def6

Please sign in to comment.