I want to control my addressable LEDs depending on the current music’s volume. I need some kind of value like 0-100 depending on the music’s loudness.
I thought of measuring the microphone’s volume, but I don’t want to create virtual microphones from speakers.
import sounddevice as sd
import numpy as np
def print_volume(indata, frames, time, status):
volume_norm = np.linalg.norm(indata)*10
print(f'Microphone Volume: {volume_norm:.2f}')
with sd.InputStream(callback=print_volume):
sd.sleep(10000)