Because this workaround is causing MIDI events drops at low block size settings.pull/1934/head
@@ -61,6 +61,7 @@ extern float knobLinearSensitivity; | |||||
extern float knobScrollSensitivity; | extern float knobScrollSensitivity; | ||||
extern float sampleRate; | extern float sampleRate; | ||||
extern int threadCount; | extern int threadCount; | ||||
extern bool disableDawTimeWarpWorkaround; | |||||
extern bool tooltips; | extern bool tooltips; | ||||
extern bool cpuMeter; | extern bool cpuMeter; | ||||
extern bool lockModules; | extern bool lockModules; | ||||
@@ -548,6 +548,9 @@ struct EngineButton : MenuButton { | |||||
)); | )); | ||||
} | } | ||||
})); | })); | ||||
menu->addChild(createCheckMenuItem("Disable DAW time warp workaround", "", | |||||
[=]() { return settings::disableDawTimeWarpWorkaround; }, | |||||
[=]() { settings::disableDawTimeWarpWorkaround ^= true; })); | |||||
} | } | ||||
}; | }; | ||||
@@ -7,6 +7,7 @@ | |||||
#include <string.hpp> | #include <string.hpp> | ||||
#include <system.hpp> | #include <system.hpp> | ||||
#include <context.hpp> | #include <context.hpp> | ||||
#include <settings.hpp> | |||||
#include <engine/Engine.hpp> | #include <engine/Engine.hpp> | ||||
@@ -339,11 +340,13 @@ bool InputQueue::tryPop(Message* messageOut, int64_t maxFrame) { | |||||
return true; | return true; | ||||
} | } | ||||
// If next MIDI message is too far in the future, clear the queue. | |||||
// This solves the issue of unconsumed messages getting stuck in the future when a DAW rewinds the engine frame. | |||||
int futureFrames = 2 * APP->engine->getBlockFrames(); | |||||
if (msg.getFrame() - maxFrame > futureFrames) { | |||||
internal->queue.clear(); | |||||
if (!rack::settings::disableDawTimeWarpWorkaround) { | |||||
// If next MIDI message is too far in the future, clear the queue. | |||||
// This solves the issue of unconsumed messages getting stuck in the future when a DAW rewinds the engine frame. | |||||
int futureFrames = 2 * APP->engine->getBlockFrames(); | |||||
if (msg.getFrame() - maxFrame > futureFrames) { | |||||
internal->queue.clear(); | |||||
} | |||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
@@ -36,6 +36,7 @@ float knobLinearSensitivity = 0.001f; | |||||
float knobScrollSensitivity = 0.001f; | float knobScrollSensitivity = 0.001f; | ||||
float sampleRate = 0; | float sampleRate = 0; | ||||
int threadCount = 1; | int threadCount = 1; | ||||
bool disableDawTimeWarpWorkaround = false; | |||||
bool tooltips = true; | bool tooltips = true; | ||||
bool cpuMeter = false; | bool cpuMeter = false; | ||||
bool lockModules = false; | bool lockModules = false; | ||||
@@ -137,6 +138,8 @@ json_t* toJson() { | |||||
json_object_set_new(rootJ, "threadCount", json_integer(threadCount)); | json_object_set_new(rootJ, "threadCount", json_integer(threadCount)); | ||||
json_object_set_new(rootJ, "disableDawTimeWarpWorkaround", json_boolean(disableDawTimeWarpWorkaround)); | |||||
json_object_set_new(rootJ, "tooltips", json_boolean(tooltips)); | json_object_set_new(rootJ, "tooltips", json_boolean(tooltips)); | ||||
json_object_set_new(rootJ, "cpuMeter", json_boolean(cpuMeter)); | json_object_set_new(rootJ, "cpuMeter", json_boolean(cpuMeter)); | ||||
@@ -305,6 +308,10 @@ void fromJson(json_t* rootJ) { | |||||
if (threadCountJ) | if (threadCountJ) | ||||
threadCount = json_integer_value(threadCountJ); | threadCount = json_integer_value(threadCountJ); | ||||
json_t* disableDawTimeWarpWorkaroundJ = json_object_get(rootJ, "disableDawTimeWarpWorkaround"); | |||||
if (disableDawTimeWarpWorkaroundJ) | |||||
disableDawTimeWarpWorkaround = json_boolean_value(disableDawTimeWarpWorkaroundJ); | |||||
json_t* tooltipsJ = json_object_get(rootJ, "tooltips"); | json_t* tooltipsJ = json_object_get(rootJ, "tooltips"); | ||||
if (tooltipsJ) | if (tooltipsJ) | ||||
tooltips = json_boolean_value(tooltipsJ); | tooltips = json_boolean_value(tooltipsJ); | ||||