views:

1342

answers:

2

Hello,

could you point me to docs/snippets/blogs, which explain how to record Apple lossless audio files on the iPhone, please?

I've inspected the audio recorder example from the Apple Dev Center, but couldn't figure out, which setting I have use for lossless audio.

Regards,

Stefan

A: 

Take a look at the SpeakHere example on the Apple iPhone Dev center.

Jordan
I've used SpeakHere already. But it's for recording CAF, sadly not MP4 loseless. Thanks, anyway.
Stefan
+5  A: 

The iPhone OS supports recording a .caf file using a number of different compressed audio encoding formats:

Apple Lossless - kAudioFormatAppleLossless

iLBC (Internet Low Bitrate Codec) - kAudioFormatiLBC

IMA/ADPCM (aka IMA4) - kAudioFormatAppleIMA4

µLaw - kAudioFormatULaw

aLaw - kAudioFormatALaw

- (id) initWithURL: fileURL {
    NSLog (@"initializing a recorder object.");
    self = [super init];

    if (self != nil) {

        // define the audio stream basic description for the file to record into

        // record audio at the current hardware sample rate
        // make sure the audio session is active before asking for properties
        UInt32 propertySize = sizeof(audioFormat.mSampleRate);
        AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareSampleRate,
                                &propertySize,
                                &audioFormat.mSampleRate);

        audioFormat.mFormatID           = kAudioFormatAppleIMA4; // record using IMA4 codec
        audioFormat.mChannelsPerFrame   = 1;

        AudioQueueNewInput(&audioFormat, ... );

        ...

    }

    return self;
}

You'll definitely want to read the Audio Queue Services Programming Guide

slf