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/help.../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 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.
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.
>>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.
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
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 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 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.
> 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? ...
Some very knowledgeable people value sarcasm and look-how-smart-I-am
(wink, wink) comments more. Think of it as the left-handed-monkey-wrench
or let's-amuse-ourselves-by-mocking-newbies syndrome. I was never fond
of those initiation rituals, from either direction.
Jerry
--
Engineering is the art of making what you want from things you can get.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
> Stupid questions deserve the dumb answers. The invasion of the dolts is
> what is killing the group.
We've always had our share of dolts. Stupid questions deserve honest (if
painful) statements about why they make no sense. Dumb answers drag the
group down, along with two faults I'm guilty of: insufficient snipping,
and changing the subject without changing the subject line.
Jerry
--
Engineering is the art of making what you want from things you can get.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Vladimir Vassilevsky wrote:
> [snip]
>
> Stupid questions deserve the dumb answers. The invasion of the dolts is
> what is killing the group.
>
*NO*
_your_ 'answers' are sample of what is wrong!
*YOU* fail to distinguish between _pupils_ asking comp.dsp to do their
homework and *STUDENTS* who innocently ask "dumb" questions out of
innocent ignorance.
Before replying, please study differences between/among
definition/connotation of student/pupil.
>
> *YOU* fail to distinguish between _pupils_ asking comp.dsp to do their
> homework and *STUDENTS* who innocently ask "dumb" questions out of
> innocent ignorance.
There is no difference. Ignorance is always ignorance and demonstrating
ignorance is equal to stupidity. Worthwhile folks are trying to sort
out their problems themself. Have you seen Avins, or Wescott, or RBJ, or
Lyons, or Andor, or Alnor or whoever asking stupid questions?
> Before replying, please study differences between/among
> definition/connotation of student/pupil.
> Otherwise will class you with ...
My firm belief is the best way to learn how to swim is to be thrown out
of the boat.
>
>
> Richard Owlett wrote:
>
>>
>> *YOU* fail to distinguish between _pupils_ asking comp.dsp to do their
>> homework and *STUDENTS* who innocently ask "dumb" questions out of
>> innocent ignorance.
>
>
> There is no difference. Ignorance is always ignorance and demonstrating
> ignorance is equal to stupidity. Worthwhile folks are trying to sort
> out their problems themself. Have you seen Avins, or Wescott, or RBJ, or
> Lyons, or Andor, or Alnor or whoever asking stupid questions?
>
>> Before replying, please study differences between/among
>> definition/connotation of student/pupil.
>> Otherwise will class you with ...
>
>
> My firm belief is the best way to learn how to swim is to be thrown out
> of the boat.
>
>
> VLV
Suspect you are _pupil_ not *STUDENT*
Can you prove otherwise?
I've demonstrated *IGNORANCE*
BUT are you a 'student'?
[I DOUBT IT]
Vladimir Vassilevsky <antispam_bogus@hotmail.com> writes:
> [...]
> My firm belief is the best way to learn how to swim is to be thrown
> out of the boat.
I would say you first give a few lessons, THEN throw them out of the
boat.
And tell them ahead of time this is what is going to happen - that
way they'll pay more attention if they're not stupid.
--
% Randy Yates % "How's life on earth?
%% Fuquay-Varina, NC % ... What is it worth?"
%%% 919-577-9882 % 'Mission (A World Record)',
%%%% <yates@ieee.org> % *A New World Record*, ELO http://www.digitalsignallabs.com
> ... Have you seen Avins, or Wescott, or RBJ, or
> Lyons, or Andor, or Alnor or whoever asking stupid questions?
Vladimir,
I'm pleased that you don't think my questions stupid. (I know that some
of my answers are!) You may also have noticed that I often trouble to
answer questions that you think are stupid, or at least trying to
explain the question's flaws. "Are we there yet" coming from the back
seat is a stupid question when traveling down the road at speed. There
are other circumstances that make the same question reasonable.
I am often tempted to the same sarcasm that you do so well. Knowing that
the momentary satisfaction I would derive from it comes at the expense
of the group dynamic here, I usually refrain.
Jerry
--
Engineering is the art of making what you want from things you can get.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Vladimir Vassilevsky 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.
For a sufficiently small definition of "works just fine". WAV files have
size markers at several places, and your method will only work for
sufficiently simple^Wstupid WAV readers (for example those that simply
do a seek(44) and read until EOF).
Actually, Windows Media Player refuses to open WAV files I wrote
although I think I conform to the specs. Didn't get around debugging
that, though: I use them for temporary storage only, and Audacity, Sound
Recorder and sox read them just fine :-)
>>>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.
>
>
> For a sufficiently small definition of "works just fine". WAV files have
> size markers at several places, and your method will only work for
> sufficiently simple^Wstupid WAV readers (for example those that simply
> do a seek(44) and read until EOF).
>
> Actually, Windows Media Player refuses to open WAV files I wrote
> although I think I conform to the specs. Didn't get around debugging
> that, though: I use them for temporary storage only, and Audacity, Sound
> Recorder and sox read them just fine :-)
It worked fine with the WMP and WinAmp too (although I would not bet
about the latest versions). However you need to make sure that your file
is not shorter then the original; it is OK if the file is longer.
> Didn't get around debugging
> that, though: I use them for temporary storage only, and Audacity, Sound
> Recorder and sox read them just fine :-)
Audacity for instance uses libsndfile.
I suspect that the reason WMP doesn't like your WAV file is that
you have one of more of the following:
- more than 2 channels
- PCM bitwidths > 16
for which WMP insists on the WAVFORMATEXTENSIBLE style WAV files.
Erik
--
-----------------------------------------------------------------
Erik de Castro Lopo
-----------------------------------------------------------------
" Baldie is such a wonderful villain
The Linux/OSS community could not possibly ask for a better villain than
our man Baldie. He is absolutely perfect for the part. Just look at his
creds: 1) Physically repulsive; 2) Morally bankrupt; 3) Megalomaniacal;
4) Possessed of a truly nasty, abusive disposition; 5) Prone to Hitlerian
ranting; 6) Stalinesque paranoia... The list just goes on and on. The man
has the gift of true despicability, no doubt about it. If it weren't for
Baldie we'd be stuck with Bilgatus' merely vacuuous and creepy persona
for an anthropomorphization of the Evil Empire -- tepid at best."
-- Matthew Alton in LinuxToday.com on Steve Balmer
>>Erik de Castro Lopo wrote:
>>> This is why you should use a library like
>
>>Well _THANKS_ for your library, it saved me a LOT of time
>
> Same here
Thanks for the thanks. Now if I could just get all these people
who insist on writing their own WAV file writers, my life would
be somewhat easier :-).
Erik (who has spent far too much time working around broken WAV
file headers).
--
-----------------------------------------------------------------
Erik de Castro Lopo
-----------------------------------------------------------------
"I'm not even an atheist so much as I am an antitheist; I not
only maintain that all religions are versions of the same
untruth, but I hold that the influence of churches, and the
effect of religious belief, is positively harmful."
-- Christopher Hitchens in "Letters to a Young Contrarian" 2001
Erik de Castro Lopo wrote:
> Stefan Reuther wrote:
>>Actually, Windows Media Player refuses to open WAV files I wrote
>>although I think I conform to the specs.
>
> This is why you should use a library like
> http://www.mega-nerd.com/libsndfile/
> (of which I am the main author).
If I would redo my toolchain from scratch, I would probably do that. My
WAV I/O is part of a codec/filter test framework I started few years
ago, grew in little steps to 100x its originally intended size, and is
in production use although never intended to - but each evolution step
small enough that I said "just writing this little thing down is much
less effort than researching for an existing solution". I think you all
know this game :-)
> I suspect that the reason WMP doesn't like your WAV file is that
> you have one of more of the following:
>
> - more than 2 channels
> - PCM bitwidths > 16
Nope (2x16 bit is the maximum I handle). But actually I don't really
care. I mainly read others' WAVs, which works fine. If Audacity can read
my temporary files, that's nice because I don't have to write a custom
editor (like my terminal program saving its transcripts in HTML so I
don't need a custom viewer), but not a prime objective.