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!

Creating a playable WAV file from data or equation input 1

Status
Not open for further replies.

Wicsteve

Mechanical
Dec 10, 2001
109
I'm looking for a means to create a playable *.WAV file from either some sort of data list or equation. I'd like to combine and create a data list of combined sine waves together (creating a sawtooth, triangular, or sauare waves) then listen to the resulting noise from the data list (using perhaps EXCEL, TXT, or MATLAB).

Does anyone have a recommendation of how to do this?
 
Replies continue below

Recommended for you

What Greg said, except the file is hex/binary, not text. Wikipedia has a lot of info on the structure of .wav files.
 
If you are a competent (possibly even adventurous) C programmer, the Microsoft WAVE format is published. Here is someone's fairly well annotated copy of it:

[link]https://ccrma.stanford.edu/courses/422/projects/WaveFormat/[/url]

Be prepared to think in terms of bits and bytes though, possibly even endianness (although not probably an issue unless you want to write AIFF files too). You might want to hex dump a small working one to see what's inside. It'll help you to understand the format.

- Steve
 
I apologise, wav either used to be ascii format or I used to be a lot cleverer than I am now, or both, either way I wrote a qbasic program to do exactly what I said.

Cheers

Greg Locock


New here? Try reading these, they might help FAQ731-376
 
Greg,

wav (and other binary files) still look like ASCII when pulled up in Notepad, or you can read them in bytes with a program, just like ASCII.

If you know where the wav file header ends, you can copy and paste with Notepad or however you want. But don't use Word - it'll insert formatting in normal mode.

Best to you,

Goober Dave

Haven't see the forum policies? Do so now: Forum Policies
 
DR - you mean the header shows up in ASCII? The data is in binary, though, at least in examples I could find quickly (wikipedia has several, and Steve's excellent link shows it that way too). I do recall some kind of sound file that had human-readable (decimal number) inputs...but I too may be suffering from any number of maladies, including Friday-itis and LBL (Low Beer Levels).
 
btrueblood,

Try opening up a wav file in a text-only editor of your choice (it turns out Notepad puts extra stuff in there when saving nowadays). Even though you see jibberish, you can copy and paste that jibberish into another file without disturbing it, as long as you know where you are. Agreed, it's tough to interpret.

I used to have a disk patcher that would show you the hex for each byte and the ASCII to the right. It was even better, but the old thing has disappeared... If I find it, I'll post it here -- I do remember it was freeware.

Best to you,

Goober Dave

Haven't see the forum policies? Do so now: Forum Policies
 
The problem with some of these file formats is that while *most* tools/players will like them, a stray bit here and there may make other tools hate them. A two goal problem: #1, make a sound, whatever from your PC's default WAV player; #2 make the code robust and conforming to their standard in every way.

- Steve
 
<soapbox>
Forget Windows, forget the curse of the double-click that tries to guess what you want. A standard (non-interpretive) text or binary editor works wonders.
n the real World, it's emacs or vi.
</soapbox>

Most "interesting" stuff from any binary file can be found using "strings".

- Steve
 
I feel like we've lost the OP and are now talking about my job.

- Steve
 
"Even though you see jibberish"

Yes, that is what binary/hex files look like in a text editor.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor