RasPI Audio line monitoring?

Is it possible to use a Raspberry Pi with a USB audio dongle (line-in and line-out) to monitor audio and trigger a response when sound is passed through the RPI?

IE, music or sound comes in, RPI triggers an event like servos or motors, then passes the audio signal line-out?

short answer - yes.
long - I am feeling lazy.

@Tavor,

I have never done it with my rpi, but yes you can.

The question is what layer are you trying to interpret sound?

Well, I’m a coding noob so I wasn’t targeting any particular layer. I was thinking simple, comparing a noise to a known sample for fun things. For example hearing a new level in Minecraft and have a servo wave a flag. Since the sounds in Minecraft are all easily available to sample? But before I plonk down money on parts I want to make sure what I’m thinking is doable.

Before you mentioned minecraft audio I was thinking this:

Pick a frequency (1000 and 1200 are common in this context); this will be your baud rate.
Audio line voltage is 1 volt = +4dbv
1v high 0v low
Maybe shift it to 3.3v and use gpio
Or some serial comm nonsense
I’ve never done it this way but idk it might work

As far as automating identified sounds, shazam style, I don’t know.
The basics of spectral analysis are:
Split a signal into a specified number of bands
Compare all content in each band (per windowed unit of time) to a known freq sine in that band.
Use beats created by phase differences to determine freq of input signal in each band
Maybe set thresholds for each band for noise and for comparing spectral profiles of the stored sounds you’re listening for

Maybe have a buffer listening for a certain sequence of levels or equivalent proportionate levels in each range.

Just spitballin’, here. There’s probably a library for something, somewhere that can solve this the easy way, in a second.

1 Like

Well, maybe I should start off a little easier. What if I changed the stock sound to a 2600 tone? I know from history that those are easy to listen for. (Thanks Captain Crunch)

for single frequency detection, Captain Crunch era had good non-digital tech

RC filter network that only passes detection frequency to fire a transistor/relay