From: Richard Dobson on
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


From: Jerry Avins on
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.
�����������������������������������������������������������������������
From: Jerry Avins on
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.
�����������������������������������������������������������������������
From: aaronde on
Thanks for the useful info guys I think you were write I was confused. I
can now understand clearer

VV I will just ignore you. May you be able to build the next state of the
art computer using your soldering iron and breadboards .... The greatest
idiot is the person who calls other people idiots and thinks that he is too
good for everyone else ... Good Luck
From: Fully Half Baked on
On Nov 13, 2:51 am, "aaronde" <aaronddebatti...(a)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 :)