Hi all, I've recorded a wav file at 8KHz with an 8bit sample size. I now want to write code to convert the data from the wav file to PCM, so that I can send it over my ISDN Card to a phone. I've read that a wav file is basicaly the PCM data with some headers. If this is true, it shouldnt be that difficult to convert it. However, I havent been able to figure out how to do this.... Could someone please help me out...
WAV to PCM conversion
Started by ●May 11, 2006
Reply by ●May 11, 20062006-05-11
Reply by ●May 12, 20062006-05-12
Suneeel@gmail.com wrote:> > Hi all, > > I've recorded a wav file at 8KHz with an 8bit sample size. I now want > to write code to convert the data from the wav file to PCM, so that I > can send it over my ISDN Card to a phone. I've read that a wav file is > basicaly the PCM data with some headers. If this is true, it shouldnt > be that difficult to convert it. However, I havent been able to figure > out how to do this....Don't convert the file, just read it as it is using http://www.mega-nerd.com/libsndfile/ Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo +-----------------------------------------------------------+ "The lusers I know are so clueless, that if they were dipped in clue musk and dropped in the middle of pack of horny clues, on clue prom night during clue happy hour, they still couldn't get a clue." --Michael Girdwood, in the monastery
Reply by ●May 13, 20062006-05-13
Suneeel@gmail.com wrote:> Hi all, > > I've recorded a wav file at 8KHz with an 8bit sample size. I now want > to write code to convert the data from the wav file to PCM, so that I > can send it over my ISDN Card to a phone. I've read that a wav file is > basicaly the PCM data with some headers. If this is true, it shouldnt > be that difficult to convert it. However, I havent been able to figure > out how to do this.... > > Could someone please help me out... >You may want to look at the Sox utility at sourcefourge. Cheers, David
Reply by ●May 14, 20062006-05-14
Suneeel@gmail.com wrote:> Hi all, > > I've recorded a wav file at 8KHz with an 8bit sample size. I now want > to write code to convert the data from the wav file to PCM, so that I > can send it over my ISDN Card to a phone. I've read that a wav file is > basicaly the PCM data with some headers. If this is true, it shouldnt > be that difficult to convert it. However, I havent been able to figure > out how to do this.... > > Could someone please help me out...Funny, it seems that I'm the only one out there who wrote his own input/output .wav functions. They are quite simple and can read and write 8-bit, 16-bit and 32-bit IEEE-754 float format and output the PCM data to a bidimensional array of doubles as well as an array with the content of each tag in it. Drop me a mail if you'd like to see the code.
Reply by ●May 15, 20062006-05-15
Michel Rouzic wrote: ..> Funny, it seems that I'm the only one out there who wrote his own > input/output .wav functions. They are quite simple and can read and > write 8-bit, 16-bit and 32-bit IEEE-754 float format and output the PCM > data to a bidimensional array of doubles as well as an array with the > content of each tag in it. Drop me a mail if you'd like to see the code. >Well , not quite the only one! Eric has already posted about libsndfile, which should be enough to dissuade most people from ever needing to roll their own. I have my own library as I don't just use file formats, I design them too, - it may get published some day! There are many other open-source libraries "out there", mostly in C, but some in C++ (e.g. in Perry Cook's "STK"). Best to ask on the music-dsp list for more information, as those folk use such things all the time. Almost always, the answer is libsndfile, unless your requirements are especially esoteric. Richard Dobson
Reply by ●May 15, 20062006-05-15
Michel Rouzic wrote:> > Funny, it seems that I'm the only one out there who wrote his own > input/output .wav functions. They are quite simple and can read and > write 8-bit, 16-bit and 32-bit IEEE-754 float format and output the PCM > data to a bidimensional array of doubles as well as an array with the > content of each tag in it. Drop me a mail if you'd like to see the code.One of the things your WAV parser probably doesn't have is code that works around the vast number of broken and malformed files that are generated by software people rolled themselves. libsndfile has this. If you really want to roll your own go for it. If it comes to writing, please use libsndfile because if you make a mistake I might have to add code to work around the malformed files you create. Its not just smaller developers who get this wrong either. There are some well know pieces of software which have versions which create bad files. Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo +-----------------------------------------------------------+ "One of Subversions biggest weaknesses is its lack of adequate internal tracking for merges." -- William Nagle in "Subversion Version Control"
Reply by ●May 16, 20062006-05-16
"Michel Rouzic" <Michel0528@yahoo.fr> wrote in message news:1147652536.653509.187020@y43g2000cwc.googlegroups.com...> > Suneeel@gmail.com wrote: >> Hi all, >> >> I've recorded a wav file at 8KHz with an 8bit sample size. I now want >> to write code to convert the data from the wav file to PCM, so that I >> can send it over my ISDN Card to a phone. I've read that a wav file is >> basicaly the PCM data with some headers. If this is true, it shouldnt >> be that difficult to convert it. However, I havent been able to figure >> out how to do this.... >> >> Could someone please help me out... > > Funny, it seems that I'm the only one out there who wrote his own > input/output .wav functions. They are quite simple and can read and > write 8-bit, 16-bit and 32-bit IEEE-754 float format and output the PCM > data to a bidimensional array of doubles as well as an array with the > content of each tag in it. Drop me a mail if you'd like to see the code.It's one of those things where it can be very simple to read a few types of wave files, but to really handle all the permutations, corner cases, errors, etc. gracefully it becomes a much bigger project.
Reply by ●May 16, 20062006-05-16
I must agree with Erik. Once you use libsndfile once and find how easy it is, I can see few reasons not to use it whenever you want to read or write WAV files. I prefer to think of sampled data as being floating point rather than integers, and with libsndfile, I don't ever get exposed to the underlying data format. It's just as easy to read the data as integers if you prefer. Cheers, Ross-c
Reply by ●May 16, 20062006-05-16
Ross Clement (Email address invalid - do not use) wrote:> ... I prefer to think of sampled data as being floating > point rather than integers, ...Do you suppose there will ever be a floating-point ADC? Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������






