Re: sample code on how to write an MP3 file?
Re: sample code on how to write an MP3 file?
- Subject: Re: sample code on how to write an MP3 file?
- From: Brian Whitman <email@hidden>
- Date: Tue, 4 Jan 2005 12:31:15 -0500 (EST)
LAME is very good for this task. It is LGPL.
http://www.mp3dev.org/
--
Brian Whitman - email@hidden
http://web.media.mit.edu/~bwhitman
Music, Mind & Machine Group - MIT Media Lab
On Tue, 4 Jan 2005, David M.Cotter wrote:
> my only choice is MP3. does anyone know of open source or otherwise
> free 3rd party code that can write an MP3 file?
>
> On Jan 4, 2005, at 9:11 AM, Doug Wyatt wrote:
>
> > The key thing to understand about how CoreAudio deals with audio files
> > and formats -- as we stressed at WWDC last year ;-) -- is that they
> > are utterly separate concepts.
> >
> > A file is just a container and is not assumed to have any knowledge of
> > how to encode or decode the audio data inside it.
> >
> > Codecs know how to convert between PCM and encoded formats, but have
> > no idea of how to store the data in files.
> >
> > Your code looks like it's writing PCM data packets to the MP3
> > container.
> >
> > CoreAudio's MP3 file object knows how to write a valid MP3 file --
> > given a series of MP3 packets. But (probably due to licensing
> > considerations) there is no MP3 encoder in the base system.
> >
> > You might be better off sending AppleEvents to iTunes or using AAC
> > (though using the AAC encoder has its own set of hoops to jump
> > through, and the only *currently* supported container for AAC is ADTS
> > ...).
> >
> > Doug
> >
> >
> > On Jan 3, 2005, at 21:51, David M.Cotter wrote:
> >> 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
>
--
--
Brian Whitman - email@hidden
http://web.media.mit.edu/~bwhitman
Music, Mind & Machine Group
MIT Media Lab
_______________________________________________
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