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: Martin Wolters (martinwolters_AT_yahoo.com)
Date: Sun Aug 11 2002 - 04:26:54 EEST


Thanks everybody for the help. To bring the topic to an end, here is the code
that works:

#include <endian.h>

unsigned char * in; //point to buffer returned by cd_read_audio

#ifdef __LITTLE_ENDIAN
        short input = (short)(in[0]|(in[1] << 8)); // PC
#else
        short input = (short)(in[1]|(in[0] << 8));
        // ?? didn't test this configuration.
        // Don't know if byte order of CD data is changed
        // on different patforms.
#endif

-M

PS.: FYI, this work is part of an audio programming tutorial which I am
currently working on. It probably will be published as a HowTo/quicktoot.

On Saturday 10 August 2002 16:38, Erik de Castro Lopo wrote:
> On Sat, 10 Aug 2002 18:32:36 -0500
>
> Mark Rages <markrages_AT_mlug.missouri.edu> wrote:
> > Ahh, I forgot CDDA is signed.
> >
> > Yes, I meant the u16 in the general sense that you picked up on.
> >
> > Well, you can try a byte-swap like this:
> >
> > #include <string.h> // for swab()
> > #include <asm/byteorder.h> // for __LITTLE_ENDIAN macro
>
> In my last replay I suggested that you not use headers like <linux/*.h>
> and in this one, I'm goint to suggest that you not use <asm/*.h> headers.
>
> You will also find __LITTLE_ENDIAN (and __BIG_ENDIAN) in <endian.h> which
> is designed to be used in user space programs.
>
> Erik


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 - 04:28:47 EEST