Converting Arb Waveform to Data Points

I have an MP3 file of an arbitrary waveform. From it I need to derive a set of data points with values from 0 to 256 (y) at 3 precise millisecond (x) intervals. What is the most straightforward way of accomplishing this?

BTW I only have the analogue waveform, not access to an arb generator itself.

John Farrell

Reply to
jfarrell
Loading thread data ...

Unless it's a really high bitrate MP3 (even then, I don't know), your waveform is already trash. MP3 is a lossy format with psychoacoustic adjustments, probably passable for frequency domain measurements, but any time domain waveforms will have phase shifts and humps you weren't expecting. Or something.

So, you want to extract samples? Downsample? Quantize? Measure? What? I'd say try opening it in Audacity..

Tim

-- Deep Friar: a very philosophical monk. Website:

formatting link

Reply to
Tim Williams

"audacity"

"mpg123" + "sox" if you need to script it,

--
?? 100% natural 

--- news://freenews.netfront.net/ - complaints: news@netfront.net ---
Reply to
Jasen Betts

Zeroth, I'm assuming you want to do this on a full desktop/laptop PC. If you need to implement it on some kind of microprocessor or embedded system, the steps are the same, but you get to write more of the software yourself.

First, you need to get it out of MP3 and into something like WAVE or raw binary format. sox or Audacity will do this.

At this point, it is optional to normalize it, such that the loudest sound (highest peak) in the waveform corresponds to the biggest number representable in the chosen format. This means finding the loudest peak in the data, figuring out the scale factor, and then multiplying all the samples by the same scale factor. Again, sox or Audacity will do this.

Second, assuming that 0 to 255 is OK, you need to scale it to 8 bits. If you really, really, really need 0 to 256, you'll need to scale it to either 9 bits (which gives you 0 to 511) or 16 bits (0 to 65,535). Most all sound software will be happy to scale it to 8 or 16 bits but I don't know if many packages can do 9 bits. If you end up scaling it to 9 or 16 bits, you'll have to add a manual scaling step later to scale the 0-511 or 0-65535 range to 0-256.

Third, if I understand your requirement correctly, you need a value every 3 milliseconds. You therefore probably need to resample to some rate that gives you samples on an integer multiple of 3 milliseconds. (You can resample to 333.33 Hz and use every sample, or resample to

1 kHz and use every third sample, or resample to 10 kHz and use every 30th sample, etc.) Note that resampling will limit the bandwidth of your data; if you resample to 333 Hz, no signal faster than about 167 Hz will make it through. sox or Audacity will do this.

Fourth, you need to pick out whatever samples you have selected and read out their values. sox and Audacity can save audio as binary files with no header; you will need to either inspect the file on your own or write a program to scan the file and print out the results in human- readable form. This is probably where you would do the manual scaling if you need 0-256 and have 0-511 or 0-65535.

sox is a command-line program and Audacity has a GUI. If you're doing this once, Audacity is easier. If you need to automate it, sox is easier. (Also, if you're automating it, record to an uncompressed format at first - *not* MP3.)

It is probably a good idea to obtain an input file of something like a pure sine wave at 1 kHz or 10 kHz or whatever approximately matches your data, run it through all the steps, and make sure you see about what you expect. If you don't, then try an input file with a constant DC level in it.

Audacity and sox should be installable packages on all major Linux distributions. There are Windows versions of both programs; see

formatting link
and
formatting link
.

Matt Roberds

Reply to
mroberds

Except for the slightly nasty 11.025/22.05/44.1 kHz sampling rates, what is the problem ?

With simple weighting (1st order interpolation), even those cases could be handled easily.

Reply to
upsidedown

Thank your for your detailed reply.

I have a copy of Adobe Audition which I assume will do about the same thing. It used to be called "CoolEdit" and you can still get it at

formatting link

Goldwave can implement math expressions, but I would need to brush up on these.

John Farrell

Reply to
jfarrell

You're welcome!

CoolEdit/Audition should do most of the same things as Audacity, yes. I think Audacity's basic feature set and UI were partly modeled on CoolEdit, many years ago, but they have probably diverged since then.

Depending on how old it is, Audition might not want to use an MP3 as input, even if it can save its output as MP3. In that case, there are lots of MP3-to-WAV converters around that you can use first.

Audition may have some kind of scripting language in case you need to do this more than once. But get it working through the GUI first before you try to automate it.

Matt Roberds

Reply to
mroberds

Great reply! Sorry for being a bit pedantic, Yes, the 'results' will be limited in frequency, but the 'content' will contain aliasing [energy] of every higher frequency folded into that spectrum. The result will not even represent very well the low frequency content of the original signal with all that folded in higher frequency content.

Reply to
Robert Macy

I seem to recall that Audacity will (or can) apply a low-pass filter before resampling to a lower rate. It's been a while since I've used that functionality, though.

In general, you can *hear* the high-frequency aliasing in things that have been undersampled without a low-pass filter first. YouTube videos recorded at low bitrates from TV or radio tend to have it.

Matt Roberds

Reply to
mroberds

Have a copy of Audacity, will try...some day.

Interesting. Bet aliasing shows up more in speech than music, right? Interesting because *if* you can hear it, something incredible as the pattern recognition of the human brain could remove it. Well, maybe. Tantalizing.

Reply to
Robert Macy

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.