• 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
MTCoreAudio, CAAudioFileWriter and conversion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

MTCoreAudio, CAAudioFileWriter and conversion


  • Subject: MTCoreAudio, CAAudioFileWriter and conversion
  • From: Olivier Destrebecq <email@hidden>
  • Date: Mon, 10 Oct 2005 23:45:18 -0400

I made progress since my last question and now have stumbled upon other road blocks.

I want to record audio to disk, so i'm using MTCoreAudio to get the data and CAAudioFileWriter to write it to disk. I'm limiting my deployment target to 10.4, so i'm using the extended API.

My code run, the file gets created, but then when i try to open it with Quicktime, it tells me it cannot open it. Also if i add code to try to convert to AAC before writing to disk i get an error. I include the code in this email for your review.


As usual, any pointers are appreciated:-) Thanks in advance Olivier http://otusweb.spymac.com/home/


//create a fileWriter from the description we get back from the mic
//
MTCoreAudioStreamDescription *audioStreamDescription = [[[[self recordingDevice] streamsForDirection: kMTCoreAudioDeviceRecordDirection] objectAtIndex: 0] streamDescriptionForSide: kMTCoreAudioStreamLogicalSide];
audioFileWriter = new CAAudioFileWriter(44100, [audioStreamDescription bytesPerFrame]); //should give us one second buffer


//create the directory reference and the filereference
FSRef parentDir;
NSString *tempRecordFileName = [@"recording" stringByAppendingString: [[NSNumber numberWithDouble: [[NSDate date] timeIntervalSince1970]] stringValue]];
NSURL *parentDirectoryURL = [NSURL fileURLWithPath: [NSTemporaryDirectory() stringByAppendingPathComponent: [[NSBundle mainBundle] bundleIdentifier]]];


//make sure the directory exists
//
[[NSFileManager defaultManager] createDirectoryAtPath: [parentDirectoryURL path]
attributes: nil];
CFURLGetFSRef((CFURLRef)parentDirectoryURL, &parentDir);


audioFileWriter->SetFile(parentDir,
(CFStringRef) tempRecordFileName,
kAudioFileCAFType, //if I set the format here i get a format error, CAF seems to be the only one working
[audioStreamDescription audioStreamBasicDescription],
NULL);


//set the converter in place for the file so that we write straight to AAC
//
// CAAudioFile theAudioFile = audioFileWriter->GetFile();
//
// MTCoreAudioStreamDescription *aacDescription = [MTCoreAudioStreamDescription streamDescriptionWithAudioStreamBasicDescription: [audioStreamDescription audioStreamBasicDescription]];
// [aacDescription setFormatID: kAudioFormatMPEG4AAC];
// theAudioFile.SetClientFormat([aacDescription audioStreamBasicDescription]);


  BOOL returnValue = [[self recordingDevice] deviceStart];
  audioFileWriter->Start();



_______________________________________________
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: MTCoreAudio, CAAudioFileWriter and conversion
      • From: Jens Alfke <email@hidden>
    • Re: MTCoreAudio, CAAudioFileWriter and conversion
      • From: Jianhua Meng <email@hidden>
  • Prev by Date: Overload question
  • Next by Date: Re: MTCoreAudio, CAAudioFileWriter and conversion
  • Previous by thread: Re: Overload question
  • Next by thread: Re: MTCoreAudio, CAAudioFileWriter and conversion
  • Index(es):
    • Date
    • Thread