[dataio] adding samplerate to circular buffer

This commit is contained in:
wendtalexander 2024-10-04 11:48:59 +02:00
parent e43bb16bd4
commit 8910305262

View File

@ -4,7 +4,7 @@ from IPython import embed
class CircBuffer:
def __init__(self, size: int, channels: int = 1, samplerate: float = 40_000):
def __init__(self, size: int, channels: int = 1, samplerate: int = 40_000):
self.__size = size
self.__channels = channels
self.__samplereate = samplerate
@ -14,6 +14,7 @@ class CircBuffer:
self.__index = [0 for i in range(channels)]
self.__is_full = [False for i in range(channels)]
self.__totalcount = [0 for i in range(channels)]
self.__time = [0.0 for i in range(channels)]
self.__overflows = [0 for i in range(channels)]
@property
@ -41,6 +42,7 @@ class CircBuffer:
self.__buffer[channel, self.write_index(channel)] = item
self.__index[channel] = (self.write_index(channel) + 1) % self.__size
self.__totalcount[channel] += 1
self.__time[channel] += 1 / self.__samplereate
if self.__index[channel] == 0:
self.__is_full[channel] = True
self.__overflows[channel] += 1