Home > Store

Learning Core Audio: A Hands-On Guide to Audio Programming for Mac and iOS

Register your product to gain access to bonus material or receive a coupon.

Learning Core Audio: A Hands-On Guide to Audio Programming for Mac and iOS

Book

  • Sorry, this book is no longer in print.
Not for Sale

Description

  • Copyright 2012
  • Dimensions: 7" x 9"
  • Pages: 336
  • Edition: 1st
  • Book
  • ISBN-10: 0-321-63684-8
  • ISBN-13: 978-0-321-63684-3

Audio can affect the human brain in the most powerful and profound ways. Using Apple’s Core Audio, you can leverage all that power in your own Mac and iOS software, implementing features ranging from audio capture to real-time effects, MP3 playback to virtual instruments, web radio to VoIP support. The most sophisticated audio programming system ever created, Core Audio is not simple. In Learning Core Audio, top Mac programming author Chris Adamson and legendary Core Audio expert Kevin Avila fully explain this challenging framework, enabling experienced Mac or iOS programmers to make the most of it. In plain language, Adamson and Avila explain what Core Audio can do, how it works, and how it builds on the natural phenomena of sound and the human language of audio. Next, using crystal-clear code examples, they guide you through recording, playback, format conversion, Audio Units, 3D audio MIDI connectivity, and overcoming unique challenges of Core Audio programming for iOS. Coverage includes: mastering Core Audio’s surprising style and conventions; recording and playback with Audio Queue; synthesizing audio; perform effects on audio streams; capturing from the mic; mixing multiple streams; managing file streams; converting formats; creating 3D positional audio; using Core MIDI on the Mac; leveraging your Cocoa and Objective-C expertise in Core Audio’s C-based environment, and much more. When you’ve mastered the “black arts” of Core Audio, you can do some serious magic. This book will transform you from an acolyte into a true Core Audio wizard.

Downloads

Downloads

Download the source code for the projects in each chapter of the book.

CHANGES for "Learning Core Audio: A Hands-On Guide to Audio Programming for Mac and iOS" sample code

March 13, 2014
-------------
All projects:
With the release of Xcode 5.1 and iOS 7.1, we are updating all projects to use "Latest OS X" or "Latest iOS" as their target SDK, rather than risk breakage as newer versions of Xcode drop older versions of the OS X and iOS SDKs. We are also modernizing the project files to use LLVM and LLDB, the supported compiler and debugger as of Xcode 5.1.

Because it has been a source of confusion for some readers, we are also moving all Foundation-based examples to use Automatic Reference Counting (ARC). This means the downloadable code no longer matches the book, in that all uses of retain/release, autorelease pools, and explicit calls to dealloc been removed, and that toll-free bridging casts now take the appropriate __bridge modifier. But we've found that ARC is now sufficiently entrenched that some people don't recognize the pre-ARC memory management techniques.

There are no code changes other than those required to handle ARC or resolve new compiler warnings (most of which are just explicit casts). The code zip includes all errata fixes from the earlier updates posted in 2012 and 2013.

Each project now has its own README.txt file describing the project. These files include the individual changes made as part of this update.

Individual examples:

We've re-colored the piano keyboard buttons in the CH11_MIDIWifiSource .xib, since iOS 7 made them not look like buttons.

CH12_MIDIToAUSampler now includes the .aupreset file and source sound used when writing the book, though we still recommend building your own preset with AU Lab. This same preset has always been included with the CH12_MIDIToAUSamplerIOS example, since the iOS version needs to find the preset within its own app bundle, unlike OS X, which searches known filesystem paths.

Sample Content

Online Sample Chapter

An Overview of Core Audio

Sample Pages

Download the sample pages (includes Chapter 1 and Index)

Table of Contents

About the Authors     xiii

Foreword  by Mike Lee  xv

Introduction     1

   Audience for This Book     2

   What You Need to Know     3

   Looking Up Documentation     3

   How This Book Is Organized     5

   About the Sample Code     9

PART I: UNDERSTANDING CORE AUDIO

Chapter 1  Overview of Core Audio     13

The Core Audio Frameworks     14

Core Audio Conventions     15

Your First Core Audio Application     16

   Running the Example     19

Core Audio Properties     22

Summary     23

Chapter 2  The Story of Sound     25

Making Waves     25

Digital Audio     27

DIY Samples     32

Buffers     40

Audio Formats     40

Summary     41

Chapter 3  Audio Processing with Core Audio     43

Audio Data Formats     43

   Example: Figuring Out Formats     46

Canonical Formats     51

Processing Audio with Audio Units     53

The Pull Model     55

Summary     55

PART II: BASIC AUDIO

Chapter 4  Recording     59

All About Audio Queues     59

Building a Recorder     60

A CheckError() Function     63

Creating and Using the Audio Queue     64

Utility Functions for the Audio Queue     71

   The Recording Audio Queue Callback     75

Summary     78

Chapter 5  Playback     81

Defining the Playback Application     81

Setting Up a File-Playing Audio Queue     83

   Setting Up the Playback Buffers     85

   Starting the Playback Queue     88

Playback Utility Functions     89

   Handling the Magic Cookie     89

   Calculating Buffer Size and Expected Packet Count     90

The Playback Audio Queue Callback     91

Features and Limits of Queue-Based Playback     94

Summary     95

Chapter 6  Conversion     97

The afconvert Utility     97

Using Audio Converter Services     100

Setting Up Files for Conversion     102

   Calling Audio Converter Services     105

   Implementing the Converter Callback     109

Converting with Extended Audio File Services     112

   Reading and Converting with Extended Audio Files     116

Summary     118

PART III: ADVANCED AUDIO

Chapter 7  Audio Units: Generators, Effects, and Rendering     123

Where the Magic Happens     123

How Audio Units Work     124

Sizing Up the Audio Units     126

Your First Audio Units     129

   Building the main() Function     131

   Creating an Audio Unit Graph     133

   Setting Up the File Player Audio Unit     137

Speech and Effects with Audio Units     141

   Building Blocks of the Speech Synthesis Graph     142

   Creating a Speech Synthesis AUGraph     144

   Setting Up a Speech Synthesizer     146

   Adding Effects     147

Adding Your Code to the Audio Rendering Process     150

   The Audio Unit Render Cycle     150

   A Custom Rendering Example     151

   Creating and Connecting Audio Units     154

   The Render Callback Function     155

Summary     160

Chapter 8  Audio Units: Input and Mixing     161

Working with I/O Input     161

   Connecting Input and Output Units     164

   Creating an AUHAL Unit for Input     168

   Writing the Input Callback     176

   Building an AUGraph to Play Samples from a CARingBuffer     178

   Writing the Play-Through App’s Render Callback     181

   Running the Play-Through Example     182

Mixing     183

Summary     189

Chapter 9  Positional Sound     191

Sound in Space     191

The OpenAL API     193

Putting a Sound in Space     196

   Setting Up the Example     197

   Using OpenAL Objects     200

   Animating the Source’s Position     205

   Loading Samples for an OpenAL Buffer     206

Streaming Audio in OpenAL     210

   Setting Up the OpenAL Streaming Example     210

   Setting Up an ExtAudioFile for Streaming     215

   Refilling the OpenAL Buffers     217

Summary     220

PART IV: ADDITIONAL TOPICS

Chapter 10  Core Audio on iOS     223

Is That Core Audio in Your Pocket?     223

Playing Nicely with Others: Audio Session Services     224

An Audio Session Example     227

   Setting Up the App     227

   Initializing the Audio Session and Audio Queue     231

   The Tone Generator Method     234 

   Handling iOS Interruptions     236

Audio Units on iOS     238

   Building an Audio Pass-Through App with the iOS RemoteIO Unit     239

   Setting Up the Pass-Through Example     241

   Setting Up the RemoteIO Audio Unit for Capture and Play-Out     244

   The RemoteIO Render Callback     249

Other iOS Audio Tricks     253

   Remote Control on iOS     253

   IOS Hardware Hazards     254

Summary     254

Chapter 11  Core MIDI     257

MIDI Concepts     257

Core MIDI     258

   Core MIDI Architecture     258

   Core MIDI Terminology     258

   Core MIDI Properties     260

   MIDI Messages     260

Instrument Units     261

Building a Simple MIDI Synthesizer     262

   Connecting to MIDI     265

Handling MIDI Notifications and Events     267 

   Playing Your AUGraph     269

Creating MIDI Events     269

   Setting Up the MIDIWifiSource Example     269

   Setting Up MIDI over Wi-Fi     271

   Sending MIDI Messages     273

   Setting Up Your Mac to Receive Wi-Fi MIDI Data     275

Summary: MIDI Mastery … but Mobility?     277

Chapter 12  Coda     279

Still More Core Audio     279

Next Steps     280

   Digital Signal Processing     280

Lion and iOS 5     281

   AUSampler     281

   Core Audio on iOS 5     285

The Core Audio Community     286

Summary: Sounds Good     287

Index     289


More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020