WAV to Voltage vs Time - diyAudio
Go Back   Home > Forums > Source & Line > Digital Line Level

Digital Line Level DACs, Digital Crossovers, Equalizers, etc.

Please consider donating to help us continue to serve you.

Ads on/off / Custom Title / More PMs / More album space / Advanced printing & mass image saving
Reply
 
Thread Tools Search this Thread
Old 20th November 2010, 07:30 PM   #1
diyAudio Member
 
Feebleminded's Avatar
 
Join Date: Dec 2008
Default WAV to Voltage vs Time

Hello all,

I am looking for a way to digitally decode a WAV file and output a voltage level for every time sample. So for a 44.1kHz WAV file that would be a voltage level every 20s. Is there any way to emulate digitally what a DAC does? I realize WAV files are PCM, so I'm not sure how to convert that to a time varying signal.

The goal is to output a voltage vs time plot from an audio recording, and then perform an FFT of that dataset. It seems like there should be some algorithm for doing this, but I have been unable to find anything online. Any suggestions or ideas would be greatly appreciated! Thanks in advance.
  Reply With Quote
Old 20th November 2010, 09:47 PM   #2
Banned
 
Join Date: Jan 2008
Blog Entries: 2
I recently asked for the author of Visual Analyser Visual Analyser 2011

to include a feature permitting FFTs of files to be performed, but I haven't received an answer.

In the absence of such a feature the simplest thing is to use 2 PCs. (It might be possible to do output and input simultaneously on one PC)

Connect the audio output of one PC to the input of the second (or connect 1 PC in loopback).

Run VA or other audio analysis program (AudioTester). Play the audio file on the software player of your choice. Capture the FFT into the analysis program.

w
  Reply With Quote
Old 20th November 2010, 10:04 PM   #3
diyAudio Member
 
Feebleminded's Avatar
 
Join Date: Dec 2008
Wakibaki,

Let me know if you hear anything back from about the Visual Analyser.

I considered your recommendation which would pass the signal through a DAC and then get recorded by an ADC to get the data. There has to be a better way; one that doesn't introduce distortion by having to loop from digital to analog then back to digital.
  Reply With Quote
Old 20th November 2010, 10:24 PM   #4
Banned
 
Join Date: Jan 2008
Blog Entries: 2
OK I have written to the author again...

An FFT is not a difficult algorithm. You could just print out the values, say 8192 of them, then do the butterflies manually. It would take a while... Or if you have software skills, read the .wav and write a program to do it.

I could do it, but it's a while since I wrote anything like that, I'm a bit lazy. I'll look it up and see how much work it would take...

w
  Reply With Quote
Old 20th November 2010, 10:44 PM   #5
Banned
 
Join Date: Jan 2008
Blog Entries: 2
You can do an FFT in Excel if you load the Data Analysis toolpack:

http://userwww.sfsu.edu/~larryk/Comm.../Excel.FFT.pdf

You can even graph it with the charting functions.

Here's a hex editor:

Freeware Hex Editor XVI32

Here's the header format for .wav files:

https://ccrma.stanford.edu/courses/4...ts/WaveFormat/

w
  Reply With Quote
Old 21st November 2010, 12:29 AM   #6
jcx is offline jcx  United States
diyAudio Member
 
Join Date: Feb 2003
Location: ..
quite a few freeware options - that read .wav directly

SciLab, Octave are MatLab work-alikes, both free, handle more points than Excel but still not good for more than a few x 10e7 points some syntax to master - I know SciLab, OK graphic interface, Octave rumored to run MatLab scripts better? - may need xwav scripts for 24 bit - actually more efficient to save as 32 bit wav in Audacity and read as 32 bit in SciLab - playing with bytes is expensive

LtSpice free simulator can read in .wav in a sim - you can then look at the fft in the plot tools, read magnitude, phase, compare ratios with dual cursors - handy if you're familiar with LtSpice

Audacity is a freeware sound editor project - not the highest res fft but good for stimulus/response playback/recording through a soundcard and extensive wav editing tools

Last edited by jcx; 21st November 2010 at 12:52 AM.
  Reply With Quote
Old 21st November 2010, 12:43 AM   #7
dmills is offline dmills  United Kingdom
diyAudio Member
 
Join Date: Aug 2008
Location: High Wycombe
A standard PCM wav file (They can contain various other things) is in essence a header plus a stream of sample values so plotting from the sample values is trivial in either the sample value or frequency domain.

Emulating the reconstruction filter so that you actually get something that looks like an analogue signal takes a little more work, especially if you are changing magnification often....

I don't know about Windows but on Linux there is JAAA and JAPA depending on exactly what you want to see for running realtime plots and any number of file IO utilities for reading the source data.

Failing that, hack something together with FFTW, libSoundFile and Gnuplot, should take less then an hour even given Windows pathetic excuse for a command shell.

Regards, Dan.
  Reply With Quote
Old 21st November 2010, 01:09 AM   #8
Banned
 
Join Date: Jan 2008
Blog Entries: 2
Quote:
Originally Posted by jcx View Post
LtSpice free simulator can read in .wav in a sim - you can then look at the fft in the plot tools
Ideal. That sounds like what he wants do.

w
  Reply With Quote
Old 21st November 2010, 01:41 AM   #9
jcx is offline jcx  United States
diyAudio Member
 
Join Date: Feb 2003
Location: ..
there are some oddities - Ltspce .TRAN will do a 1st order linear interpolation between points, if you use a high resolution time step, long fft record size you won't see the classic 1:1 reflection of the spectum around fs/2 - but the passband below fs/2 should still be representative (the images are sinc^2 filtered by the 1st order hold)

you could tweak the .tran settings, fft length to get closer to the "pure math" DiracDelta "no order hold" plots you would get with SciLab, ect

also you need to learn about window functions - but that applies to getting clean results from any time limited fft (I default to using Blackman)

Last edited by jcx; 21st November 2010 at 01:50 AM.
  Reply With Quote
Old 21st November 2010, 02:48 AM   #10
Banned
 
Join Date: Jan 2008
Blog Entries: 2
Looks like Audacity is the easiest, you can just load the .wav, highlight the bit you're interested in by clicking and dragging the cursor, and going Analyze/Plot Spectrum. It doesn't provide a lot of illumination as to exactly what it's doing though. You can set the number of samples and the window, but it doesn't say whether it starts at the beginning, processes the number of samples and quits or whether it starts again and overlays the results or what.

LTSpice is a bit idiosyncratic in the UI, I haven't got it to work yet, but now I'm thinking Octave or Scilab is going to be the best option for fine control.

As regards the windowing, which I'd forgotten about in the context of writing a program, it's most convenient to be able to switch between them and observe the effect. Of those available in Audacity only the Hanning is of much use, and it doesn't seem to apply it consistently anyway. The leakage with the others is considerable, as can be seen if you generate a tone and then analyse it.

w
  Reply With Quote

Reply


Hide this!Advertise here!
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
To WAV or not to WAV? Godzilla Digital Line Level 110 30th September 2011 06:16 AM
software to compare wav to wav played back through speaker? freddi Multi-Way 2 28th March 2010 05:29 PM
First time caller, long time listener... smallangryboy Introductions 15 19th March 2005 09:10 PM
midi to wav? Horse lover Instruments and Amps 3 27th August 2004 10:00 PM
Opinions on my low-voltage hybrid headphone amp (this time with the right file) JHawk24821 Headphone Systems 2 1st August 2004 05:49 PM


New To Site? Need Help?

All times are GMT. The time now is 02:42 AM.


vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2014 DragonByte Technologies Ltd.
Copyright 1999-2014 diyAudio

Content Relevant URLs by vBSEO 3.3.2