www.it-ebooks.info Instant Audio Processing with Web Audio Learn how to use the Web Audio API to implement audio effects such as loop stitching, audio ducking, and audio equalization through practical, hands-on recipes Chris Khoo BIRMINGHAM - MUMBAI www.it-ebooks.info Instant Audio Processing with Web Audio Copyright © 2013 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: August 2013 Production Reference: 1220813 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78216-879-9 www.packtpub.com www.it-ebooks.info Credits Author Proofreader Chris Khoo Joanna McMahon Reviewer Graphics Alex Libby Abhinash Sahu Acquisition Editor Production Coordinator James Jones Nitesh Thakur Commissioning Editor Cover Work Harsha Bharwani Nitesh Thakur Technical Editor Cover Image Veena Pagare Sheetal Aute Project Coordinator Suraj Bisht www.it-ebooks.info About the Author Chris Khoo has been an avid programmer since his first encounter with the personal computer in the 80s. Since then, he's evolved from a nerdy hobbyist programmer into a full-fledged software developer with over 15 years of industry experience in developing games at companies including Microsoft, Disney, Electronic Arts, and Nexon. To date, he has shipped over a dozen console, mobile, and online games including the FIFA series, the SSX series, Def Jam: FFNY, Tom and Jerry Online, and Hyper Grav. His unique combination of AAA console game programming experience and web development experience makes him uniquely qualified to pen a practical study of implementing audio using the Web Audio API. Chris presently resides in Vancouver, BC, with his wife and two children. He is the founder and primary developer at Wappworks Studio, a 3-man indie game studio dedicated to online and mobile web games. When he's not busy at work, Chris enjoys playing board games and helping out with praise and worship at his local church. I would like to send a giant heartfelt thanks to my wife, Joanne, and my two kids, Michelle and Michael, for allowing me to give up my family time in pursuit of an authoring career. I would also like to thank my business partner and confidante, Chris, for his patience and advice. Finally, I want to thank God for all His blessings and for giving me peace and comfort as I've frantically juggled my personal, work, and authoring roles. www.it-ebooks.info About the Reviewer Alex Libby's background is in IT support—he has been involved in supporting end users for the last 15 years in a variety of different environments, and currently works as a Technical Analyst, supporting a medium-sized SharePoint estate for an international distributor based in the UK. Although Alex gets to play with different technologies in his day job, his true love has always been the Open Source movement, and in particular, experimenting with jQuery, CSS3, and HTML5. To date, Alex has written several books for Packt, including ones on HTML5 technologies and others on jQuery tools. In his free time, Alex enjoys helping out at the local amateur theatre. He also enjoys cycling and photography. www.it-ebooks.info www.PacktPub.com Support files, eBooks, discount offers and more You might want to visit www.PacktPub.com for support files and downloads related to your book. Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details. At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks. http://PacktLib.PacktPub.com Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books. Why Subscribe? f Fully searchable across every book published by Packt f Copy and paste, print and bookmark content f On demand and accessible via web browser Free Access for Packt account holders If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access. www.it-ebooks.info Table of Contents Preface 1 Instant Audio Processing with Web Audio 7 Setting up a web host (Simple) 7 Playing audio in a loop (Simple) 11 Setting the volume (Simple) 18 Automating the audio parameters (Intermediate) 28 Building an equalizer using BiquadFilterNode (Advanced) 44 www.it-ebooks.info Table of Contents ii www.it-ebooks.info Preface Web Audio is a new audio API proposed by World Wide Web Consortium (W3C) to address the shortcomings of the existing HTML5 Audio API. This new API allows developers to perform advanced real-time audio processing/mixing that is just not possible with current standards. In this book, we'll explore Web Audio's audio processing functionality through a series of recipes. We'll also apply our learning towards building an audio system. By the end of the book, we will have a clear grasp of the Web Audio API, its design philosophy, and how to utilize it to put together a plethora of audio effects. Web Audio is a fairly new API. As a result, many browsers do not yet support it. The list of web browsers which currently support it is a short one; they are Chrome for PC and Mac (v10 or higher), and Safari for PC and Mac (v6 or higher).Firefox has slated to support Web Audio in its next release (Version 19). The Web Audio API is a big subject matter for an Instant book. In fact, it's so large that we'll jump straight into Web Audio's audio manipulation functionality. But don't worry, we're providing bonus online recipes which focus on the basic aspects of the API which we skipped over. What this book covers Setting Up a Web Host (Simple), will help us set up a local web host for our development environment. Playing Audio in a Loop (Simple), will help us explore Web Audio's audio looping functionality as we build a simple sound player. Setting the Volume (Simple), will guide us through an in-depth look at Web Audio's volume control functionality. Automating Audio Parameters (Intermediate), will focus on Web Audio's timing and scheduling functionality, and use it to build a sound ducking audio processor. www.it-ebooks.info
Description: