T
The real Andy
- Jan 1, 1970
- 0
search google, i have seen this done.
Jeremy said:I had a bit of a 'brain-storm' while I was thinking about how to extract
frequency component information from an analog audio signal. I'll be making
a bunch of assumptions here, and throw a bunch of numbers which may/may not
be usable/believable/correct, but I'm trying to work out the theory, so
please bare with me...
Ok, say you take a PIC's A/D converter, hook it up to a low volt analog
input, say from a headphone jack or an input from an RCA connector. You do
the A/D conversion at say 1khz (keeping everything in 10's so the math is
easier), I'll also assume (for easyness) that the range of the A/D's output
is 0-99 (50 being midrange) and that's all the input signal will do anyways.
Ok, in a nutshell, if the previous reading was a 0, and the current reading
(1ms later) is a 99, then that would mean that the input signal is a 500hz
signal, which would also presume that the next reading would be a 0. So
now, I can deduce that I have a very strong 500hz signal at the input. Ok,
extrapolating that theory, if the previous reading was a 0, and the current
reading is a 50 and the next reading would be a 99, then the input signal
would be 250hz...and so on and so on...
Therefore, I could store these in a FIFO buffer, and continuously do the
math, going back farther in the buffer, looking at the signal level vs. time
and calculate signal strengths and frequencies from this.
Ok, so I got that...Problem is...a 500hz signal could, in theory, look
exactly like a 250hz signal, which could also look exactly like a 125hz
signal, and so on... And of course, all of these numbers I'm throwing out
are theoretical and don't mean anything, just easy numbers to work with.
How would a person compensate for this, in software?
Is this something new (probably not), or is this something that's been going
on for years and years and I have missed something completely?
Basically, where this is going is a project to run a bunch of LED's which
will respond to different audio freq's, pulse the blue for low freq's, pulse
the green for mid-freq's, etc.etc.etc. But I don't want a bunch of
hi/low/band pass filters running around...too many pieces/parts. It's
probably easier in software anyways...
Other than an FFT, you surely should be able to measure the 'average sample
Rich said:[snip...snip...]
There used
to be an excellent DSP primer on the net that could be downloaded by
chapters, but I've no idea where you might find it.
http://www.dspguide.com/
it's all C IIRC
FORTRAN! Pretty straightforward to recode, though.
and
includes samples of IIR filters. I don't recall if it includes filter
calculations.
Some. Enough to get started with and enough to be able to understand
what's going on when punching tables (or software) for other filters.
The OP should definitely get the Smith book above. Signal processing can
actually be kind of fun and the book is a great intro (esp. for free).
Also grab a copy of Scilab 2.7 from http://www-rocq.inria.fr/scilab/
(which seems to be down at the moment?). It's a free tool that's similar
to Matlab and includes canned routines for filter design.
Jeremy said:Fourier Transforms...
I knew I'd heard that somewhere before, didn't know what it was all about.
I've downloaded a bunch of pdf's to read thru all about FFT.
Thanks for all the information from everybody. I knew I couldn't possibly
be the first person ever to think of such a thing.
Now to just figure out how much I could actually do with a 40mhz PIC on 10
bit A/D data with limited ram space. My goal isn't a perfect real time
audio spectrum analyzer, just a digital 'filter' of sorts to flash a bunch
of LED's according to the levels of frequencies coming across the wires.
JDG
In that case Jeremy look at using IIR bandpass filters. They require
less storage than FIR or FFT, fewer coefficents, and you could probably
get it working real time. use 4 pole filters. Each filter requires 3 x
16 bit coefficients (8 bits will not work properly) and 3 x 16 bit
variables. Even a lower end PIC can handle that.