fix(vsti): crackle fix P1-P3 — SHM 8-slot ring + drain-delta pump + AudioWorklet sink

- SharedMemoryIPC.h/main.cpp: render into ring slot (idx & ringMask), 8 slots
- shm.rs: ring fields + read_ring_audio; lib.rs pump drains FULL delta, not just latest
- bridgeAudioNode.js: AudioWorklet primary (bridge-audio-sink), ScriptProcessor fallback
- bridgeAudioWorklet.js: ring 64 blocks, underrun fade, overrun drop + crossfade
- layout tests: sizeof 27560 (8-align via u64)
This commit is contained in:
2026-08-16 20:43:50 +07:00
parent ed26e1706d
commit cead8c8c71
8 changed files with 235 additions and 29 deletions
+6 -1
View File
@@ -654,6 +654,8 @@ int main(int argc, char* argv[]) {
#else
(void)shmName; // POSIX shm mapping (shm_open) added when porting off Windows
auto* shmIPC = (SharedAudioBufferIPC*)std::calloc(1, sizeof(SharedAudioBufferIPC));
// VSTi crackle fix: 8-slot audio ring (see SharedMemoryIPC.h).
shmIPC->ringMask = 7;
if (!shmIPC) return 1;
#endif
@@ -754,9 +756,12 @@ int main(int argc, char* argv[]) {
};
// Render only [from, to) of the block — used by sample-accurate splitting.
// VSTi crackle fix: target the multi-slot ring slot for the block being
// built, so old blocks stay readable until the reader drains them.
auto renderSegment = [&](uint32_t from, uint32_t to) {
if (to <= from) return;
instruments.renderAll(shmIPC->masterLeft + from, shmIPC->masterRight + from, to - from);
uint32_t slot = shmIPC->bridgeWriteIndex & shmIPC->ringMask;
instruments.renderAll(shmIPC->ringLeft[slot] + from, shmIPC->ringRight[slot] + from, to - from);
};
double blockDurationMs = (double)block / sampleRate * 1000.0;