Re: [linux-audio-dev] CDDA interface - How to convert to float? Any library?

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [linux-audio-dev] CDDA interface - How to convert to float? Any library?
From: Erik de Castro Lopo (erikd-lad_AT_mega-nerd.com)
Date: Sun Aug 11 2002 - 02:35:20 EEST


On Sat, 10 Aug 2002 16:05:40 -0700
Martin Wolters <martinwolters_AT_yahoo.com> wrote:

> On Saturday 10 August 2002 09:49, Mark Rages wrote:
> > Anyhow, try something like this:
> >
> > u16 *u16_buffer = (u16 *)buf;
> > float sample[samplesInBuffer]
> >
> > for (i=0; i<samplesInBuffer; i++)
> > sample[i]=u16_buffer[i]; // implicit conversion to float
>
> Well, that doesn't seem to work for me. If I use "s16" instead, it sounds a
> little more like music (I actually can recognize a song). But it's far from
> being undistored. I am wondering, if a byte-swap might be required and how to
> do that.

I'm pretty sure that the audio data is signed.

Seem my reponse to your ealier post.

> PS.: I assume "u16" is equivalent to "__u16" as defined in <linux/types.h>,
> correct? I now use the following lines:
> #include <linux/types.h>
> #define s16 __s16
> #define u16 __u16

You really shouldn't be using header files like <linux/*.h> as they are really
only for kernel related code.

Instead #include <stdint.h> which defines things like int16_t and uint16_t
which are part of the ISO 1999 C Standard. Make things a little more portable.

Erik

-- 
+-----------------------------------------------------------+
  Erik de Castro Lopo  nospam_AT_mega-nerd.com (Yes it's valid)
+-----------------------------------------------------------+
With careful modifications to the case of the Win 3.1 machine, it can be
hollowed out and turned into a Crab-pot. Once tossed into the nearest river
or estuary, you will be amazed at it's improved performance. Where once it
produced very little of anything, now you'll have mud crabs.
        --OzCableguy (as posted to bigpond.broadband.tech.win)


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Sun Aug 11 2002 - 02:38:12 EEST