• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
sample code on how to write an MP3 file?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

sample code on how to write an MP3 file?


  • Subject: sample code on how to write an MP3 file?
  • From: "David M.Cotter" <email@hidden>
  • Date: Mon, 3 Jan 2005 21:51:54 -0800

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?

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: sample code on how to write an MP3 file?
      • From: "Daniel C. Heidebrecht" <email@hidden>
    • Re: sample code on how to write an MP3 file?
      • From: Doug Wyatt <email@hidden>
  • Prev by Date: Re: Audio MIDI Setup Icon
  • Next by Date: AUParametricEq Q parameter?
  • Previous by thread: Re: Audio MIDI Setup Icon
  • Next by thread: Re: sample code on how to write an MP3 file?
  • Index(es):
    • Date
    • Thread