I am creating a simple program that visualizes stereo sound. The program code below shows the visualization from mirophone (input) only. I want the visualization to work from the output (system sound).
import pyaudio
import numpy as np
maxValue = 2**16
p=pyaudio.PyAudio()
stream = p.open(format=pyaudio.paInt16, channels=1, rate=44100, input=True, output=True, frames_per_buffer=1024, output_device_index=3)
while True:
data = np.fromstring(stream.read(1024),dtype=np.int16)
dataL = data[0::2]
dataR = data[1::2]
peakL = np.abs(np.max(dataL)-np.min(dataL))/maxValue
peakR = np.abs(np.max(dataR)-np.min(dataR))/maxValue
print("left", round(peakL, 2))
print("right", round(peakR, 2))