Open JacquiG29 opened 2 years ago
It is difficult to understand what is going wrong without the actual code. Please post a minimal example that showcases the behavior you're struggling with.
Thanks for the replay
My main code is the following:
if __name__ == '__main__':
try:
#THREAD
t1=threading.Thread(name="hilo_1",target=grabacion_filtrada)
t1.start()
while True:
with sd.Stream(device=(args.input_device, args.output_device),
samplerate=args.samplerate, blocksize=args.blocksize,
dtype=args.dtype, latency=args.latency,
channels=args.channels, callback=callback):
input()
# Reset by pressing CTRL + C
except KeyboardInterrupt:
print("Measurement stopped by User")
And the function that I am calling in my thread is the next one:
def grabacion_filtrada():
while True:
modo=1
filename='Prueba'
print ("recording...")
myrecording = sd.rec(int(seconds * fs), samplerate=fs, channels=1)
sd.wait() # Wait until recording is finished
print ("finished recording")
print ("filtering...")
raw_data = myrecording.flatten() #simple string
kalman_filt=Kalman(raw_data,varMeas,varProcess)
kalman_filt = np.asarray(kalman_filt)
write(filename[0:len(filename)]+'.wav', fs,kalman_filt)
print ("end filtering")
I get the error that I post every time my function called ¨grabacion_filtrada()¨ is trying to record. I hope this pieces of code make it more understandable. Thank you for your help.
I don't think I understand what you are trying to do or how often these loops are iterated for example.
Isn't maybe the problem that sd.Stream(...
and sd.rec(...
try to access the same interface simultaneously? I'm not sure right now weather that is supposed to be possible. But anyways, doing that seems like it should simply be implemented differently?
Is the objective that the input data is passed straight to output as well as simultaneously captured (+ processed + saved)? If so, then we can think of a more appropriate "signal flow" to be implemented.
Isn't maybe the problem that
sd.Stream(...
andsd.rec(...
try to access the same interface simultaneously? I'm not sure right now weather that is supposed to be possible. But anyways, doing that seems like it should simply be implemented differently?
I was able to access to it simultaneously in windows, but when I tried it in Ubuntu it failed and my implementation will be on Ubuntu that's why I'm struggling with it.
Is the objective that the input data is passed straight to output as well as simultaneously captured (+ processed + saved)? If so, then we can think of a more appropriate "signal flow" to be implemented.
This actually what I am trying to do
I was able to access to it simultaneously in windows, but when I tried it in Ubuntu it failed and my implementation will be on Ubuntu that's why I'm struggling with it.
Interesting.
Is the objective that the input data is passed straight to output as well as simultaneously captured (+ processed + saved)? If so, then we can think of a more appropriate "signal flow" to be implemented.
This actually what I am trying to do
Then before suggesting a potentially better solution to implement this ... The processing is efficient enough to be performed in real-time (on a block-by-block) basis? Is the execution in the scope of a few seconds or rather of arbitrarily long length?
So I tried my processing in real time and I think that it is efficient enough to be performed. In the other hand, the execution won't have a defined duration.
I have the following issue: I am creating a thread that is dedicated to record and post process my audio. In my main program I am streaming the real time audio according to the wire.py example. I already tried both functions separately and they work but everytime that I want to multithread them I got the following error:
I am using Ubuntu 21.04. The device that I want to select from the sd.query_devices() is this:
8 USB PnP Sound Device: Audio (hw:3,0), ALSA (1 in, 2 out)
and I am selecting it with this code line:sd.default.device = 8,8
Thank you for your help