EARTH WEEK
Now through April 22, save up to 70% on digital learning resources. Learn more.
Rough Cuts are manuscripts that are developed but not yet published, available through Safari. Rough Cuts provide you access to the very latest information on a given topic and offer you the opportunity to interact with the author to influence the final publication.
This is the Rough Cut version of the printed book.
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.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