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 11-13-2009, 03:51 AM
aaronde
Guest
 
Posts: n/a
Default Wav File

Hi

I reading a Wav file in C++. I need to convert the PCM values to floa
values for further DSP manipulation (Filtering etc ...). Do I need to d
this through a conversion from Hex to binary unsigned 2 complement value
then to integers ? Thus anyone know of any available function in C/C++ ? A
I missing something ?

Thanks and Regards
Aaron
Reply With Quote
  #2 (permalink)  
Old 11-13-2009, 04:19 AM
Jerry Avins
Guest
 
Posts: n/a
Default Re: Wav File

aaronde wrote:
> Hi
>
> I reading a Wav file in C++. I need to convert the PCM values to float
> values for further DSP manipulation (Filtering etc ...). Do I need to do
> this through a conversion from Hex to binary unsigned 2 complement values
> then to integers ? Thus anyone know of any available function in C/C++ ? Am
> I missing something ?


I suspect that you are in serious trouble if you don't know that hex and
binary represent exactly the same thing.

Jerry
--
Engineering is the art of making what you want from things you can get.
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
Reply With Quote
  #3 (permalink)  
Old 11-13-2009, 04:29 AM
Vladimir Vassilevsky
Guest
 
Posts: n/a
Default Re: Wav File



aaronde wrote:

> Hi
>
> I reading a Wav file in C++. I need to convert the PCM values to float
> values for further DSP manipulation (Filtering etc ...). Do I need to do
> this through a conversion from Hex to binary unsigned 2 complement values
> then to integers ? Thus anyone know of any available function in C/C++ ? Am
> I missing something ?


Sometimes the idiocy of modern programmers is just unbelievable.

VLV
Reply With Quote
  #4 (permalink)  
Old 11-13-2009, 05:29 AM
aaronde
Guest
 
Posts: n/a
Default Re: Wav File

>
>
>aaronde wrote:
>
>> Hi
>>
>> I reading a Wav file in C++. I need to convert the PCM values to float
>> values for further DSP manipulation (Filtering etc ...). Do I need t

do
>> this through a conversion from Hex to binary unsigned 2 complemen

values
>> then to integers ? Thus anyone know of any available function in C/C+

? Am
>> I missing something ?

>
>Sometimes the idiocy of modern programmers is just unbelievable.
>
>VLV
>


Hi

Thanks for calling me an idiot. Really nice of you I suppose you were bor
knowing everything and you never asked a simple and dumb question. No on
forced you to reply or read the post if you think it so stupid. On th
other hand I would appreciate any help as this is the first time I am doin
such work.

Okey I know that hex and binary are the representation of the same thing
My question was that you can't apply a dsp operation using the PCM values
If I read the wav file and get a Hex value of 8A this has to b
represented as an float type ie conveted and rescaled to a range between -
and 1 in order to apply further operations. My question was weather ther
is a built in fucntion in C/C++. Please excuse me if I am not clear with m
question

Thanks and Regards
Aaron
Reply With Quote
  #5 (permalink)  
Old 11-13-2009, 05:44 AM
Les Cargill
Guest
 
Posts: n/a
Default Re: Wav File

aaronde wrote:
>>
>> aaronde wrote:
>>
>>> Hi
>>>
>>> I reading a Wav file in C++. I need to convert the PCM values to float
>>> values for further DSP manipulation (Filtering etc ...). Do I need to

> do
>>> this through a conversion from Hex to binary unsigned 2 complement

> values
>>> then to integers ? Thus anyone know of any available function in C/C++

> ? Am
>>> I missing something ?

>> Sometimes the idiocy of modern programmers is just unbelievable.
>>
>> VLV
>>

>
> Hi
>
> Thanks for calling me an idiot. Really nice of you I suppose you were born
> knowing everything and you never asked a simple and dumb question. No one
> forced you to reply or read the post if you think it so stupid. On the
> other hand I would appreciate any help as this is the first time I am doing
> such work.
>
> Okey I know that hex and binary are the representation of the same thing.
> My question was that you can't apply a dsp operation using the PCM values.
> If I read the wav file and get a Hex value of 8A this has to be
> represented as an float type ie conveted and rescaled to a range between -1
> and 1 in order to apply further operations. My question was weather there
> is a built in fucntion in C/C++. Please excuse me if I am not clear with my
> question
>
> Thanks and Regards
> Aaron



You need to use either the plain assignment operator or a cast.

short number = 55;
double dnumber = number;
-- or --
double dnumber = (double) number;
depending on which sort of compiler you use and
what options are enabled.

--
Les Cargill
Reply With Quote
  #6 (permalink)  
Old 11-13-2009, 06:09 AM
Jerry Avins
Guest
 
Posts: n/a
Default Re: Wav File

aaronde wrote:
>>
>> aaronde wrote:
>>
>>> Hi
>>>
>>> I reading a Wav file in C++. I need to convert the PCM values to float
>>> values for further DSP manipulation (Filtering etc ...). Do I need to

> do
>>> this through a conversion from Hex to binary unsigned 2 complement

> values
>>> then to integers ? Thus anyone know of any available function in C/C++

> ? Am
>>> I missing something ?

>> Sometimes the idiocy of modern programmers is just unbelievable.
>>
>> VLV
>>

>
> Hi
>
> Thanks for calling me an idiot. Really nice of you I suppose you were born
> knowing everything and you never asked a simple and dumb question. No one
> forced you to reply or read the post if you think it so stupid. On the
> other hand I would appreciate any help as this is the first time I am doing
> such work.
>
> Okey I know that hex and binary are the representation of the same thing.
> My question was that you can't apply a dsp operation using the PCM values.


If course you can. It's called "integer". Often you need to scale it.
See especially http://www.digitalsignallabs.com/fp.pdf and also
http://cnx.org/content/m11054/latest/

> If I read the wav file and get a Hex value of 8A this has to be
> represented as an float type ie conveted and rescaled to a range between -1
> and 1 in order to apply further operations. My question was weather there
> is a built in fucntion in C/C++. Please excuse me if I am not clear with my
> question


I'll go put on a limb and claim that every language that supports both
integer and floating point has a way to convert between them. In C and
C++, the compiler will do it for you if you ask nicely.

Jerry
--
Engineering is the art of making what you want from things you can get.
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
Reply With Quote
  #7 (permalink)  
Old 11-13-2009, 06:13 AM
Andrew Reilly
Guest
 
Posts: n/a
Default Re: Wav File

On Thu, 12 Nov 2009 22:29:53 -0600, aaronde wrote:

> If I read the wav file and get a Hex value of 8A this has to be
> represented as an float type ie conveted and rescaled to a range between
> -1 and 1 in order to apply further operations.


I was going to try to be helpful, but then I noticed that your question
contained the entire answer (above). So now I'm just confused about what
it is that you don't understand. Could you have another go at asking the
question, please?

Cheers,

--
Andrew
Reply With Quote
  #8 (permalink)  
Old 11-13-2009, 06:40 AM
Eric Jacobsen
Guest
 
Posts: n/a
Default Re: Wav File

On 11/12/2009 9:29 PM, aaronde wrote:
>>
>> aaronde wrote:
>>
>>> Hi
>>>
>>> I reading a Wav file in C++. I need to convert the PCM values to float
>>> values for further DSP manipulation (Filtering etc ...). Do I need to

> do
>>> this through a conversion from Hex to binary unsigned 2 complement

> values
>>> then to integers ? Thus anyone know of any available function in C/C++

> ? Am
>>> I missing something ?

>> Sometimes the idiocy of modern programmers is just unbelievable.
>>
>> VLV
>>

>
> Hi
>
> Thanks for calling me an idiot. Really nice of you I suppose you were born
> knowing everything and you never asked a simple and dumb question. No one
> forced you to reply or read the post if you think it so stupid. On the
> other hand I would appreciate any help as this is the first time I am doing
> such work.
>
> Okey I know that hex and binary are the representation of the same thing.
> My question was that you can't apply a dsp operation using the PCM values.


First, that's not a question, and, second, it's not true.

Why can't you do a DSP operation on integers?

> If I read the wav file and get a Hex value of 8A this has to be
> represented as an float type ie conveted and rescaled to a range between -1
> and 1 in order to apply further operations.


I don't know why that would be. Lots of processing is done on arrays or
streams of integers without ever converting to floating point.

> My question was weather there
> is a built in fucntion in C/C++. Please excuse me if I am not clear with my
> question
>
> Thanks and Regards
> Aaron



--
Eric Jacobsen
Minister of Algorithms
Abineau Communications
http://www.abineau.com
Reply With Quote
  #9 (permalink)  
Old 11-13-2009, 07:25 AM
Erik de Castro Lopo
Guest
 
Posts: n/a
Default Re: Wav File

aaronde wrote:

> Hi
>
> I reading a Wav file in C++. I need to convert the PCM values to float
> values for further DSP manipulation (Filtering etc ...). Do I need to do
> this through a conversion from Hex to binary unsigned 2 complement values
> then to integers ? Thus anyone know of any available function in C/C++ ? Am
> I missing something ?


You're probably much more interesting in doing the DSP manipulation
than you are in reading WAV files. If thats the case, then why don't
you use libsndfile:

http://www.mega-nerd.com/libsndfile/

which reads WAV as well as many other formats. In addition, if you
can use the sf_read_float() function you can directly read normalized
floating point data

http://www.mega-nerd.com/libsndfile/api.html#read

Ie the library does the conversion to float for you, on the fly.

Erik
--
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/
Reply With Quote
  #10 (permalink)  
Old 11-13-2009, 07:38 AM
Vladimir Vassilevsky
Guest
 
Posts: n/a
Default Re: Wav File



aaronde wrote:
>>
>>aaronde wrote:
>>
>>
>>>I reading a Wav file in C++. I need to convert the PCM values to float
>>>values for further DSP manipulation


>>Sometimes the idiocy of modern programmers is just unbelievable.

>
> Thanks for calling me an idiot.


Sure. I can call you idiot once more, if you like.

> Really nice of you I suppose you were born
> knowing everything and you never asked a simple and dumb question.


You see, before I could do any programming, I had to build a computer
for myself. With soldering iron, breadboard and discrete parts from
black market. There wasn't anybody to ask questions to. Now, with the
computers widely available, with the miracles of Google and Wikipedia,
with the zillion of books and online guides, why do you have to ask
2+2=4 question?

VLV
Reply With Quote
  #11 (permalink)  
Old 11-13-2009, 11:38 AM
Richard Dobson
Guest
 
Posts: n/a
Default Re: Wav File

Erik de Castro Lopo wrote:
> aaronde wrote:
>
>> Hi
>>
>> I reading a Wav file in C++. I need to convert the PCM values to float
>> values for further DSP manipulation (Filtering etc ...). Do I need to do
>> this through a conversion from Hex to binary unsigned 2 complement values
>> then to integers ? Thus anyone know of any available function in C/C++ ? Am
>> I missing something ?

>
> You're probably much more interesting in doing the DSP manipulation
> than you are in reading WAV files. If thats the case, then why don't
> you use libsndfile:
>
> http://www.mega-nerd.com/libsndfile/
>
> which reads WAV as well as many other formats. In addition, if you
> can use the sf_read_float() function you can directly read normalized
> floating point data
>
> http://www.mega-nerd.com/libsndfile/api.html#read
>
> Ie the library does the conversion to float for you, on the fly.
>
> Erik



And I will quietly note that ~nobody~ else responding to the OP offered
this obvious (to those who know...) and simple piece of information!

Richard Dobson


Reply With Quote
  #12 (permalink)  
Old 11-13-2009, 04:39 PM
Jerry Avins
Guest
 
Posts: n/a
Default Re: Wav File

Vladimir Vassilevsky wrote:
>
>
> aaronde wrote:
>>>
>>> aaronde wrote:
>>>
>>>
>>>> I reading a Wav file in C++. I need to convert the PCM values to float
>>>> values for further DSP manipulation

>
>>> Sometimes the idiocy of modern programmers is just unbelievable.

>>
>> Thanks for calling me an idiot.

>
> Sure. I can call you idiot once more, if you like.
>
>> Really nice of you I suppose you were born
>> knowing everything and you never asked a simple and dumb question.

>
> You see, before I could do any programming, I had to build a computer
> for myself. With soldering iron, breadboard and discrete parts from
> black market. There wasn't anybody to ask questions to. Now, with the
> computers widely available, with the miracles of Google and Wikipedia,
> with the zillion of books and online guides, why do you have to ask
> 2+2=4 question?
>
> VLV


Vlad, let me remind you of the Computer Science type (MSCS) who asked me
how the hardware distinguishes between byte-wide integer and ASCII. At
least aaronde has the excuse of never having been taught. Someone who
can't slog his way through a core dump shouldn't be called a programmer.

Jerry
--
Engineering is the art of making what you want from things you can get.
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
Reply With Quote
  #13 (permalink)  
Old 11-13-2009, 04:45 PM
Jerry Avins
Guest
 
Posts: n/a
Default Re: Wav File

Richard Dobson wrote:
> Erik de Castro Lopo wrote:
>> aaronde wrote:
>>
>>> Hi
>>> I reading a Wav file in C++. I need to convert the PCM values to float
>>> values for further DSP manipulation (Filtering etc ...). Do I need to do
>>> this through a conversion from Hex to binary unsigned 2 complement
>>> values
>>> then to integers ? Thus anyone know of any available function in
>>> C/C++ ? Am
>>> I missing something ?

>>
>> You're probably much more interesting in doing the DSP manipulation
>> than you are in reading WAV files. If thats the case, then why don't
>> you use libsndfile:
>>
>> http://www.mega-nerd.com/libsndfile/
>>
>> which reads WAV as well as many other formats. In addition, if you
>> can use the sf_read_float() function you can directly read normalized
>> floating point data
>>
>> http://www.mega-nerd.com/libsndfile/api.html#read
>>
>> Ie the library does the conversion to float for you, on the fly.
>>
>> Erik

>
>
> And I will quietly note that ~nobody~ else responding to the OP offered
> this obvious (to those who know...) and simple piece of information!


Because until the OP understands what a .wav file is, the simple (and
excellent) piece of information won't do him any good. He first needs to
know that PCM _is_ integer. Then, if he really needs floating point, he
needs to learn his programming language well enough to change types.

Jerry
--
Engineering is the art of making what you want from things you can get.
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
Reply With Quote
  #14 (permalink)  
Old 11-13-2009, 06:44 PM
aaronde
Guest
 
Posts: n/a
Default Re: Wav File

Thanks for the useful info guys I think you were write I was confused.
can now understand clearer

VV I will just ignore you. May you be able to build the next state of th
art computer using your soldering iron and breadboards .... The greates
idiot is the person who calls other people idiots and thinks that he is to
good for everyone else ... Good Luck
Reply With Quote
  #15 (permalink)  
Old 11-13-2009, 06:51 PM
Fully Half Baked
Guest
 
Posts: n/a
Default Re: Wav File

On Nov 13, 2:51*am, "aaronde" <aaronddebatti...@gmail.com> wrote:
> Hi
>
> I reading a Wav file in C++. I need to convert the PCM values to float
> values for further DSP manipulation (Filtering etc ...). Do I need to do
> this through a conversion from Hex to binary unsigned 2 complement values
> then to integers ? Thus anyone know of any available function in C/C++ ? Am
> I missing something ?
>
> Thanks and Regards
> Aaron


If the input is 16 bit you can do something like
float floatval = (float)(inputval/32768)
That will give you a normalised value between +/- 1.0
16 bit audio is a (signed short) which is +32768 - 32767
Or is it the other way around I can never remember
Reply With Quote
  #16 (permalink)  
Old 11-15-2009, 07:36 PM
Richard Dobson
Guest
 
Posts: n/a
Default Re: Wav File

Jerry Avins wrote:
...
>> And I will quietly note that ~nobody~ else responding to the OP
>> offered this obvious (to those who know...) and simple piece of
>> information!

>
> Because until the OP understands what a .wav file is, the simple (and
> excellent) piece of information won't do him any good. He first needs to
> know that PCM _is_ integer. Then, if he really needs floating point, he
> needs to learn his programming language well enough to change types.
>


Or use (or copy to) a floats WAVE file - then you can just read and
process. Still PCM (at least, in the sense of "not compressed"), or so
I'm told. Lots of integer types in WAVE and AIFF files BTW: covering all
byte-lengths from 1 to 4 inclusive; 2 and 3-byte words of course the
most common by far. And with WAVE_EX, you can in principle have 20bit
words inside a 24bit container. So anyone parsing a PCM WAVE file still
needs to check if the data is integer or floats, what size of
integer/float the file contains, etc etc etc.

It is a ~lot~ less work, and a whole lot safer, just to use an
established library to do the job.

Richard Dobson
Reply With Quote
  #17 (permalink)  
Old 11-15-2009, 08:39 PM
Jerry Avins
Guest
 
Posts: n/a
Default Re: Wav File

Richard Dobson wrote:

> It is a ~lot~ less work, and a whole lot safer, just to use an
> established library to do the job.


Yes. I stand corrected and abashed, but the OP still needs to know what
a .wav file is -- in particular, _his_ .wav file. He can use libsndfile
to read the header. (Do you think he knows about headers?)

Jerry
--
Engineering is the art of making what you want from things you can get.
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
Reply With Quote
  #18 (permalink)  
Old 11-15-2009, 10:24 PM
Richard Dobson
Guest
 
Posts: n/a
Default Re: Wav File

Jerry Avins wrote:
> Richard Dobson wrote:
>
>> It is a ~lot~ less work, and a whole lot safer, just to use an
>> established library to do the job.

>
> Yes. I stand corrected and abashed, but the OP still needs to know what
> a .wav file is -- in particular, _his_ .wav file. He can use libsndfile
> to read the header. (Do you think he knows about headers?)
>
> Jerry



The only essential point to make in answering that question is that a
WAVE (or AIFF) file does not have a fixed-length header. The OP shoudl
disregard any suggestion to the contrary. You can't take a short cut and
say 'the audio starts at byte 34' or whatever. Well, you could, just, in
writing a file, but not in reading one. There are unfortunately many
examples (including many self-styled "documentation" pages) on the net
where that assumption is made, implicitly or explicitly (the original
matlab implementation of "wavread" suffered just this problem, among
other things). I long ago lost count of the number of unix programs
especially that broke simply because I gave them a WAVE file with a
longer header than the theoretical minimum.

All other things being equal, there are only two primary types of
programmer who should really commit the time and effort to delve into
the minutiae of such file formats - writers of soundfile handling
libraries such as Eric with libsndfile (which as I am sure he will
confirm has taken years of work to reach its present extremely
efficient, accurate and comprehensive state), and people who design file
formats (and thus need a custom soundfile library they can freely
"hack"); which is what I have done from time to time (e.g. for phase
vocoder analysis files, and for Ambisonic B-Format).


Richard Dobson
Reply With Quote
  #19 (permalink)  
Old 11-15-2009, 10:36 PM
Erik de Castro Lopo
Guest
 
Posts: n/a
Default Re: Wav File

Jerry Avins wrote:

> Richard Dobson wrote:
>
> > It is a ~lot~ less work, and a whole lot safer, just to use an
> > established library to do the job.

>
> Yes. I stand corrected and abashed, but the OP still needs to know what
> a .wav file is -- in particular, _his_ .wav file. He can use libsndfile
> to read the header. (Do you think he knows about headers?)


Quite honestly, manually read WAV file headers is something to
be avoided unless you have a very good reason not to. WAV files
have a rather poor sepcification and there have been many, many
programs over the years that produced odd or non-standard files.
libsndfile's WAV parser is full of little workarounds and special
cases for some of these non-standard files.

However, for those interested, the sndfile-info program which
comes with libsndfile dumps all the header information in a human
readable form liek this:

erik > sndfile-info drumset01-sep08wallywoods-zettberlin.wav

Version : libsndfile-1.0.21pre1

========================================
File : /home/erik/drumset01-sep08wallywoods-zettberlin.wav
Length : 270608864
RIFF : 270608856
WAVE
fmt : 16
Format : 0x3 => WAVE_FORMAT_IEEE_FLOAT
Channels : 2
Sample Rate : 96000
Block Align : 8
Bit Width : 32
Bytes/sec : 768000
fact : 4
frames : 33826097
PEAK : 24
version : 1
time stamp : 1221772493
Ch Position Value
0 12307085 0.817219
1 12307085 0.712256
data : 270608776
End

----------------------------------------
Sample Rate : 96000
Frames : 33826097
Channels : 2
Format : 0x00010006
Sections : 1
Seekable : TRUE
Duration : 00:05:52.355
Signal Max : 0.817219 (-1.75 dB)

Erik
--
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/
Reply With Quote
  #20 (permalink)  
Old 11-15-2009, 10:45 PM
Erik de Castro Lopo
Guest
 
Posts: n/a
Default Re: Wav File

Richard Dobson wrote:

> All other things being equal, there are only two primary types of
> programmer who should really commit the time and effort to delve into
> the minutiae of such file formats - writers of soundfile handling
> libraries such as Eric with libsndfile (which as I am sure he will
> confirm has taken years of work to reach its present extremely
> efficient, accurate and comprehensive state), and people who design file
> formats (and thus need a custom soundfile library they can freely
> "hack"); which is what I have done from time to time (e.g. for phase
> vocoder analysis files, and for Ambisonic B-Format).


I agree with this completely. Reading most files is relatively trivial
but there are a huge number of tiny variations, some within spec and
some no that make reading as many files as possible a pain in the neck.

On a side note, libsndfile has been publicly available for a little
over 10 years. The 10 year retrospective is here:

http://www.mega-nerd.com/erikd/Blog/...ten_years.html

libsndfile actually grew out of code I originally wrote in 1992,
when i decided that microsoft's API for reading WAV files was
simply way too horrible to use.

Erik
--
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/
Reply With Quote
  #21 (permalink)  
Old 11-15-2009, 11:18 PM
Jerry Avins
Guest
 
Posts: n/a
Default Re: Wav File

Richard Dobson wrote:
> Jerry Avins wrote:
>> Richard Dobson wrote:
>>
>>> It is a ~lot~ less work, and a whole lot safer, just to use an
>>> established library to do the job.

>>
>> Yes. I stand corrected and abashed, but the OP still needs to know
>> what a .wav file is -- in particular, _his_ .wav file. He can use
>> libsndfile to read the header. (Do you think he knows about headers?)
>>
>> Jerry

>
>
> The only essential point to make in answering that question is that a
> WAVE (or AIFF) file does not have a fixed-length header. The OP shoudl
> disregard any suggestion to the contrary. You can't take a short cut and
> say 'the audio starts at byte 34' or whatever. Well, you could, just, in
> writing a file, but not in reading one. There are unfortunately many
> examples (including many self-styled "documentation" pages) on the net
> where that assumption is made, implicitly or explicitly (the original
> matlab implementation of "wavread" suffered just this problem, among
> other things). I long ago lost count of the number of unix programs
> especially that broke simply because I gave them a WAVE file with a
> longer header than the theoretical minimum.
>
> All other things being equal, there are only two primary types of
> programmer who should really commit the time and effort to delve into
> the minutiae of such file formats - writers of soundfile handling
> libraries such as Eric with libsndfile (which as I am sure he will
> confirm has taken years of work to reach its present extremely
> efficient, accurate and comprehensive state), and people who design file
> formats (and thus need a custom soundfile library they can freely
> "hack"); which is what I have done from time to time (e.g. for phase
> vocoder analysis files, and for Ambisonic B-Format).


All true. When I write that aaronde needs to know what a .wav file is, I
don'r mean the details you enumerate. I mean its format, including
header (which I suspect is a surprise to him) and a series of integers
whose size and format the header describes. I hope he's still reading.
There's a lot he needs to learn from you and Erik.

Jerry
--
Engineering is the art of making what you want from things you can get.
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
Reply With Quote
  #22 (permalink)  
Old 11-16-2009, 12:30 AM
glen herrmannsfeldt
Guest
 
Posts: n/a
Default Re: Wav File

Jerry Avins <[email protected]> wrote:
(snip)

> Yes. I stand corrected and abashed, but the OP still needs to know what
> a .wav file is -- in particular, _his_ .wav file. He can use libsndfile
> to read the header. (Do you think he knows about headers?)


Some time ago I wrote a program to read WAV files, including
extracting the data from the header. It seems, though, that what
most do is just skip the appropriate number of bytes. (Programs
like cdrecord.) I have one that computes, among others, the peak
and RMS values. I thought about posting it but never did.

-- glen
Reply With Quote
  #23 (permalink)  
Old 11-16-2009, 12:44 AM
Randy Yates
Guest
 
Posts: n/a
Default Re: Wav File

Erik de Castro Lopo <[email protected]> writes:
> [...]


Erik,

Didn't libsndfile just recently win some type of award or recognition?

In any case, thanks for a very useful library. I use it in my spectral
analysis tool.
--
Randy Yates % "Bird, on the wing,
Digital Signal Labs % goes floating by
mailto://[email protected] % but there's a teardrop in his eye..."
http://www.digitalsignallabs.com % 'One Summer Dream', *Face The Music*, ELO
Reply With Quote
  #24 (permalink)  
Old 11-16-2009, 12:54 AM
aaronde
Guest
 
Posts: n/a
Default Re: Wav File

>Richard Dobson wrote:
>> Jerry Avins wrote:
>>> Richard Dobson wrote:
>>>
>>>> It is a ~lot~ less work, and a whole lot safer, just to use an
>>>> established library to do the job.
>>>
>>> Yes. I stand corrected and abashed, but the OP still needs to know
>>> what a .wav file is -- in particular, _his_ .wav file. He can use
>>> libsndfile to read the header. (Do you think he knows about headers?)
>>>
>>> Jerry

>>
>>
>> The only essential point to make in answering that question is that a
>> WAVE (or AIFF) file does not have a fixed-length header. The OP shoud


>> disregard any suggestion to the contrary. You can't take a short cu

and
>> say 'the audio starts at byte 34' or whatever. Well, you could, just

in
>> writing a file, but not in reading one. There are unfortunately many
>> examples (including many self-styled "documentation" pages) on the ne


>> where that assumption is made, implicitly or explicitly (the original
>> matlab implementation of "wavread" suffered just this problem, among
>> other things). I long ago lost count of the number of unix programs
>> especially that broke simply because I gave them a WAVE file with a
>> longer header than the theoretical minimum.
>>
>> All other things being equal, there are only two primary types of
>> programmer who should really commit the time and effort to delve into
>> the minutiae of such file formats - writers of soundfile handling
>> libraries such as Eric with libsndfile (which as I am sure he will
>> confirm has taken years of work to reach its present extremely
>> efficient, accurate and comprehensive state), and people who desig

file
>> formats (and thus need a custom soundfile library they can freely
>> "hack"); which is what I have done from time to time (e.g. for phase
>> vocoder analysis files, and for Ambisonic B-Format).

>
>All true. When I write that aaronde needs to know what a .wav file is,


>don'r mean the details you enumerate. I mean its format, including
>header (which I suspect is a surprise to him) and a series of integers
>whose size and format the header describes. I hope he's still reading.
>There's a lot he needs to learn from you and Erik.
>
>Jerry
>--
>Engineering is the art of making what you want from things you can get.
>ïż½ïż½ïż½ïż½ïż½ïż½ïż½ïż½ïż½ïż½ïż½ïż½ïż½ïż½ïż½ïż½ï ż½ïż½ïż½ïż½ïż½ïż½ïż½ïż½ïż½ïż½ïż½ïż½ïż½ïż½ïż½ïż½ïż½ ïż½ïż½ïż½ïż½ïż½ïż½ïż½ïż½ïż½ïż½ïż½ïż½ïż½ïż½ïż½ïż½ïż ½ïż½ïż½ïż½ïż½ïż½ïż½ïż½ïż½ïż½ïż½ïż½ïż½ïż½ïż½ïż½ïż½ï ż½ïż½ïż½ïż½ïż½
>


Yeah still reading.... thanks for the info guys really helped
Reply With Quote
  #25 (permalink)  
Old 11-16-2009, 03:59 AM
Erik de Castro Lopo
Guest
 
Posts: n/a
Default Re: Wav File

Randy Yates wrote:

> Didn't libsndfile just recently win some type of award or recognition?


If it did, nobody told me :-).

Erik
--
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/
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
Verilog 2001 File I/O: read large file? Davy Verilog 15 04-07-2006 04:03 AM
How to get *.mcs file containing both *.bit and *.elf file, to port linux on my memec virtex-ii board. beomseok,lee FPGA 2 06-04-2005 04:33 PM
ispLSI-2064 -- how to decompile jedec file to ldf file? Qiang He FPGA 0 11-07-2003 05:08 AM
Re: Downsampe and convert stereo file to mono file. Jim Thomas DSP 1 08-25-2003 05:38 AM
Re: Downsampe and convert stereo file to mono file. Martin Eisenberg DSP 0 08-14-2003 09:29 PM


All times are GMT +1. The time now is 01:55 AM.


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