Re: ExtAudioFile for audio recording
Re: ExtAudioFile for audio recording
- Subject: Re: ExtAudioFile for audio recording
- From: infrequent <email@hidden>
- Date: Sun, 1 Aug 2010 21:43:31 +0100
iOS doesn't provide any means of converting LPCM to mp3. There's a
decoder available but not an encoder. AFAIK, you can encode to aac,
but only on the 3GS or later (and there's also IMA if quality is not a
crucial factor). Otherwise you'll have to implement your own encoder.
On Sun, Aug 1, 2010 at 5:31 PM, Fernando Valente
<email@hidden> wrote:
> Thanks! This is my entire code. The problem is that the iOS doesn't have an
> MP3 encoder, so I need to set the kExtAudioFileProperty_ClientDataFormat as
> PCM and the file I'm writing to is MP3.
> NSMutableString *documents = [NSMutableString stringWithFormat:@"%@",
> [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,
> YES) objectAtIndex:0]];
> [documents appendFormat:@"/%@.mp3", [NSDate date]];
> while ([documents rangeOfString:@":"].length > 0) {
> [documents replaceCharactersInRange:[documents rangeOfString:@":"]
> withString:@""];
> NSLog(@"D");
> }
> while ([documents rangeOfString:@" "].length > 0) {
> [documents replaceCharactersInRange:[documents rangeOfString:@" "]
> withString:@""];
> }
> url = (CFURLRef)[NSURL URLWithString:documents];
> NSLog(@"%@", url);
> AudioStreamBasicDescription desc;
> desc.mSampleRate = 44100;
> desc.mFormatID = kAudioFormatMPEGLayer3;
> desc.mChannelsPerFrame = 1;
> ExtAudioFileRef ref = NULL;
> NSLog(@"variables");
> OSStatus createFile = ExtAudioFileCreateWithURL(url, kAudioFileMP3Type,
> &desc, NULL, kAudioFileFlags_EraseFile, &ref);
> NSLog(@"%d", createFile);
>
> ExtAudioFileRef xaref = nil;
> ExtAudioFileOpenURL(url, &xaref);
>
> AudioStreamBasicDescription mDesc;
> mDesc.mChannelsPerFrame = 1;
> mDesc.mSampleRate = 44100.0;
> mDesc.mFormatID = kAudioFormatLinearPCM;
> mDesc.mFormatFlags = kLinearPCMFormatFlagIsBigEndian |
> kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked;
> mDesc.mBitsPerChannel = 16;
> mDesc.mBytesPerFrame = mDesc.mChannelsPerFrame * mDesc.mBitsPerChannel / 8;
> mDesc.mFramesPerPacket = 1;
> mDesc.mBytesPerPacket = mDesc.mBytesPerFrame * mDesc.mFramesPerPacket;
> UInt32 propSize = sizeof(mDesc);
> createFile = ExtAudioFileSetProperty(ref,
> kExtAudioFileProperty_ClientDataFormat, propSize, &mDesc);
> NSLog(@"%d", createFile);
> On Aug 1, 2010, at 12:56 PM, infrequent wrote:
>
> r problem is. There are a few
> potential problems that I can see (and apologies if you're aware of
> any/all of these). Firstly, you need to crea
>
> Fernando Valente
> Chiaro Software
> email@hidden
> http://www.chiarosoft.com
> http://www.twitter.com/chiarosoftware
>
_______________________________________________
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