DSPRelated.com
Forums

Compress/Decompress Wave file to MP3 and vice versa

Started by Unknown April 17, 2006
Hello. Sorry to disturb you all. I hope to get your opinion. For your
information, I have a Visual C++ 6.0 software to record and playback
human speech. All the speech is recorded with sampling rate of 16kHz in
wave file format. Each wave file size is 188kbytes. I have 20 wave
files in each practice or each usage of software. And, I need to save
all these 20 wave files into a single floppy disk (1.44 Mbytes).

Total size of 20 wave files = 20*188k = 3,760,000 bytes
Total floppy disk needed = (3,760,000)/1,440,000 = 2.6 floppy disks
But, I must save all the 20 wave files into a single floppy disk

I hope it can work like this: save the data as a wave file in the
temporary directory and then convert wave file to MP3 file in your
floppy disk. To load a file, convert the mp3 file to wave file in the
temporary directory and then load the wave file to the memory.
Can this method enable me to save all 20 wave files in a single floppy
disk?

I don't know how to insert the encoding/decoding program codes into
my current software without causing any new bugs.

Or, other than the MP3 compression method, do you have another method
or idea of minimizing the size of each wave file? Please tell me.

Hope to hear you soon, thanks.

<space.oca@gmail.com> wrote in message
news:1145261306.489910.204460@u72g2000cwu.googlegroups.com...
> Hello. Sorry to disturb you all. I hope to get your opinion. For your > information, I have a Visual C++ 6.0 software to record and playback > human speech. All the speech is recorded with sampling rate of 16kHz in > wave file format. Each wave file size is 188kbytes. I have 20 wave > files in each practice or each usage of software. And, I need to save > all these 20 wave files into a single floppy disk (1.44 Mbytes). > > Total size of 20 wave files = 20*188k = 3,760,000 bytes > Total floppy disk needed = (3,760,000)/1,440,000 = 2.6 floppy disks > But, I must save all the 20 wave files into a single floppy disk > > I hope it can work like this: save the data as a wave file in the > temporary directory and then convert wave file to MP3 file in your > floppy disk. To load a file, convert the mp3 file to wave file in the > temporary directory and then load the wave file to the memory. > Can this method enable me to save all 20 wave files in a single floppy > disk? > > I don't know how to insert the encoding/decoding program codes into > my current software without causing any new bugs. > > Or, other than the MP3 compression method, do you have another method > or idea of minimizing the size of each wave file? Please tell me. > > Hope to hear you soon, thanks. >
What is the size of the data samples stored in the .wav file? If it is 16-bit you can cut the size in half by converting to mu-law 8-bit samples. Also, you only need an 8kHz sample rate for speech. This means you can store 1,440,000*8/(8*8,000) = 180 seconds on one floppy. Try a google of "convert .wav to mu-law" to find software that will do the conversion. If you convert to .mp3 you can probably use a 16kbps code rate. This means you can store 1,440,000*8/16,000 = 720 seconds of sound on one floppy. Search for lame encoder to find open source software to playback mp3s. -Clark
Not a reply to your query - but a request. is it possible you can share
the VC++ project including the code for this? i am trying to learn to
do (in particular the access to the sound card/device) this. thanks.
regards, srini.

<space.oca@gmail.com> wrote in message 
news:1145261306.489910.204460@u72g2000cwu.googlegroups.com...
> Hello. Sorry to disturb you all. I hope to get your opinion. For your > information, I have a Visual C++ 6.0 software to record and playback > human speech. All the speech is recorded with sampling rate of 16kHz in > wave file format. Each wave file size is 188kbytes. I have 20 wave > files in each practice or each usage of software. And, I need to save > all these 20 wave files into a single floppy disk (1.44 Mbytes). > > Total size of 20 wave files = 20*188k = 3,760,000 bytes > Total floppy disk needed = (3,760,000)/1,440,000 = 2.6 floppy disks > But, I must save all the 20 wave files into a single floppy disk > > I hope it can work like this: save the data as a wave file in the > temporary directory and then convert wave file to MP3 file in your > floppy disk. To load a file, convert the mp3 file to wave file in the > temporary directory and then load the wave file to the memory. > Can this method enable me to save all 20 wave files in a single floppy > disk? > > I don't know how to insert the encoding/decoding program codes into > my current software without causing any new bugs. > > Or, other than the MP3 compression method, do you have another method > or idea of minimizing the size of each wave file? Please tell me. > > Hope to hear you soon, thanks. >
Have you tried to zip all of the files together? The result may just fit on your floppy. One variant of the .wav format actually allows for ADPCM - maybe this will compress the files enough for you. Clay
space.oca@gmail.com wrote:
> Hello. Sorry to disturb you all. I hope to get your opinion. For your > information, I have a Visual C++ 6.0 software to record and playback > human speech. All the speech is recorded with sampling rate of 16kHz in > wave file format. Each wave file size is 188kbytes. I have 20 wave > files in each practice or each usage of software. And, I need to save > all these 20 wave files into a single floppy disk (1.44 Mbytes). > > Total size of 20 wave files = 20*188k = 3,760,000 bytes > Total floppy disk needed = (3,760,000)/1,440,000 = 2.6 floppy disks > But, I must save all the 20 wave files into a single floppy disk > > I hope it can work like this: save the data as a wave file in the > temporary directory and then convert wave file to MP3 file in your > floppy disk. To load a file, convert the mp3 file to wave file in the > temporary directory and then load the wave file to the memory. > Can this method enable me to save all 20 wave files in a single floppy > disk? > > I don't know how to insert the encoding/decoding program codes into > my current software without causing any new bugs. > > Or, other than the MP3 compression method, do you have another method > or idea of minimizing the size of each wave file? Please tell me. > > Hope to hear you soon, thanks.
This must be some sort of class assignment. I've had an extended email conversation on the same subject. Zipping the file is out because third-party software is nominally disallowed (but what about an MP3 encoder?). I suspect that it is a puzzle whose key is a remark the instructor made at some point. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295; ~~~*Conversation log*~~~ Mr. Jerry Avins, Hello. Sorry to disturb you again. I hope to get your opinion. For your information, I have developed a Visual C++ 6.0 software to record and playback human speech. All the speech is recorded with sampling rate of 16kHz in wave file format. Each wave file size is 188kbytes. I have 20 wave files in each practice or each usage of software. And, I need to save all these 20 wave files into a single floppy disk (1.44 Mbytes). Total size of 20 wave files = 20*188k = 3,760,000 bytes Total floppy disk needed = (3,760,000)/1,440,000 = 2.6 floppy disks But, I must save all the 20 wave files into a single floppy disk, what methods should I use? Can I maintain the wave file format during the recording/playing during the usage of software, and change the wave files into MP3 file format when I want to save these files into floppy disk? It is called MP3 compression method, right? But, I don&rsquo;t know where to obtain the encoding/decoding source codes. I don&rsquo;t know how to insert the encoding/decoding program codes into my current software. Can you help me? Can you please tell me what should I do? Or, other than the MP3 compression method, do you have another method or idea of minimizing the size of each wave file? Please tell me. Hope to hear you soon, thanks ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Isabella, By asking me, you limit yourself to my knowledge alone. If you ask in a newsgroup, you would receive the benefit of everyone's knowledge. You seem to want lossless compression (i.e. compression that allows exact reconstruction); MP3 doesn't allow that. Compression will certainly fit your files on two disks, with room to spare for a decompression program. Fitting them on only one may be possible, but it isn't clear to me that you can. Your question is really about lossless data compression. If you use MAC OS or Windows, a common file compression format is zip. (Also, on the MAC, stuffit). On Linux or Unix, it is gzip or tar. Utilities for those formats are available for both platforms. Whether one of those will compress enough for you isn't clear; the degree of compression that can be achieved depends on the data being compressed. Windows can unzip zipped files. Win-Zip has what is supposed to be a friendly user interface. It is available for free trial. http://www.winzip.com/ I use an old version of PKZIP, a DOS command-line program because I have it. They offer a free ZIP reader you can load onto the computer that will need to unzip your floppy. You can get free zip/unzip programs from http://www.7-zip.org/ (claims high compression ratio) and many other links you will find at http://www.google.com/search?&q=zip+utility Gzip uses its own format and might possibly compress more. http://www.gzip.org/ There a few tricks you can use if compression nearly but not quite succeeds. 1. Since your files have the same length and recording properties, they have identical headers. You can strip all the headers and send one copy of it and the headerless files, then attach the header at the receiving end. You might save some tens of bytes that way. 2. Be sure to compress your files as a single "archive". That is more compact than compressing the files separately. Jerry ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Mr. Jerry Avins, Thank you very much for your reply, I appreciate. I cant use third party software as I need to have the compression algoritms inside my software itself. I am now using 16kHz as sampling rate. Even if I change to 8kHz, the size only reduced by half. But, in order to have all 20 wave files saved into a single floppy disk, I must have at least 62% size reduction of 188kB. I cant use 8 bits. My software works by measuring human speech's magnitude (energy) and give some scoring based on the voice magnitude. If I use 8 bits, I guess the magnitude measurement will be affected a lot, isnt it? I guess I can use lossy compression method as my software need to measure human voice magnitude of whole sentence and not measuring the syllable by syllable. Please correct me if I am wrong and hope to have your suggestion of what methods or approaches I can use. Hope to hear you. Thank you. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Isabella, It seems to me that you are laboring under artificial constraints that may be designed to force you to a solution hinted at by whoever imposed those constraints, about which I can have no ideas. PKzip was standard compression back when the smallest floppies were 5-1/4"; every Windows program since 2000 has unzip capability in the operating system. Most computers nowadays can read and write CDs; they hold 650 megabytes. I think you've been given a puzzle to solve, not a real problem. I'm not particularly interested. Jerry ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Mr. Jerry Avins, I hope it can work like this: It would work like this: save the data as a wave file in the tempory directory and then convert wave file to MP3 file in your floppy disk. To load a file, convert the mp3 file to wave file in the tempory directory and then load the wave file to the memory. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Isabella, ... Will you write the software to convert wave to MP3 and back? If not, why is third-party MP3 software more kosher than third-party ZIP software? Who laid these ridiculous constraints on you, anyway? Jerry
space.oca@gmail.com wrote:
> Hello. Sorry to disturb you all. I hope to get your opinion. For your > information, I have a Visual C++ 6.0 software to record and playback > human speech. All the speech is recorded with sampling rate of 16kHz in > wave file format. Each wave file size is 188kbytes. I have 20 wave > files in each practice or each usage of software. And, I need to save > all these 20 wave files into a single floppy disk (1.44 Mbytes).
You haven't made clear your purpose in saving these 20 wave files. If it is to exactly reconstitute them again, then IMHO there's no way to do this. If your purpose is to get back 20 wave files that "sound like" the originals, then MP3 compression may well do what you need. My point is that some compression methods are lossless and some introduce data loss to the signal -- it may be an acceptable loss, but it's a loss nonetheless. cheers, jerry
space.oca@gmail.com wrote:

> Hello. Sorry to disturb you all. I hope to get your opinion. For your > information, I have a Visual C++ 6.0 software to record and playback > human speech. All the speech is recorded with sampling rate of 16kHz in > wave file format. Each wave file size is 188kbytes. I have 20 wave > files in each practice or each usage of software. And, I need to save > all these 20 wave files into a single floppy disk (1.44 Mbytes). > > Total size of 20 wave files = 20*188k = 3,760,000 bytes > Total floppy disk needed = (3,760,000)/1,440,000 = 2.6 floppy disks > But, I must save all the 20 wave files into a single floppy disk > > I hope it can work like this: save the data as a wave file in the > temporary directory and then convert wave file to MP3 file in your > floppy disk. To load a file, convert the mp3 file to wave file in the > temporary directory and then load the wave file to the memory. > Can this method enable me to save all 20 wave files in a single floppy > disk? > > I don't know how to insert the encoding/decoding program codes into > my current software without causing any new bugs. > > Or, other than the MP3 compression method, do you have another method > or idea of minimizing the size of each wave file? Please tell me. > > Hope to hear you soon, thanks. >
Hi there, If this is indeed a class assignment then I would say that ADPCM is probably your answer. It seems to me that the factor of 2.6 is quite telling. If it were 2.0 the solution would be simple, use 8 bit differences giving you a ratio 2:1. As it is you could use 6 bit differences which would *just* be enough (2.67:1 maybe this is what you are *meant* to do?) but a slight pain to implement (faffing around with bit manipulation), use straight 4 bit which remembering back to when I did the same thing for a class assignment sounded rubbish, or use 4 bit ADPCM, which will sound fine. Richard
Anonymous wrote:
> <space.oca@gmail.com> wrote in message > news:1145261306.489910.204460@u72g2000cwu.googlegroups.com... > > Hello. Sorry to disturb you all. I hope to get your opinion. For your > > information, I have a Visual C++ 6.0 software to record and playback > > human speech. All the speech is recorded with sampling rate of 16kHz in > > wave file format. Each wave file size is 188kbytes. I have 20 wave > > files in each practice or each usage of software. And, I need to save > > all these 20 wave files into a single floppy disk (1.44 Mbytes). > > > > Total size of 20 wave files = 20*188k = 3,760,000 bytes > > Total floppy disk needed = (3,760,000)/1,440,000 = 2.6 floppy disks > > But, I must save all the 20 wave files into a single floppy disk > > > > I hope it can work like this: save the data as a wave file in the > > temporary directory and then convert wave file to MP3 file in your > > floppy disk. To load a file, convert the mp3 file to wave file in the > > temporary directory and then load the wave file to the memory. > > Can this method enable me to save all 20 wave files in a single floppy > > disk? > > > > I don't know how to insert the encoding/decoding program codes into > > my current software without causing any new bugs. > > > > Or, other than the MP3 compression method, do you have another method > > or idea of minimizing the size of each wave file? Please tell me. > > > > Hope to hear you soon, thanks. > > > > What is the size of the data samples stored in the .wav file? If it is > 16-bit you can cut the size in half by converting to mu-law 8-bit samples. > Also, you only need an 8kHz sample rate for speech. This means you can store > 1,440,000*8/(8*8,000) = 180 seconds on one floppy. Try a google of "convert > .wav to mu-law" to find software that will do the conversion. > > If you convert to .mp3 you can probably use a 16kbps code rate. This means > you can store 1,440,000*8/16,000 = 720 seconds of sound on one floppy. > Search for lame encoder to find open source software to playback mp3s. > > -Clark
Clark, Thank you for your reply, appreciate. If I reduce sampling rate from 16k to 8k, I will reduce 50% size but I need at least 62% reduction in order to save all 20 files in a single floppy disk. Reducing bits from 16 to 8, I am afraid that this will influence alots of the quality issue. I have searched the lame encoder source code but I dont know how to implement it into my current software? Can you please give me some guidance? Please help, please.
Hi, Mr Clay.
Yes, I have tried to zip it before and the WinZip reduced each wave
file from 188k to 91k. But I need at least more than 62% in order to
reach purpose.
Sorry, I dont understand what you mean by "ADPCM - maybe this will
compress the files enough for you. ", hope you dont mind to elaborate.
thanks a lot

Hi, Mr Jerry Avin, thank you for your reply.
Can you elaborate more on how to incorporate 'MP3 encoder" into other
part of software? Thanks