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.
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.
Building an Equalizer Using BiquadFilterNode (Advanced), will cover Web Audio's built-in audio processing functionality while building a 5-band equalizer.
In addition, this book features the following bonus online recipes. These recipes are available at http://www.packtpub.com/sites/default/files/downloads/Bonus_Recipes.pdf.
Initializing Web Audio (Simple), will take a look at Web Audio initialization on various web browsers.
Playing Audio Files (Simple), will cover Web Audio's design and playback fundamentals as we implement a sound player.
Scheduling Audio Playback (Intermediate), will explore Web Audio's timing functionality as we build a sound player capable of stitching audio playback seamlessly.
The following applications are required in order to follow all the recipes:
Chrome or Safari web browser (we need a Web Audio-capable web browser in order to run the recipes).
Apache Web Server (we have to host the recipes on a local web server in order to function properly. Most of the recipes rely on audio data loaded via AJAX and AJAX functions properly, only if the requested data is hosted on a web server. I've chosen to use Apache as the local web server of choice, as it is available for virtually all operating systems).
If you are installing it for the first time, I recommend installing XAMPP. XAMPP is a free and open source web server package which includes Apache Web Server as part of its bundle. The XAMPP installer and set up instructions are available at http://www.apachefriends.org/en/xampp.html.
You'll also need a text editor as we'll be writing CSS, HTML, and JavaScript code. While simple text editors such as Notepad or Vim will suffice, I recommend choosing a JavaScript editor with good autocomplete functionality, as we'll be spending a large part of our time writing JavaScript. A good and free JavaScript editor is Komo Edit (http://www.activestate.com/komodo-edit).
This book is meant for programmers who already have some HTML and JavaScript programming experience and who are seeking to learn how to use Web Audio in their applications. Experience with AJAX and web server installation/configuration will be good, but is not a necessity in order to follow the contents.
In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.
Code words in text are shown as follows: " The recipes of this book assume that the recipe application root is the webaudio
subdirectory."
A block of code is set as follows:
Alias /mywebaudio /webaudio <Directory "/webaudio"> Order allow,deny Allow from all </Directory>
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
sourceNode.loop = true; // Specify a custom loop segment sourceNode.loopStart = audioBuffer.duration * 0.5; sourceNode.loopEnd = audioBuffer.duration; // Keep track of the active sound loop
New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "clicking the Next button moves you to the next screen".
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.
To send us general feedback, simply send an e-mail to <[email protected]>
, and mention the book title via the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.
Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <[email protected]>
with a link to the suspected pirated material.
We appreciate your help in protecting our authors, and our ability to bring you valuable content.
You can contact us at <[email protected]>
if you are having a problem with any aspect of the book, and we will do our best to address it.