[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: [linux-audio-dev] CDDA interface - How to convert to float? Any library?
From: Martin Wolters (martinw_AT_atc.creative.com)
Date: Sat Aug 10 2002 - 04:18:44 EEST


  I am trying to read out data from a CDDA and convert it into float (on
Linux x86). The data from the CD is returned in an unsigned char buffer.
That code looks something like this:

int cd_read_audio(int cdrom_fd, int lba, int num, unsigned char *buf)
{
    struct cdrom_read_audio ra;
    ra.addr.lba = lba;
    ra.addr_format = CDROM_LBA;
    ra.nframes = num;
    ra.buf = buf;
   ioctl(cdrom_fd, CDROMREADAUDIO, &ra);
}

I tried using something like the following to convert the data:

float samples[samplesInBuffer];
for(i=0;i<samplesInBuffer;i++) {
    int value = (buf[1] << 8) + (buf[0] << 16);
    sample[i] = ((float)(value/256))*scalefactor;
    buf += 2;
}

I would expect left/right audio interleaved, but that doesn't sound like
regular audio at all. Any ideas? Or even better: Are you aware of any
library such as portaudio or libsndfile that will do that for me? (Looks
like libcdaudio doesn't actually touch the audio data but only controls
the CD drive. Correct?)

-M

-- 
Martin Wolters
Creative ATC   
1500 Green Hills Road
Scotts Valley, CA 95066
Phone: ++1 (831) 440-2848
Fax: ++1 (831) 440-2882


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

This archive was generated by hypermail 2b28 : Sat Aug 10 2002 - 04:16:43 EEST