ezmsg-org / ezmsg

Pure-Python DAG-based high-performance SHM-backed pub-sub and multi-processing pattern
https://ezmsg.readthedocs.io/en/latest/
MIT License
11 stars 5 forks source link

sigproc.synth.Counter sleeps too long #40

Closed cboulay closed 9 months ago

cboulay commented 11 months ago

https://github.com/iscoe/ezmsg/blob/005590f74ec66b22cd36a94827ff5822ee4bbc92/extensions/ezmsg-sigproc/ezmsg/sigproc/synth.py#L111-L117

Both await asyncio.sleep(block_dur) and await asyncio.sleep(1.0 / dispatch_rate) fail to subtract the processing time. The sleep durations should probably be something like asyncio.sleep(t_next - time.time()) where t_next is calculated from a sum of the time of the last counter-reset (if self.STATE.samp >= self.STATE.cur_settings.mod: self.STATE.t_counter_reset = time.time() + {time of overflow samples}) + how long it should taken to reach the next self.STATE.samp.

I'm actually playing around with EEGSynth, which uses ext_clock, so the above issue isn't even the source of my problem. I just thought I'd submit the issue before moving on.

griffinmilsap commented 11 months ago

Aye... this was a case of "good enough for now" but I agree its not the highest precision impl. Now that this is addressed in sigproc.synth.Clock I'll make a TODO to fix this here in the dev branch.

cboulay commented 9 months ago

I'm pretty sure this was fixed in #62