Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conversion from ascii to wav

Status
Not open for further replies.

kaiserman

Mechanical
Oct 5, 2001
22
SPL data was recently requested and taken on several different steppermotors for an automotive application. That data was collected using an FFT analyzer (RealTime octave Analysis). The data was then provided to the customer, as requested in 1/3 octave bands in EXCEL. The data was first saved as an ascii file and then imported in EXCEL per the customers request. The customer is now asking if we could send them a wav file for them to listen to via their PC.

Is anyone aware of conversion type software that can convert ascii files to wav? I would hate to have to repeat the process.

Thanks!
 
Replies continue below

Recommended for you

It is easy to convert ASCII to wav, here is a very bodgy way to do it, but there are many pages on the web that describe it properly, do a google search, looking for the structure of wav files. I'll post separately on why I think you are doomed to failure.

Use this rather nasty Basic program to generate custom .wav files, then play them back using the Media Recorder. This generates a double, ramped, 1 or 2 kHz tone (can’t remember), which is lousy for testing, fine for what I want. If you need longer samples (you will) then increase the length of the source .wav in sound recorder, and modify the program. Obviously you need to start with a wav file long enough to contain your data, and to replace the loop that generates the tone with your ascci data.

ding.wav is used to generate a valid header as I couldn’t find the .wav file format.

Frequency accuracy is unknown, but probably ok .Voltage calibration will be unique to your system.

Good Luck

OPEN "ding.wav" FOR INPUT AS #1

OPEN "tone.wav" FOR OUTPUT AS #3

FOR m = 1 TO 128
i$ = INPUT$(1, #1)
PRINT m + k + j * 20 + 800 * i, i$, ASC(i$)
PRINT #3, i$;
NEXT m

FOR i = m TO 11598
f = 1000
c$ = STR$(INT(128 + (SIN(i / (11598 - m) * 2 * 3.142)) * (125 * SIN(i * f / 22050 * 6.28))))

'PRINT i, c$
IF VAL(c$) < 0 THEN c$ = STR$(1)
PRINT #3, CHR$(VAL(c$));
NEXT i


CLOSE
STOP

FOR i = 0 TO 11
FOR j = 0 TO 39
FOR k = 1 TO 20
i$ = INPUT$(1, #1)
PRINT m + k + j * 20 + 800 * i, i$, ASC(i$)
NEXT k
INPUT s$
CLS
NEXT j
NEXT i
CLOSE
STOP


Cheers

Greg Locock
 
The reason I think this is no help is that you have lost the original time history data when you took its FFT. If you have averaged the FFTs then it is no longer possible to reconstruct the time history. (it is possible in some circumstances but not very often).

If you take your averaged FFT, and IFFT them then you will get an impulsive noise, because you have lost the phase information.

Rule 1: Except in the most trivial case record your data before analysing it.

Rule 2: Keep the original data until the end of the contract, and as long as possible afterwards.

Rule 3: Keep the tape record sheets as well

Rule 4: You always lose the vital piece of data

I have every tape record sheet from the last 12 years hidden in my filing cabinet, and, admittedly, a stack of tapes that we can't play back. But if we had to, we could find the right sort of tape recorder. Much cheaper than building a prototype and testing it!


Cheers

Greg Locock
 
Oh, and third octave values cannot be used to reconstruct time histories. They are summed levels in each band and do not have associated phase values, of any meaningful nature in the context of this job. Cheers

Greg Locock
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor