AmpliPi icon indicating copy to clipboard operation
AmpliPi copied to clipboard

Detect audio level on analog inputs

Open Lohrer opened this issue 4 years ago • 1 comments

New preamp boards have "peak detection" circuits on them.

  • [x] Read the output of the peak detect circuit on the Pi
  • [x] Fix the issue where when nothing is connected to the input, ~3.75V is present
    • Pulldowns added to Rev 2A boards, Rev3A boards will measure post-AC coupling
  • [ ] Determine if audio is playing or not from peak detect values
  • [ ] Integrate with AmpliPi: make analog inputs have a "playing" or "paused" status based on detected audio level

Lohrer avatar May 18 '21 22:05 Lohrer

When no input is connected: AL1_R rises to at least ~3.7V. It's hard to measure because it collapses when probed, but this is the value on C62. The other side of C1 is at ~2.4V, so I don't know where the extra 1.3V+ comes from.

With an audio input connected: The output of U25A matches the input exactly, except is clipped at 0V. The cathode of D1 tends to spike high, then decay until something causes it to spike up again.

Lohrer avatar May 18 '21 22:05 Lohrer

The above comments are for old hardware and have been fixed. See the preamp board's schematic page 2 for the circuit.

This is being worked on in the peak-detect branch. There is currently a skeleton audiodetector.c which does the actual ADC reading and outputs the status to a file. Amplipi's ctrl.py has been updated to read the playing/stopped status from that file.

To build the audiodetector binary, run make -C amplipi/audiodetector from the root of the AmpliPi repo. ./scripts/configure.py --audiodetector will also build the binary and install the service.

Lohrer avatar Nov 21 '22 16:11 Lohrer

@jonahshader did you try the audiodetector on Preamp board rev 2.A?

Also, I tried from a fresh install and the rca_status file is generated but is empty. If it helps debug, I don't have anything playing and haven't had anything playing. Since the file is 0 bytes, I get the following error in AmpliPi:

Error getting RCA audio status: index out of range

Lohrer avatar Dec 21 '22 20:12 Lohrer

Integrated this in 0.2.0

linknum23 avatar Mar 15 '23 19:03 linknum23