Hi,
I am working on an audio processing project using Rsp4. It involves using two mics both connected via USB ports.
The program works however there is far too much noise that you can barely hear. It mic2 it like a machine is ON. I am new to audio processing so I assume I need to do some filtering but I am not sure if this much noise is normal. My codes are below.
Any tips or guidance is most welcome.
I am working on an audio processing project using Rsp4. It involves using two mics both connected via USB ports.
The program works however there is far too much noise that you can barely hear. It mic2 it like a machine is ON. I am new to audio processing so I assume I need to do some filtering but I am not sure if this much noise is normal. My codes are below.
Any tips or guidance is most welcome.
Code:
import pyaudio
import sys
import time
from gpiozero import LED, Button
import time
chunk = 4096
FRAMES_PER_BUFFER = 3200
FORMAT = pyaudio.paInt16
MIC1 = 1
MIC2 = 2
RATE = 44100
led = LED(17)
button = Button(27)
p = pyaudio.PyAudio()
stream1 = p.open(format = FORMAT,
channels = MIC1,
rate = RATE,
input = True,
output = True,
frames_per_buffer = FRAMES_PER_BUFFER)
stream2 = p.open(format = FORMAT,
channels = MIC1,
rate = RATE,
input = True,
output = True,
frames_per_buffer = FRAMES_PER_BUFFER)
player = p.open(format = FORMAT,
channels = MIC1,
rate = RATE,
input = True,
output = True,
frames_per_buffer = FRAMES_PER_BUFFER
)
player2 = p.open(format = FORMAT,
channels = MIC2,
rate = RATE,
input = True,
output = True,
frames_per_buffer = FRAMES_PER_BUFFER
)
#stream started
started = False
while True:
if button.is_pressed:
if not started:
stream2.stop_stream()
stream1.start_stream()
started = True
frames = []
data = stream1.read(FRAMES_PER_BUFFER)
frames.append(data)
player.write(data,FRAMES_PER_BUFFER)
print('MIC1 is running')
else:
if started:
stream1.stop_stream()
started = False
stream2.start_stream()
frames2 = []
data2 = stream2.read(FRAMES_PER_BUFFER)
frames2.append(data2)
player2.write(data2,FRAMES_PER_BUFFER)
print('MIC2 is running')
Last edited by a moderator: