fix(fxrt): toggle VST bypass khong reload plugin - cache instance trong bridge, chain giu slot bypassed, bypass state trong chainKey, poll 100ms + fade-in 512 samples che gap latency
This commit is contained in:
@@ -198,7 +198,7 @@ int run_realtime_fx_loop(const std::string& jobPath, const std::string& shmName,
|
||||
});
|
||||
|
||||
// Chain update (set_chain): engine ghi lại job file seq++ — poll mỗi
|
||||
// 500ms; seq đổi → setChain ASYNC (worker load chain mới, swap atomic
|
||||
// 100ms; seq đổi → setChain ASYNC (worker load chain mới, swap atomic
|
||||
// dưới mutex — audio thread copy shared_ptr, không dừng) → load/đổi VST
|
||||
// FX + đổi preset GUI không ngắt âm/crackle.
|
||||
uint64_t lastSeq = (uint64_t)jsonNumber(job, "seq", 0);
|
||||
@@ -209,6 +209,8 @@ int run_realtime_fx_loop(const std::string& jobPath, const std::string& shmName,
|
||||
uint32_t outMask = ipc->h.outSlots - 1;
|
||||
uint64_t processed = 0;
|
||||
uint64_t lastGen = 0; // chain generation đã báo latency
|
||||
uint32_t fadeLeft = 0; // output fade-in còn lại sau chain swap (che gap latency jump)
|
||||
const uint32_t fadeTotal = 512; // ~11.6ms @44.1k
|
||||
// ---- FXRT_PERF instrumentation (tạm, đo crackle) ----
|
||||
uint64_t perfIter = 0, perfProc = 0, perfIdle = 0, perfOutFull = 0;
|
||||
double perfProcSum = 0.0, perfProcMax = 0.0, perfProcMin = 1e9;
|
||||
@@ -224,7 +226,7 @@ int run_realtime_fx_loop(const std::string& jobPath, const std::string& shmName,
|
||||
}
|
||||
{
|
||||
const auto nowT = std::chrono::steady_clock::now();
|
||||
if (std::chrono::duration_cast<std::chrono::milliseconds>(nowT - lastPoll).count() >= 500) {
|
||||
if (std::chrono::duration_cast<std::chrono::milliseconds>(nowT - lastPoll).count() >= 100) {
|
||||
lastPoll = nowT;
|
||||
const std::string j2 = readFile(jobPath);
|
||||
if (!j2.empty()) {
|
||||
@@ -266,6 +268,7 @@ int run_realtime_fx_loop(const std::string& jobPath, const std::string& shmName,
|
||||
ipc->h.latWrite++;
|
||||
}
|
||||
lastGen = gen;
|
||||
fadeLeft = fadeTotal;
|
||||
std::cerr << "[RealtimeFxLoop] latency reported: " << lats.size()
|
||||
<< " slot(s)" << std::endl;
|
||||
}
|
||||
@@ -314,6 +317,16 @@ int run_realtime_fx_loop(const std::string& jobPath, const std::string& shmName,
|
||||
if (perfProcMs > perfProcMax) perfProcMax = perfProcMs;
|
||||
if (perfProcMs < perfProcMin) perfProcMin = perfProcMs;
|
||||
for (uint32_t i = 0, o = 0; i < take; ++i, o += n) {
|
||||
if (fadeLeft > 0) {
|
||||
const uint32_t f = std::min<uint32_t>(fadeLeft, n);
|
||||
const float start = (float)(fadeTotal - fadeLeft);
|
||||
for (uint32_t k = 0; k < f; ++k) {
|
||||
const float g = (start + (float)k) / (float)fadeTotal;
|
||||
L[o + k] *= g;
|
||||
R[o + k] *= g;
|
||||
}
|
||||
fadeLeft -= f;
|
||||
}
|
||||
const uint32_t oslot = ipc->h.outWrite & outMask;
|
||||
std::memcpy(ipc->outL[oslot], L + o, n * sizeof(float));
|
||||
std::memcpy(ipc->outR[oslot], R + o, n * sizeof(float));
|
||||
|
||||
Reference in New Issue
Block a user