i've searched the doc, i've searched google, i've searched the
archives, to no avail.
i'm trying to do CD ripping.
I found this:
http://www.mat.ucsb.edu:8000/CoreAudio/90
which is utterly fantastic, except it records AIFF instead of MP3
so I try to record MP3 this way:
AudioStreamBasicDescription asbd;
AudioFileTypeAndFormatID fmID;
UInt32 sizeL = sizeof(asbd);
fmID.mFileType = kAudioFileMP3Type;
fmID.mFormatID = kAudioFormatMPEGLayer3;
if (!err) err = AudioFileGetGlobalInfo(
kAudioFileGlobalInfo_AvailableStreamDescriptionsForFormat,
sizeof(fmID), &fmID, &sizeL, &asbd);
at this point the asbd looks nothing like i'd expect, but the
following call works
if (!err) err = AudioFileInitialize(
&i_destAudioFileSpec, kAudioFileMP3Type,
&asbd, 0, &i_audioFileID);
etc etc, and I use
OSErr CSongImporter::DumpAudioSector(unsigned char *bufP)
{
OSErr err = noErr;
UInt32 num_bytesL = kCDSectorSizeCDDA;
err = AudioFileWriteBytes(
i_audioFileID, true, i_audio_bytePos, &num_bytesL, bufP);
if (!err) err = num_bytesL != kCDSectorSizeCDDA;
if (!err) i_audio_bytePos += num_bytesL;
return err;
}
the bufP is what is returned by:
dk_cd_read_t readCDParam;
UInt64 bufLen = kCDSectorSizeCDDA;
structclr(readCDParam);
readCDParam.offset = bufLen * cur_sectorL;
readCDParam.sectorArea = kCDSectorAreaUser;
readCDParam.sectorType = kCDSectorTypeCDDA;
readCDParam.bufferLength = bufLen;
readCDParam.buffer = i_buffer;
err = ioctl(i_fd, DKIOCCDREAD, (char*)&readCDParam) == -1;
so it's raw audio bytes, i suppose it's raw PCM data?
but then i end up with a 50 meg file that's NOT playable. so huh,
what am I doing wrong?
is there sample code somewhere?