Re: Play from Audio CD
Re: Play from Audio CD
- Subject: Re: Play from Audio CD
- From: Jeff Moore <email@hidden>
- Date: Thu, 10 Jun 2010 14:20:44 -0700
- Resent-date: Thu, 10 Jun 2010 14:21:55 -0700
- Resent-from: Jeff Moore <email@hidden>
- Resent-message-id: <email@hidden>
- Resent-to: CoreAudio API <email@hidden>
The API you want is the AudioFileStreaming API. That exposes the parsers for audio files to you via callbacks that you can implement to provide access to the data as it gets ripped. There is a project in our sample code called "AudioFileStreamExample" that illustrates this. Note that it was the demo code for a WWDC session from a few years ago. So you can go look up the session in the WWDC archives and see the talk that went with the code.
That said, audio CDs on the system are available to you as regular old audio files. You can the AudioFile or ExtendedAudioFile API to open and access the audio data on the disk directly.
--
Jeff Moore
Core Audio
Apple
On Jun 10, 2010, at 8:09 AM, John Johnson wrote:
> Hey everyone. I'm trying to play audio directly from a CD. I have an audio ripper that's set up to rip the audio; it rips a certain number of sectors and then passes it back to a delegate object to process in the form of an AudioBufferList. Here is where I write the audio data to a file. My question is how would I begin playing that file before the ripping is completely done? It seems the audio file is not playable until I call AudioFileDispose... Maybe it's possible to play the audio data directly without the need for an intermediate file, I don't know. I'm just a little confused on how this process should go. Any help would be appreciated.
>
> Here's the delegate method that process the ripped audio.
>
> - (void)processRippedAudio:(AudioBufferList *)audioBufferList andSubchannel:(SubchannelBufferList *)subBufferList
> {
> if (audioBufferList->mNumberBuffers > 0) {
> NSUInteger frameCount = audioBufferList->mBuffers[0].mDataByteSize / sizeof(Float32);
> OSErr err = ExtAudioFileWrite(_extAudioFile, frameCount, audioBufferList);
> NSAssert2(err == noErr, @"The call to ExtAudioFileWrite failed.", UTCreateStringForOSType(err));
> }
>
> if (subBufferList->mNumberBuffers > 0) {
> [_subchannelData appendBytes:subBufferList->mBuffers[0].mData length:subBufferList->mBuffers[0].mDataByteSize];
> }
> }
>
>
> The audio file is set up as follows:
>
> asbd.mSampleRate = 44100.f;
> asbd.mFormatID = kAudioFormatLinearPCM;
> asbd.mFormatFlags = kAudioFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsBigEndian | kAudioFormatFlagIsPacked;
> asbd.mBytesPerPacket = 4;
> asbd.mFramesPerPacket = 1;
> asbd.mBytesPerFrame = 4;
> asbd.mChannelsPerFrame = 2;
> asbd.mBitsPerChannel = 16;
_______________________________________________
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