Skip to content

Commit 0524e86

Browse files
cboulayclaude
andcommitted
Round the mock's EEG filter delay to the nearest sample
The EEG anti-alias delay rounds to the nearest sample instead of flooring, so DIN->EEG lands at 112/62/36 ms (was 108/60/36) -- closer to the device's 111/61/36, which the app applies as a continuous (non-quantized) timestamp offset anyway. The physio lead keeps flooring to match the device's own whole-sample quantization, so EEG-physio is unchanged at 32/32/33 ms. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 1ee56e1 commit 0524e86

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

mock/src/MockAmplifier.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,12 @@ void MockAmplifier::generatePacketFormat2(PacketFormat2_SamplePacket& packet) {
413413
// event immediately; EEG and physio see it delayed in decimated mode so the
414414
// device's EEG-vs-DIN filter delay and physio-leads-EEG-by-33ms skews appear.
415415
const long long n = static_cast<long long>(state_.packetCounter);
416+
// EEG filter delay rounds to the nearest sample (the app applies it as a
417+
// continuous timestamp offset, so nearest-sample is the closest the mock's
418+
// sample grid can get). The physio lead floors, matching the device's own
419+
// whole-sample quantization (32 ms @ 250/500, 33 ms @ 1000).
416420
const int eegDelaySamples = state_.decimated
417-
? filterDelayMs(sampleRate) * sampleRate / 1000 : 0;
421+
? (filterDelayMs(sampleRate) * sampleRate + 500) / 1000 : 0;
418422
const int physioLeadSamples = state_.decimated
419423
? PHYSIO_LEAD_MS * sampleRate / 1000 : 0;
420424
int physioDelaySamples = eegDelaySamples - physioLeadSamples;

0 commit comments

Comments
 (0)