FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > DSP

DSP comp.dsp newsgroup, mailing list

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-24-2007, 09:01 AM
Mikial Chubarov
Guest
 
Posts: n/a
Default 32 bit integer WAV file writer?

Hi All,

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

Thanks,

Mikial
Reply With Quote
  #2 (permalink)  
Old 09-24-2007, 12:21 PM
Clyde
Guest
 
Posts: n/a
Default Re: 32 bit integer WAV file writer?

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 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/42...ts/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
Reply With Quote
  #3 (permalink)  
Old 09-24-2007, 02:04 PM
mnentwig
Guest
 
Posts: n/a
Default Re: 32 bit integer WAV file writer?

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
Reply With Quote
  #4 (permalink)  
Old 09-24-2007, 02:13 PM
Vladimir Vassilevsky
Guest
 
Posts: n/a
Default Re: 32 bit integer WAV file writer?


"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



Reply With Quote
  #5 (permalink)  
Old 09-24-2007, 03:34 PM
Greg Berchin
Guest
 
Posts: n/a
Default Re: 32 bit integer WAV file writer?

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

Reply With Quote
  #6 (permalink)  
Old 09-24-2007, 03:54 PM
Vladimir Vassilevsky
Guest
 
Posts: n/a
Default Re: 32 bit integer WAV file writer?



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


Reply With Quote
  #7 (permalink)  
Old 09-24-2007, 05:19 PM
dbd
Guest
 
Posts: n/a
Default Re: 32 bit integer WAV file writer?

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

Reply With Quote
  #8 (permalink)  
Old 09-24-2007, 06:21 PM
Richard Dobson
Guest
 
Posts: n/a
Default Re: 32 bit integer WAV file writer?

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



Reply With Quote
  #9 (permalink)  
Old 09-24-2007, 06:31 PM
Vladimir Vassilevsky
Guest
 
Posts: n/a
Default Re: 32 bit integer WAV file writer?



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
Reply With Quote
  #10 (permalink)  
Old 09-24-2007, 09:10 PM
Richard Dobson
Guest
 
Posts: n/a
Default Re: 32 bit integer WAV file writer?

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

Reply With Quote
  #11 (permalink)  
Old 09-24-2007, 09:26 PM
Jerry Avins
Guest
 
Posts: n/a
Default Re: 32 bit integer WAV file writer?

Richard Dobson wrote:

...

> 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.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Reply With Quote
  #12 (permalink)  
Old 09-24-2007, 09:32 PM
Jerry Avins
Guest
 
Posts: n/a
Default Re: 32 bit integer WAV file writer?

Vladimir Vassilevsky wrote:

...

> 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.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Reply With Quote
  #13 (permalink)  
Old 09-25-2007, 12:59 AM
Richard Owlett
Guest
 
Posts: n/a
Default Re: 32 bit integer WAV file writer?

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.

Otherwise will class you with ...
Reply With Quote
  #14 (permalink)  
Old 09-25-2007, 01:42 AM
Vladimir Vassilevsky
Guest
 
Posts: n/a
Default Re: 32 bit integer WAV file writer?



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
Reply With Quote
  #15 (permalink)  
Old 09-25-2007, 01:58 AM
Richard Owlett
Guest
 
Posts: n/a
Default Re: 32 bit integer WAV file writer?

Vladimir Vassilevsky wrote:

>
>
> 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]


Reply With Quote
  #16 (permalink)  
Old 09-25-2007, 02:05 AM
Vladimir Vassilevsky
Guest
 
Posts: n/a
Default Re: 32 bit integer WAV file writer?



Richard Owlett wrote:


>
> Suspect you are _pupil_ not *STUDENT*
>
> Can you prove otherwise?
>
> I've demonstrated *IGNORANCE*
> BUT are you a 'student'?
> [I DOUBT IT]


Would you mind if I add you to the plonk file?

VLV


Reply With Quote
  #17 (permalink)  
Old 09-25-2007, 04:02 AM
Randy Yates
Guest
 
Posts: n/a
Default Re: 32 bit integer WAV file writer?

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
Reply With Quote
  #18 (permalink)  
Old 09-25-2007, 03:02 PM
Jerry Avins
Guest
 
Posts: n/a
Default Re: 32 bit integer WAV file writer?

Vladimir Vassilevsky wrote:

> ... 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.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Reply With Quote
  #19 (permalink)  
Old 09-25-2007, 05:55 PM
Stefan Reuther
Guest
 
Posts: n/a
Default Re: 32 bit integer WAV file writer?

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 :-)


Stefan

Reply With Quote
  #20 (permalink)  
Old 09-25-2007, 06:57 PM
Vladimir Vassilevsky
Guest
 
Posts: n/a
Default Re: 32 bit integer WAV file writer?



Stefan Reuther 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 :-)


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.

VLV


Reply With Quote
  #21 (permalink)  
Old 09-26-2007, 01:37 AM
Erik de Castro Lopo
Guest
 
Posts: n/a
Default Re: 32 bit integer WAV file writer?

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).

> 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
Reply With Quote
  #22 (permalink)  
Old 09-26-2007, 02:05 AM
Clyde
Guest
 
Posts: n/a
Default Re: 32 bit integer WAV file writer?

Erik de Castro Lopo wrote:
> This is why you should use a library like
>
> http://www.mega-nerd.com/libsndfile/
>
> (of which I am the main author).
>


Well _THANKS_ for your library, it saved me a LOT of time


--

Clyde
Reply With Quote
  #23 (permalink)  
Old 09-26-2007, 05:26 AM
mnentwig
Guest
 
Posts: n/a
Default Re: 32 bit integer WAV file writer?

>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

Cheers

Markus
Reply With Quote
  #24 (permalink)  
Old 09-26-2007, 07:44 AM
Erik de Castro Lopo
Guest
 
Posts: n/a
Default Re: 32 bit integer WAV file writer?

mnentwig wrote:

>>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
Reply With Quote
  #25 (permalink)  
Old 09-28-2007, 06:19 PM
Stefan Reuther
Guest
 
Posts: n/a
Default Re: 32 bit integer WAV file writer?

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.


Stefan

Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error: EDA Netlist Writer failed to generate FPGA Xchange file blakaxe@gmail.com FPGA 0 07-24-2008 04:10 PM
Error: EDA Netlist Writer failed to generate FPGA Xchange file blakaxe@gmail.com Verilog 0 07-24-2008 03:40 PM
Whether the iterator is reader or the writer parag_paul@hotmail.com Verilog 0 03-08-2007 11:25 PM
SmartMedia writer (implments using VHDL).... FPGA 14 02-28-2004 12:33 AM


All times are GMT +1. The time now is 08:15 PM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved