1

For controlling a motor and producing a sound I want to convert windows (or any other live audio stream) to an unsigned 8bit data stream with a frequency of 16kHz or 16 samples per millisecond.

I am currently using pyaudio do do this but the signal is not clear and the audio quality could be a lot better. When using files to produce the sound in the motor it works very well and i get the full audio quality.

CHUNK = 1
RATEIN = 16000
    
p = pyaudio.PyAudio()

stream = p.open(format=pyaudio.paInt16, channels=1, rate=RATEIN, input=True, frames_per_buffer=CHUNK)

I use this to get the audio stream from VB Virtual Audio cable.

Then for every message I send to the motor controller I use this:

for i in range(16):
    data = np.frombuffer(stream.read(CHUNK),dtype=np.int8)
    Payload[i+1] = int(data[0]/2+128)    
thewill102
  • 11
  • 1

0 Answers0