On Tue, 09 Nov 2010 10:35:02 -0600, Vladimir Vassilevsky <nospam@nowhere.com> wrote:> Frnak McKenney wrote: >> I'm working on a Christmas present for my sister Beth based on a 1m >> strip of 30 RGB LEDs > >> The idea is to sample the incoming audio at (say) 8kHz and determine >> the level of sound present in various frequency bands, e.g. if I >> make it respond to a normal human voice: >> >> Red: 80-186Hz >> Green: 186-420Hz >> Blue: 420-1000Hz >> >> but I could live with (say) (DC-180, 180-420, and 420-Nyquist). >> >> Oh, did I mention... I want to do this with a TI MSP430G2231 > >> I'm currently reading up on Goertzel's algorithm, trying to >> understand it well enough to develop a multi-accumulator versionVladimir, thanks for jumping in.> No need to do any Goertzels or filters.I like the sound of that. <grin!>> A basic frequency counter is all that required. > Just make a hystogram of periods; lit the LEDs accordingly.O...kay. So this would be (stop me if I missed something) a histogram of zero-crossing periods (tick counts from one minus-to-plus crossing to the next), all based on the assumption that these approximate the way "energy" is spread across the 1/period frequencies. (Is this a good assumption for complex waveforms? I need to think about this, keeping in mind that I can live with a "sloppy approximation" for "reasonably low" values of "slop".) Anyway, under this assumption my table above becomes: Red: 80-186Hz ==> "periods > 5376usec" Green: 186-420Hz ==> "periods 2381-5376usec" Blue: 420-1000Hz ==> "periods 1000-2381usec"> You might need to add RC highpass in front of the comparator to > compensate for the spectral skew.By "spectral skew" do you mean "contributions by stuff above 1kHz"? Or are you referring to the possibility that low-frequency components in my 0-1000Hz range might be under-represented because they get "chopped" by higher-frequency components which are still in the 0-1000Hz range? That is, you are suggesting an RC filter which will compensate in some way for the zero-crossing periods not well approximating the frequency components of the signal? Don't misunderstand... I really like this aproach: it looks simple to implement and "feels" right. On the other hand, my "feelings" have led me astray before, so I need to do a bit of digging to see how well this holds up. Thanks. Frank -- Our strength is great, but our statesmen have lost the capacity to appear formidable. It is in that loss that our greatest danger lies. Our power to win a war may depend on increased armaments. But our power to avoid a war depends not less on our recovering that capacity to appear formidable, which is a quality of will and demeanour. -- John Maynard Keynes -- Frank McKenney, McKenney Associates Richmond, Virginia / (804) 320-4887 Munged E-mail: frank uscore mckenney ayut mined spring dawt cahm (y'all)
Query re simple digital bandsplit/crossover algorithm
Started by ●November 9, 2010
Reply by ●November 10, 20102010-11-10
Reply by ●November 10, 20102010-11-10
Frnak McKenney <frnak@far.from.the.madding.crowd.com> wrote: (snip)>> If one filter gives you the heebee-jeebees, consider a lowpass >> filter to distinguish red, a highpass filter to distinguish blue, >> and a bandpass filter to distinguish green?> Oh, I'm fine with filters; if you don't see what you want on the > 'scope, you unsolder a part or two and replace it. It's _digital_ > filters that worry me. <grin!>Well, for many years color organs were built with analog filters, usually driving triacs and incandescent light bulbs. Much easier to drive LEDs through some power transistors instead.> Okay. You, Randy, and looking at my used-to-be-Goertzel pseudocode > have convinced me that, to get what I want, I need to go back and > study up on simple filters. Thanks. (I think. <grin!>)-- glen
Reply by ●November 15, 20102010-11-15
On Wed, 10 Nov 2010 07:28:57 -0600, Frnak McKenney <frnak@far.from.the.madding.crowd.com> wrote:> On Tue, 09 Nov 2010 10:35:02 -0600, Vladimir Vassilevsky <nospam@nowhere.com> wrote: >> Frnak McKenney wrote:>>> The idea is to sample the incoming audio at (say) 8kHz and determine >>> the level of sound present in various frequency bands, e.g. if I >>> make it respond to a normal human voice: >>> >>> Red: 80-186Hz >>> Green: 186-420Hz >>> Blue: 420-1000Hz> Vladimir, thanks for jumping in. > >> No need to do any Goertzels or filters. > > I like the sound of that. <grin!> > >> A basic frequency counter is all that required. >> Just make a hystogram of periods; lit the LEDs accordingly. >> You might need to add RC highpass in front of the comparator to >> compensate for the spectral skew.Hi, Vlad. I'm back... (It's never a good sign when you're replying to your own post. <grin!>) First, thank you for your suggestion. I _really_ like the idea of collecting intervals. It's simple and straightforward. Even better, I have an MSP430G2211 chip with an on-board comparator and an ADI MEMS mike that idles at Vcc/2; all I have to do is wire the mike to a comparator input, set up a timer "wired" to the comparator, and it'll be trivial to catch those "rising" zero-transitions. My problem: I tried simulating what I thought you were describing (using Scilab, I'm afraid) and I don't seem to be getting useful results. This could well be coding problems on my part, but it also could be that I've completely misunderstood you. Let me describe what I thought you were saying and, if you have the time, I'd appreciate your shooting holes in my assumptions. (I may not _enjoy_ it, but I ll _appreciate_ it. <grin!> So.. my pseudocode would look like this: 1) Set up a timer with clocking and width such that it can represent intervals from (say) 1.0msec (one full period of 1000Hz) to 12.5msec (a full cycle of 80Hz). If you can't represent it, you can't measure it. 2) Set up a comparator to trigger an interrupt capture of the timer each time the input transitions from sub-zero or zero to a positive value. 3) Set up a 3) Set up histogram buckets to sum amplitudes as follows: Range F(Hz) Interval(msec) Low 80- 186 12.5-5.4 Midrange 186- 420 5.4-2.4 High 420-1000 2.4-1.0 4) At each comparator interrupt, look at the interval values in the following order: Interval Action < 1.0msec Ignore < 2.4msec High++ < 5.4msec Midrange++ < 12.5msec Low++ else Ignore 5) Set the LED PWM values according to the histogram. Is that a fair representation of the process you were briefly describing? I tried to wrap my head around how "intervals" would behave, and I hit a few snags. One of the biggies was this: the positive-going zero-crossings of a simple sine wave of frequency F0 (say 10Hz) are going to be 100msec apart, and those of a 20Hz signal will be 50msec apart. If you combine these two signals the transitions-of-interest will be 50msec apart -- the interval information has completely lost track of the 10Hz part of the signal. And this will be true of any (F0 + 2*F0) waveform, yes? I don't think I'm quite up to re-inventing an FT-alike in interval-space; not this week, anyway(<grin>). Any suggestions as to where I might have gone wrong, pointers to more information, slings, arrows, Bette Midler... any and all will be appreciated. Thanks... Frank -- Government cannot police itself, which is why we have periodic elections. -- David Mamet -- Frank McKenney, McKenney Associates Richmond, Virginia / (804) 320-4887 Munged E-mail: frank uscore mckenney ayut mined spring dawt cahm (y'all)






