DSPRelated.com
Forums

32 bit integer WAV file writer?

Started by Mikial Chubarov September 24, 2007
Hi All,

Could someone please direct me to source code for generating 32 bit
integer WAV files?  Matlab C or C++ would be especially appreciated.

Thanks,

Mikial
Mikial Chubarov wrote:
> Hi All, > > Could someone please direct me to source code for generating 32 bit > integer WAV files? Matlab C or C++ would be especially appreciated. > > Thanks, > > Mikial >
In Matlab there's just a function (no source): wavwrite http://www.mathworks.com/access/helpdesk/help/techdoc/ref/wavwrite.html (i don't think usually you need to rewrite a function like that in matlab, so i doubt you can find any source in matlab source code) in C/C++ there's a great open source library: libsndfile http://www.mega-nerd.com/libsndfile/ otherwise you can just write yourself a routine, according to the wave file format: http://ccrma.stanford.edu/courses/422/projects/WaveFormat/ alternatively you can browse koders.com / google code search / codeproject.com and search for an open source sw and learn how to do that -- Clyde
in addition to above reply: sox might do the job (I have never tried,
though). At least the man page shows 32 bit as option.
http://linux.die.net/man/1/sox
"mnentwig" <mnentwig@elisanet.fi> wrote in message
news:TJGdnWhtw5pIKGrbnZ2dnUVZ_gednZ2d@giganews.com...
> in addition to above reply: sox might do the job (I have never tried, > though). At least the man page shows 32 bit as option. > http://linux.die.net/man/1/sox
You don't need all that junk. The wave file header structure is trivial; it is all explained in MSDN. VLV
On Sep 24, 9:13 am, "Vladimir Vassilevsky"
<antispam_bo...@hotmail.com> wrote:

> You don't need all that junk. The wave file header structure is trivial; it > is all explained in MSDN.
Well, at least, it CAN be trivial -- 44 bytes, if I remember correctly; specifying sampling rate, number of channels, bytes per sample, number of bytes in entire file, maybe one or two other fields that don't come to mind right now ... all in human-readable form. It can also be horrendously complex, if you choose to make it such. It is a Microsoft standard, after all. Greg

Greg Berchin wrote:

>>You don't need all that junk. The wave file header structure is trivial; it >>is all explained in MSDN. > > > Well, at least, it CAN be trivial -- 44 bytes, if I remember > correctly; specifying sampling rate, number of channels, bytes per > sample, number of bytes in entire file, maybe one or two other fields > that don't come to mind right now ... all in human-readable form. It > can also be horrendously complex, if you choose to make it such. It > is a Microsoft standard, after all.
There is also the wave format specifier, there can be many wave chunks with the different parameters in one file, etc. etc. hell knows who and why needs all of that. Here is the utterly lazy method for writing WAVs: 1. Create a wav with the required parameters in the standard Windows Sound Recorder. 2. Cut the header off. If you don't want to know what is the size of the header, ~100 bytes from the beginning of the file will do. 3. Attach that header to your file :) Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com
On Sep 24, 1:01 am, "Mikial Chubarov" <mikialchuba...@ieee.org> wrote:
> Hi All, > > Could someone please direct me to source code for generating 32 bit > integer WAV files? Matlab C or C++ would be especially appreciated. > > Thanks, > > Mikial
For up to 32 bits, Google : writewav.m readwav.m They are available and are script files. Dale B. Dalrymple http://dbdimages.com
Vladimir Vassilevsky wrote:
>
...
> > There is also the wave format specifier, there can be many wave chunks > with the different parameters in one file, etc. etc. hell knows who and > why needs all of that. > > Here is the utterly lazy method for writing WAVs: > > 1. Create a wav with the required parameters in the standard Windows > Sound Recorder. > > 2. Cut the header off. If you don't want to know what is the size of the > header, ~100 bytes from the beginning of the file will do. > > 3. Attach that header to your file :) >
To borrow the subject of another thread: what has happened to this group? I thought people here believed in technical correctness, answering questions, lets hear it for engineers, etc. So why all this stuff? Smiley notwithstanding, how does this help anyone? Very disappointing! Perhaps I should post some "utterly lazy" method for designing filters. I can think of a few! It will be OK because I follow it with a :-). Richard Dobson

Richard Dobson wrote:
> Vladimir Vassilevsky wrote: > >> >> Here is the utterly lazy method for writing WAVs: >> >> 1. Create a wav with the required parameters in the standard Windows >> Sound Recorder. >> >> 2. Cut the header off. If you don't want to know what is the size of >> the header, ~100 bytes from the beginning of the file will do. >> >> 3. Attach that header to your file :) >> > > To borrow the subject of another thread: what has happened to this > group? I thought people here believed in technical correctness, > answering questions, lets hear it for engineers, etc. So why all this > stuff? Smiley notwithstanding, how does this help anyone? Very > disappointing!
I have done it that way ~20 years ago. Surprisingly, it works just fine. What is the problem?
> Perhaps I should post some "utterly lazy" method for designing filters.
You are certainly welcome however R-B-J had already done that.
> I can think of a few! It will be OK because I follow it with a :-).
Stupid questions deserve the dumb answers. The invasion of the dolts is what is killing the group. Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com
Vladimir Vassilevsky wrote:
> > > Richard Dobson wrote: > >> Vladimir Vassilevsky wrote: >> >>> >>> Here is the utterly lazy method for writing WAVs: >>> >>> 1. Create a wav with the required parameters in the standard Windows >>> Sound Recorder. >>> >>> 2. Cut the header off. If you don't want to know what is the size of >>> the header, ~100 bytes from the beginning of the file will do. >>> >>> 3. Attach that header to your file :)
..
> I have done it that way ~20 years ago. Surprisingly, it works just fine. > What is the problem? >
It's wrong. You ~may~ get away with it if your ambitions do not extend beyond mono/stereo 8/16bit audio, and play programs are kind enough not to pay much attention to the probably wrong RIFF and data chunk duration fields in your hacked header. Methods devised 20 years ago may need to be updated. Oh, and Sound Recorder does not support any 32bit sample formats.
> > Stupid questions deserve the dumb answers. The invasion of the dolts is > what is killing the group. >
What was stupid about it? 32bit int is sufficiently rare for soundfiles that very little casually-written software handles it (which is why everyone is referred to libsndfile, sooner or later). Even the suggested "writewav.m" is inadequate (written in 1998, so predates WAVEFORMATEXTENSIBLE). And of course (as of the last time I looked at it) the resident matlab wavwrite.m function doesn't know about it either. Richard Dobson