Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   C (http://www.programmingforums.org/forum60.html)
-   -   Convert .wav file into bytes (http://www.programmingforums.org/showthread.php?t=14495)

sandeshgade Nov 17th, 2007 11:53 AM

Convert .wav file into bytes
 
I was wondering if it is possible to write a program in C or C++(maybe even Visual Basic, as i m more experienced with that programming language) to convert a .wav file into bytes and save the same file as a text file.
I am a Visual Basic programmer and have little (almost no) knowledge about C or C++ programming. Please Help.

By far, I have achieved success in only loading up the .wav file in Visual Basic. I am still wanting to learn how to extract data from the wav file using Visual Basic.

Salem Nov 17th, 2007 12:31 PM

Re: Convert .wav file into bytes
 
All files can ultimately be viewed as arrays of bytes.

Look up fopen() and fgetc() and fread()

DaWei Nov 17th, 2007 12:35 PM

Re: Convert .wav file into bytes
 
A .wav file is already bytes. So are all other files. No conversion needed.

Bytes only have 256 possible values. If you output these values directly to most displays, you will get some characters (which are meaningless) and some undisplayable output which might result in nothing at all, or might cause some funny things to happen on the display.

If you want to REPRESENT the values of the bytes on a display, you'll need to decide what representation you want (decimal, hexadecimal, quadricentennialseptisesimus, whatever) and make an appropriate conversion, using an appropriate character set.

A .wav file is a file that contains descriptive information as well as binary representations of the sound. For more information, see here.

Harakim Nov 18th, 2007 4:06 AM

Re: Convert .wav file into bytes
 
If you're in Windows, use the command prompt.
Go to the directory and type 'mv <xxxxx.wav> <xxxxx.txt>', where xxxxx.wav is the filename. (Don't type the <> brackets or the quotes)

That's the short answer. You should read DaWei's post, because that concept is very powerful if you understand it.

kruptof Nov 18th, 2007 6:13 AM

Re: Convert .wav file into bytes
 
Quote:

Originally Posted by sandeshgade (Post 136977)
I am still wanting to learn how to extract data from the wav file using Visual Basic.

Perhaps you should take the time to understand the file format, which will clearly tell you the sequence of bytes and what they mean, just try Googling WAV

DaWei Nov 18th, 2007 6:42 AM

Re: Convert .wav file into bytes
 
An example of the format is in the link I posted.

sandeshgade Nov 18th, 2007 11:51 PM

Re: Convert .wav file into bytes
 
Erm, well I know that i .wav file is bytes, but what i want is to extract those bytes and save it as a text file or something. This step is just a small part of what i am exactly trying to do. I m trying my luck on .wav steganography and on the basis of a small programming framework that i have made, i guess extracting the bytes would be a crucial step to proceed further. Although i am still researching on how to do .wav steganography, i dont mind learning a few important concepts or skills that i might be able to incorporate in a .wav stegaography program.

By the way, thanks a lot for your instantaneous reply. I surely appreciate it. Erm, since you are more professional at this stuff than me, can i expect a bit of more knowledge about what i am trying to do from you.

Thanks again

DaWei Nov 19th, 2007 2:46 AM

Re: Convert .wav file into bytes
 
Sure you can, if you avail yourself of the help already given, and apply it. Structures for discerning the format information attached to the sound information are shown there, and are available all over the web.

You have shown no attempt at breaking a sweat, designing your task, writing some code, and asking for help with its problems.

WaltP Nov 19th, 2007 1:30 PM

Re: Convert .wav file into bytes
 
You know, if you show us an example of exactly what you want you could probably save yourself days of trying to explain it. It's already been 2 and no one understands it yet.

And what's an erm?

DaWei Nov 19th, 2007 1:54 PM

Re: Convert .wav file into bytes
 
An erm is a li'l thangy, that when it joins the FBI, becomes a G-erm.

Here's what you do. Go to that link and look at the header format. You'll notice that it's not fixed in size. Read enough of it to determine what its size IS. Then read the remainder of it. Then throw all that in the trash. Read each of the subsequent bytes and convert them to a hexadecimal or decimal or other based value, in a textual representation of that value.

Just don't ask for another bite of pablum until you show some effort.


All times are GMT -5. The time now is 3:17 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC