• 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: Simple Question on m4a CAStreamBasicDescription and Recording
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Simple Question on m4a CAStreamBasicDescription and Recording


  • Subject: Re: Simple Question on m4a CAStreamBasicDescription and Recording
  • From: "Eric M. Aldrich I" <email@hidden>
  • Date: Thu, 25 Oct 2007 14:46:12 -0700

See below:


On 25 Oct 2007, at 2:24 PM, Jaime Magiera wrote:

Hello folks,

Pardon the simple question, it's been nearly 5 years since doing any audio programming.

I inherited some code that uses MTCoreAudio.framework and am now attempting to move off that and use plain vanilla CoreAudio. The project is off to a bumpy start. I can't even get a basic m4a :) I've looked at all the examples on the web, taken a look at MTCoreAudio, reverse engineered afrecord. The CAStreamBasicDescription might be incorrect. However, the code works for other formats. If I use kAudioFormatLinearPCM and kAudioFileAIFFType, everything is fine.

Can someone point out the likely obvious flaw below? Thanks for any help.

Jaime


[self setTempFileRecordingPath:
[@"/" stringByAppendingPathComponent:
[@"test" stringByAppendingString:
[[[NSNumber numberWithDouble: [[NSDate date] timeIntervalSince1970]] stringValue] stringByAppendingPathExtension: @"m4a"]]]];


BOOL testResult;
testResult = CFURLGetFSRef((CFURLRef)[NSURL fileURLWithPath: [[self tempFileRecordingPath] stringByDeletingLastPathComponent]], &parentDir);
NSLog(@"The result of the creation %d", testResult);


	CAStreamBasicDescription dataFormat;

dataFormat.mSampleRate = 44100;
dataFormat.mFormatID = kAudioFormatMPEG4AAC;
dataFormat.mFormatFlags = kAudioFormatFlagIsBigEndian | kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;

dataFormat.mFormatFlags = 0;

	dataFormat.mFramesPerPacket = 1;
	dataFormat.mChannelsPerFrame = 2;
	dataFormat.mBitsPerChannel = 16;

dataFormat.mBitsPerChannel = 0;

dataFormat.mBytesPerPacket = dataFormat.mBytesPerFrame = 4;

dataFormat.mBytesPerPacket = 0; // CBR codecs will have a non-zero value here
dataFormat.mBytesPerFrame = 0;


In general, the above changes will be true of any VBR compressed format. Lossless formats will often use the format flags.

Eric

---
Eric M. Aldrich I
Apple Core Audio Engineering
Audio Codecs



_______________________________________________
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: Simple Question on m4a CAStreamBasicDescription and Recording
      • From: "Eric M. Aldrich I" <email@hidden>
References: 
 >Simple Question on m4a CAStreamBasicDescription and Recording (From: Jaime Magiera <email@hidden>)

  • Prev by Date: Re: Simple Question on m4a CAStreamBasicDescription and Recording
  • Next by Date: Re: Simple Question on m4a CAStreamBasicDescription and Recording
  • Previous by thread: Re: Simple Question on m4a CAStreamBasicDescription and Recording
  • Next by thread: Re: Simple Question on m4a CAStreamBasicDescription and Recording
  • Index(es):
    • Date
    • Thread