Close

Sensing the Audio

A project log for Bilexa Bass

Alexa-Enabling the Billy the Bass

bob baddeleybob baddeley 04/08/2018 at 03:520 Comments

The mouth needed to move appropriately.  This was a minimum viable feature. It just had to look good. My initial thought was to treat the audio like a VU meter and dump that to the motor. It didn't work to just pipe the audio signal into the motor (though surprisingly you could hear the music playing through the motor). Adding an amplifier didn't make a difference. Then I thought I'd put in a capacitor to smooth out the waveform and give me more of a smooth volume level. This did not work. I looked for some analog circuits, but didn't find anything suitably simple, so I decided to go the route of everyone else; throw an Arduino on it!

Now this actually makes sense. I already needed some logic to handle the photoresistor and waking of Alexa, so I had need for an Arduino, and this would allow me to integrate the two sensors, AND do some DSP on the audio signal. It was perfect!

I had an ATTiny from a previous project, my LED icicles, so I decided to just use that PCB and its programming cable and skip ahead.

One thing I REALLY wish I had was some debug output. I had nothing; no indication of what values were or what I was doing. It was all a shot in the dark, and I hoped that it my changes would work slightly better than the previous attempt.

The first algorithm was based on sum of squares. Take a bunch of readings, square them to get absolute value, and see if they're above a threshold. This worked ok, but not great. On loud music the mouth would just be open the whole time.

The next step was to do a FFT. I found the fix_fft library and tried that out. It was a pain to get it working, but the results never looked good enough. I couldn't get it to look any better than random for the body motion, and for the mouth I couldn't bin things appropriately so that both men and women voices worked. It was just too unreliable.

Then I found someone else who used an ATTiny for audio processing. I used their code, tweaked it for my application, and things looked a lot better. It took quite a bit of tweaking, and I don't quite understand how it works, but I finally have something I'm happy to show off to people.

Discussions