class AudioBuffer(): def __init__(self): self.ringbuffer = RingBuffer() self.newpoints = 0 self.delay_samples = 0 def data(self, length): return self.ringbuffer.data(length) def data_older(self, length, delay_samples): return self.ringbuffer.data_older(length, delay_samples) def newdata(self): return self.data(self.newpoints) def set_newdata(self, newpoints): self.newpoints = newpoints def data_delayed(self, length): undelayed = self.data(length) delayed = self.data_older(length, self.delay_samples) data = delayed data[1, :] = undelayed[1, :] return data def set_delay_ms(self, delay_ms): self.delay_samples = delay_ms * 1e-3 * 44100
class AudioBuffer(): def __init__(self, logger): self.ringbuffer = RingBuffer(logger) self.newpoints = 0 self.delay_samples = 0 def data(self, length): return self.ringbuffer.data(length) def data_older(self, length, delay_samples): return self.ringbuffer.data_older(length, delay_samples) def newdata(self): return self.data(self.newpoints) def set_newdata(self, newpoints): self.newpoints = newpoints def data_delayed(self, length): undelayed = self.data(length) delayed = self.data_older(length, self.delay_samples) data = delayed data[1,:] = undelayed[1,:] return data def set_delay_ms(self, delay_ms): self.delay_samples = delay_ms*1e-3*SAMPLING_RATE def data_indexed(self, start, length): return self.ringbuffer.data_indexed(start, length)
class AudioBuffer(QtCore.QObject): new_data_available = QtCore.pyqtSignal(np.ndarray) def __init__(self): super().__init__() self.ringbuffer = RingBuffer() self.newpoints = 0 self.lastDataTime = 0. def data(self, length): return self.ringbuffer.data(length) def data_older(self, length, delay_samples): return self.ringbuffer.data_older(length, delay_samples) def newdata(self): return self.data(self.newpoints) def set_newdata(self, newpoints): self.newpoints = newpoints def data_indexed(self, start, length): return self.ringbuffer.data_indexed(start, length) def handle_new_data(self, floatdata, input_time, status): self.ringbuffer.push(floatdata) self.set_newdata(floatdata.shape[1]) self.new_data_available.emit(floatdata) self.lastDataTime = input_time
class AudioBuffer(QtCore.QObject): new_data_available = QtCore.pyqtSignal(np.ndarray) def __init__(self, logger): super().__init__() self.ringbuffer = RingBuffer(logger) self.newpoints = 0 self.lastDataTime = 0. def data(self, length): return self.ringbuffer.data(length) def data_older(self, length, delay_samples): return self.ringbuffer.data_older(length, delay_samples) def newdata(self): return self.data(self.newpoints) def set_newdata(self, newpoints): self.newpoints = newpoints def data_indexed(self, start, length): return self.ringbuffer.data_indexed(start, length) def handle_new_data(self, floatdata, input_time, status): self.ringbuffer.push(floatdata) self.set_newdata(floatdata.shape[1]) self.new_data_available.emit(floatdata) self.lastDataTime = input_time
class AudioBuffer(): def __init__(self, logger): self.ringbuffer = RingBuffer(logger) self.newpoints = 0 def data(self, length): return self.ringbuffer.data(length) def data_older(self, length, delay_samples): return self.ringbuffer.data_older(length, delay_samples) def newdata(self): return self.data(self.newpoints) def set_newdata(self, newpoints): self.newpoints = newpoints def data_indexed(self, start, length): return self.ringbuffer.data_indexed(start, length)
import numpy as np from friture.ringbuffer import RingBuffer import matplotlib.pyplot as plt Ns = int(1e4) x = np.arange(Ns) x.shape = (1,Ns) l = 1024 Nb = int(Ns/l) print "Nb =", Nb rb = RingBuffer() rb.data(Ns) # grow the buffer as needed # split in two to test zero-length insertions Nb0 = Nb/2 print "Nb0 =", Nb0, "Nb1 =", Nb - Nb0 print "pushing first parts" for i in range(Nb0): rb.push(x[:,i*l:(i+1)*l]) print "pushing an empty array", x[:,0:0].shape rb.push(x[:,0:0]) print "pushing second parts" for i in range(Nb0,Nb): rb.push(x[:,i*l:(i+1)*l])
def __init__(self): self.ringbuffer = RingBuffer() self.newpoints = 0 self.delay_samples = 0
def __init__(self, logger): self.ringbuffer = RingBuffer(logger) self.newpoints = 0
def __init__(self, logger): self.ringbuffer = RingBuffer(logger) self.newpoints = 0 self.delay_samples = 0
def __init__(self): super().__init__() self.ringbuffer = RingBuffer() self.newpoints = 0 self.lastDataTime = 0.
def __init__(self, logger): super().__init__() self.ringbuffer = RingBuffer(logger) self.newpoints = 0 self.lastDataTime = 0.