MOPTAW 47: LED Color organ for an electric violin

Scriptless Flickr BadgeScriptless Flickr BadgeScriptless Flickr BadgeScriptless Flickr BadgeScriptless Flickr Badge
Scriptless Flickr BadgeScriptless Flickr BadgeScriptless Flickr BadgeScriptless Flickr BadgeScriptless Flickr Badge
Porkshanks commissioned me to design an LED color organ driver for a functional art-piece modification of an electric violin, for Maker Faire. She herself had been commissioned to convert an electric violin to a tubepunk aesthetic, and was looking for a lighting effect more sophisticated than a plain glow. I built one that drives brightness based on loudness and huge based on pitch.

An ATmega168 samples the output from the violin's pickup at around 4 kHz. It's capacitively coupled to a voltage divider to bias the violin's zero voltage to the '168's input midpoint. A digital highpass filter with a very low corner frequency removes the DC component from the input signal.

From there, the signal is split into two complimentary subbands, and a signal strength estimate is performed by grouping every 32 samples of each of the upper and lower bands, as well as taking an estimate of the total signal. The total signal strength estimate is then lowpass filtered and use to drive the brightness of the LEDs. The pitch is estimated by treating the high and low bands as coordinates, and taking the arctangent of their ratio. This resulting phase angle is the pitch estimate.

The informal justification is that a very low frequency tone will excite the lowpass filter almost exclusively, just as a very high frequency tone will excite the highpass filter. A midpoint tone will excite the two equally. What is important is the ratio between the two, with 0 mapping to a low tone, 1.0 mapping to the midpoint, and +inf for a high tone.

This only strictly speaking works for pure sinusoids. Harmonics and aliasing components will contaminate the estimate. Although the input circuit forms a lowpass filter, I didn't tune it to match the sampling rate. I chose a sampling rate high enough that aliasing components tend to be due to quite weak harmonics, and the amplitudes of even the unaliased harmonics are low enough that, for a violin at least, the mapping is actually quite good.