Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

< Previous PageNext Page > Hide TOC

Recording Audio

When you record using Audio Queue Services, the destination can be just about anything—an on-disk file, a network connection, an object in memory, and so on. This chapter describes the most common scenario: basic recording to an on-disk file.

Note: The code examples in this document are sometimes simplified by using C++ classes from the Core Audio SDK. However, neither the SDK nor the C++ language is necessary to use Audio Queue Services.

For additional simplicity, these code examples do not include robust error handling. Make sure to add code to handle potential errors when you implement recording or playback with Audio Queue Services.

To add recording functionality to your application, you typically perform the following steps:

  1. Define a custom structure to manage state, format, and path information.

  2. Write an audio queue callback function to perform the actual recording.

  3. Optionally write code to determine a good size for the audio queue buffers. Write code to work with magic cookies, if you’ll be recording in a format that uses cookies.

  4. Fill the fields of the custom structure. This includes specifying the data stream that the audio queue sends to the file it’s recording into, as well as the path to that file.

  5. Create a recording audio queue and ask it to create a set of audio queue buffers. Also create a file to record into.

  6. Tell the audio queue to start recording.

  7. When done, tell the audio queue to stop and then dispose of it. The audio queue disposes of its buffers.

The remainder of this chapter describes each of these steps in detail.

Contents:

Define a Custom Structure to Manage State
Write a Recording Audio Queue Callback
Write a Function to Derive Recording Audio Queue Buffer Size
Set a Magic Cookie for an Audio File
Set Up an Audio Format for Recording
Create a Recording Audio Queue
Create an Audio File
Set an Audio Queue Buffer Size
Prepare a Set of Audio Queue Buffers
Record Audio
Clean Up After Recording




< Previous PageNext Page > Hide TOC


Last updated: 2007-10-31




Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.
Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2007 Apple Inc.
All rights reserved. | Terms of use | Privacy Notice