logo资料库

Learning Core Audio 无水印版.pdf

第1页 / 共329页
第2页 / 共329页
第3页 / 共329页
第4页 / 共329页
第5页 / 共329页
第6页 / 共329页
第7页 / 共329页
第8页 / 共329页
资料共329页,剩余部分请下载后查看
Contents
About the Authors
Foreword
Introduction
Audience for This Book
What You Need to Know
Looking Up Documentation
How This Book Is Organized
About the Sample Code
I: Understanding Core Audio
1 Overview of Core Audio
Core Audio Conventions
The Core Audio Frameworks
Your First Core Audio Application
Core Audio Properties
Summary
2 The Story of Sound
Making Waves
Digital Audio
DIY Samples
Buffers
Audio Formats
Summary
3 Audio Processing with Core Audio
Audio Data Formats
Canonical Formats
Processing Audio with Audio Units
The Pull Model
Summary
II: Basic Audio
4 Recording
All About Audio Queues
Building a Recorder
A CheckError() Function
Creating and Using the Audio Queue
Utility Functions for the Audio Queue
Summary
5 Playback
Defining the Playback Application
Setting Up a File-Playing Audio Queue
Playback Utility Functions
The Playback Audio Queue Callback
Features and Limits of Queue-Based Playback
Summary
6 Conversion
The afconvert Utility
Using Audio Converter Services
Setting Up Files for Conversion
Converting with Extended Audio File Services
Summary
III: Advanced Audio
7 Audio Units: Generators, Effects, and Rendering
Where the Magic Happens
How Audio Units Work
Sizing Up the Audio Units
Your First Audio Units
Speech and Effects with Audio Units
Adding Your Code to the Audio Rendering Process
Summary
8 Audio Units: Input and Mixing
Working with I/O Input
Mixing
Summary
9 Positional Sound
Sound in Space
The OpenAL API
Putting a Sound in Space
Streaming Audio in OpenAL
Summary
IV: Additional Topics
10 Core Audio on iOS
Is That Core Audio in Your Pocket?
Playing Nicely with Others: Audio Session Services
An Audio Session Example
Audio Units on iOS
Other iOS Audio Tricks
Summary
11 Core MIDI
MIDI Concepts
Core MIDI
Instrument Units
Building a Simple MIDI Synthesizer
Handling MIDI Notifications and Events
Creating MIDI Events
Summary: MIDI Mastery … but Mobility?
12 Coda
Still More Core Audio
Next Steps
Lion and iOS 5
The Core Audio Community
Summary: Sounds Good
Index
A
B
C
D
E
F
G-H
I
J-K-L
M
N
O
P
Q-R
S
T
U-Z
ptg7913098
Learning Core Audio
ptg7913098
Learning Core Audio A Hands-On Guide to Audio Programming for Mac and iOS Chris Adamson Kevin Avila Upper Saddle River, NJ • Boston • Indianapolis • San Francisco New York • Toronto • Montreal • London • Munich • Paris • Madrid Cape Town • Sydney • Tokyo • Singapore • Mexico City ptg7913098
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publish- er was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals. The authors and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omis- sions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein. The publisher offers excellent discounts on this book when ordered in quantity for bulk pur- chases or special sales, which may include electronic versions and/or custom covers and content particular to your business, training goals, marketing focus, and branding interests. For more information, please contact: U.S. Corporate and Government Sales (800) 382-3419 corpsales@pearsontechgroup.com For sales outside the United States, please contact: International Sales international@pearsoned.com Visit us on the Web: informit.com/aw Library of Congress Cataloging-in-Publication Data Adamson, Chris, 1967- Learning Core audio : a hands-on guide to audio programming for Mac and iOS / Chris Adamson, Kevin Avila. p. cm. ISBN 978-0-321-63684-3 (pbk. : alk. paper) — ISBN 0-321-63684-8 (pbk. : alk. paper) 1. Computer sound processing—Computer programs. 2. Core audio. 3. Apple computer— Programming. I. Avila, Kevin, 1980- II. Title. TK7881.4.A244 2012 006.4'5—dc23 Copyright © 2012 Pearson Education, Inc. 2012000862 All rights reserved. Printed in the United States of America. This publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited repro- duction, storage in a retrieval system, or transmission in any form or by any means, elec- tronic, mechanical, photocopying, recording, or likewise. To obtain permission to use materi- al from this work, please submit a written request to Pearson Education, Inc., Permissions Department, One Lake Street, Upper Saddle River, New Jersey 07458, or you may fax your request to (201) 236-3290. ISBN-13: 978-0-32-163684-3 ISBN-10: 0-32-163684-8 Text printed in the United States on recycled paper at R.R. Donnelley in Crawfordsville, Indiana. Second printing, June 2012 Editor-in-Chief Mark Taub Senior Acquisitions Editor Trina MacDonald Development Editor Chris Zahn Managing Editor Kristy Hart Senior Project Editor Lori Lyons Copy Editor Krista Hansing Editorial Services, Inc. Senior Indexer Cheryl Lenser Proofreader Kathy Ruiz Technical Reviewers Mark Dalrymple Mark Granoff Michael James Chris Liscio Robert Strogan Alex Wiltschko Publishing Coordinator Olivia Basegio Multimedia Developer Dan Scherf Cover Designer Chuti Prasertsith Compositor Nonie Ratcliff ptg7913098
Contents About the Authors Foreword xv xiii 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 I: Understanding Core Audio 1 Overview of Core Audio 13 The Core Audio Frameworks Core Audio Conventions Your First Core Audio Application 15 14 16 Running the Example 19 Core Audio Properties Summary 23 22 2 The Story of Sound 25 25 Making Waves Digital Audio DIY Samples Buffers 40 Audio Formats Summary 41 27 32 40 ptg7913098
vi Contents 3 Audio Processing with Core Audio 43 Audio Data Formats 43 Example: Figuring Out Formats 46 51 Canonical Formats Processing Audio with Audio Units The Pull Model Summary 55 55 II: Basic Audio 4 Recording 59 59 All About Audio Queues Building a Recorder A CheckError() Function Creating and Using the Audio Queue Utility Functions for the Audio Queue 63 60 53 64 71 The Recording Audio Queue Callback 75 Summary 78 5 Playback 81 Defining the Playback Application 81 Setting Up a File-Playing Audio Queue 83 85 Playback Utility Functions Setting Up the Playback Buffers Starting the Playback Queue 89 Handling the Magic Cookie Calculating Buffer Size and Expected Packet Count 88 89 90 The Playback Audio Queue Callback Features and Limits of Queue-Based Playback Summary 95 91 94 6 Conversion 97 The afconvert Utility Using Audio Converter Services Setting Up Files for Conversion 97 100 102 Calling Audio Converter Services Implementing the Converter Callback 105 109 ptg7913098
Contents vii Converting with Extended Audio File Services 112 Reading and Converting with Extended Audio Files 118 Summary 116 III: Advanced Audio 7 Audio Units: Generators, Effects, and Rendering 123 123 Where the Magic Happens How Audio Units Work Sizing Up the Audio Units Your First Audio Units 129 124 126 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 Creating a Speech Synthesis AUGraph Setting Up a Speech Synthesizer 146 Adding Effects 144 147 142 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 The Render Callback Function 155 154 Summary 160 8 Audio Units: Input and Mixing 161 Working with I/O Input 161 Connecting Input and Output Units Creating an AUHAL Unit for Input Writing the Input Callback 176 Building an AUGraph to Play Samples from a 164 168 CARingBuffer 178 Writing the Play-Through App’s Render Callback Running the Play-Through Example 182 181 183 Mixing Summary 189 ptg7913098
分享到:
收藏