ESP32 detect when there's a sound output on a jack cable

I would like my audio amplifier to turn on and off automatically to save power, I've thought an arduino and a relay hooked to one input jack channel could do the job, but how can detect a signal ?

Can I just make a analogRead() loop, when it's below a certain threshold for a long time it switches off, maybe with a Schottky diode to make it dc ?

How would you do it without affecting the sound ?

Connect your Audio to the Arduino like this.

Audio Bias.jpg

For an ESP32 use the 3V3 not the 5V shown here.

Write a program that reads the analogue input and see what the normal no sound level is, it should be around 512. Then write code to shut off your amplifier if the reading has not exceeded +/- 8 from that value for the set amount of time. Do this by subtracting the reading from the no sound level and take the absolute value of it using the abs function. Use that value in an if statement to see if it exceeds the value of 8, and if it does reset a variable with the current millis() value.

When the millis() value minus that variable exceeds the time you want to leave before shutoff then turn off your amplifier.

Audio Bias.jpg