[ILUG] Spectrum Analyzer using sound card
Michael Conry
michael.conry at ucd.ie
Tue Oct 1 18:36:03 IST 2002
Hi Declan,
I'm not sure about any of the applications you mention. Depending on
what you want to do you could maybe do this more or less by hand. You
can use arecord (part of the alsa utils) to record sound from the
microphone. Then, you can process that using FFT's or whatever else you
like. Since I like python, I use the wave and audioop modules which
include features to allow you to read in a wav, and to turn the wav
formated data into a string of integer sample values. Once you have the
signal in that format, you can use functions in the Numeric and FFT
packages to analyse the signal, and Gnuplot to view the results.
The nice thing about Numeric is that the code is very fast, but gives
you the ease of interaction of python. You can do all of this
interactively when you're setting it up, and maybe script it later on.
I just had a quick go at it and got a basic fft from microphone input in
less than 10 lines of code. I'm sure there are similar utilities for
Perl.
Indeed, once you have the raw samples from the microphone in a text
file, they could very easily be fed into octave/matlab or any other
analysis software you like or are comfortable with.
This does not give you info in realtime, which might be what you want,
but ultimately I think it could be more flexible (you could record 10
second sample from each transformer, fft the data, then calculate energy
in the audible band, or come up with a weighted noise level where you
multiply frequency components by human ear relative-sensitivity to each
component, etc.,). Also, if the results look funny, you can replay the
sample and listen again with human ear, and if you come up with a
neater/cleverer way to process the samples, you can reprocess all the
old samples if you filed them away nicely.
I think the real difficulty will lie in taking the measurements.
Positioning the microphone, trying to isolate outside noise, etc. With
the above scheme, I suppose you could do a 10 second recording and
analysis with the transformer unpowered, and then turn the transformer
on and repeat, and compare the effect (on the assumption that the
background noise changed little between the two samples). Doing
averagings of multiple tests could also help reduce noise effects.
I'd be interested to hear (of list if it's off topic) how you finally
approach the problem, and how your solution works out.
bye for now
mick
On 0020 +0100 %{!Tue, Oct 01, 2002 at 10:55:01AM +0100}, Declan Grady wrote:
> Hi folks,
> I have been googling for some info on using a sound card and microphone as a
> simple spectrum analyser for the 10Hz to 10 or 15 Khz range.
>
> I have found a few tools, such as:
> freq5.1
> jxspectrum
> svgafft
> xspectrum
>
> Anyone used any of these (successfully), or any other recommendations.
>
> The application is measurement of audible hum from power transformers
> (which we design and make), so I need to come up with a solution, and
> I'd like to go down the linux route, and mabye shed my newbie hat in
> the process !
>
> Thank for any pointers
>
> Declan
--
Michael Conry Ph.:+353-1-7161987, Web: http://www.acronymchile.com
Key fingerprint = 5508 B563 6791 5C84 A947 CB01 997B 3598 09DE 502C
More information about the ILUG
mailing list