• 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
Re: Getting PCM data from MP3/AAC/ALAC File
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting PCM data from MP3/AAC/ALAC File


  • Subject: Re: Getting PCM data from MP3/AAC/ALAC File
  • From: Daniel Staudigel <email@hidden>
  • Date: Fri, 19 Dec 2008 12:18:51 -0800
  • Resent-date: Fri, 19 Dec 2008 13:17:23 -0800
  • Resent-from: Daniel Staudigel <email@hidden>
  • Resent-message-id: <email@hidden>
  • Resent-to: email@hidden

After mulling over all of these solutions, I've hit another wall (I am trying to convert MP3 to PCM on iPhoneOS 2.2). It seemed like the best option is to use the ExtAudioFile (Available as of OS2.1) methods. Using code filched from the ConvertFile demo, I get to this line:

size = sizeof(outputFormat);
err = ExtAudioFileSetProperty(infile, kExtAudioFileProperty_ClientDataFormat, size, &outputFormat);


At which point it throws a 'fmt?' error:

Error: Error Domain=NSOSStatusErrorDomain Code=1718449215 "Operation could not be completed. (OSStatus error 1718449215.)"

--- 1718449215 'fmt?' ExtAudioFileSetProperty kExtAudioFileProperty_ClientDataFormat

All of the variable names and settings are the same as in ConvertFile. Here's what outputFormat is:

outputFormat.mFormatID = kAudioFormatLinearPCM;
outputFormat.mSampleRate = inputFormat.mSampleRate;
outputFormat.mChannelsPerFrame = inputFormat.mChannelsPerFrame;

outputFormat.mBytesPerPacket = inputFormat.mChannelsPerFrame * 2;
outputFormat.mFramesPerPacket = 1;
outputFormat.mBytesPerFrame = outputFormat.mBytesPerPacket;
outputFormat.mBitsPerChannel = 16;

Which depends on inputFormat, which is printed out as being:

Source File format: AudioStreamBasicDescription: 2 ch, 44100 Hz, '.mp3' (0x00000000) 0 bits/channel, 0 bytes/packet, 1152 frames/ packet, 0 bytes/frame
format flags: 4


And the destination format just for kicks:

Dest File format: AudioStreamBasicDescription: 2 ch, 44100 Hz, 'lpcm' (0x00000004) 16-bit little-endian signed integer

I saw a huge variety of different responses over the years to this question. I've also gotten 'perm' errors etc. None of this seems to happen on OSX. Does this have to do with the single-instance MP3/AAC/ ALAC rule?

Daniel

On Dec 17, 2008, at 3:22 PM, Daniel Staudigel wrote:

Sorry to spam the list with already-answered questions. Further poking around the list revealed that the answer lies on my own hard drive. Kevin Avila's response to essentially the same question (May 1 2006) is quoted here for interest's sake.

The modern (and easy) way I would recommend to accomplish this task would be to use QuickTime 7's AudioExtraction APIs. Check out the ADC sample codes:

SimpleAudioExtraction - http://developer.apple.com/samplecode/SimpleAudioExtraction/SimpleAudioExtraction.html
QTAudioExtractionPanel - http://developer.apple.com/samplecode/QTAudioExtractionPanel/QTAudioExtractionPanel.html
ExtractMovieAudioToAIFF - http://developer.apple.com/samplecode/ExtractMovieAudioToAIFF/ExtractMovieAudioToAIFF.html

There is also some very good documentation on these APIs

http://developer.apple.com/quicktime/audioextraction.html
http://developer.apple.com/qa/qa2006/qa1469.html

The other method I would recommend is using CoreAudio's AudioConverter APIs.

	sample: /Developer/Examples/CoreAudio/Services/AudioFileTools/
			/Developer/Examples/CoreAudio/PublicUtility/CAAudioConverter

documentation: /Developer/Examples/CoreAudio/Documentation/ AudioToolbox/AudioConverter/

Kevin Avila
DTS Audio Engineer
World Wide Developer Relations
Apple Computer, Inc.

Thanks Kevin! Sorry list!

Daniel Staudigel
_______________________________________________
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: Getting PCM data from MP3/AAC/ALAC File
      • From: William Bates <email@hidden>
References: 
 >Getting PCM data from MP3/AAC/ALAC File (From: Daniel Staudigel <email@hidden>)
 >Re: Getting PCM data from MP3/AAC/ALAC File (From: Daniel Staudigel <email@hidden>)

  • Prev by Date: Re: Synthesizing sound for the iPhone
  • Next by Date: Re: Getting PCM data from MP3/AAC/ALAC File
  • Previous by thread: Re: Getting PCM data from MP3/AAC/ALAC File
  • Next by thread: Re: Getting PCM data from MP3/AAC/ALAC File
  • Index(es):
    • Date
    • Thread