Designing Audio Effect Plugins in C++
eBook - ePub

Designing Audio Effect Plugins in C++

For AAX, AU, and VST3 with DSP Theory

  1. 656 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Designing Audio Effect Plugins in C++

For AAX, AU, and VST3 with DSP Theory

About this book

Designing Audio Effect Plugins in C++ presents everything you need to know about digital signal processing in an accessible way. Not just another theory-heavy digital signal processing book, nor another dull build-a-generic-database programming book, this book includes fully worked, downloadable code for dozens of professional audio effect plugins and practically presented algorithms.

Sections include the basics of audio signal processing, the anatomy of a plugin, AAX, AU and VST3 programming guides; implementation details; and actual projects and code. More than 50 fully coded C++ audio signal-processing objects are included. Start with an intuitive and practical introduction to the digital signal processing (DSP) theory behind audio plug-ins, and quickly move on to plugin implementation, gain knowledge of algorithms on classical, virtual analog, and wave digital filters, delay, reverb, modulated effects, dynamics processing, pitch shifting, nonlinear processing, sample rate conversion and more. You will then be ready to design and implement your own unique plugins on any platform and within almost any host program.

This new edition is fully updated and improved and presents a plugin core that allows readers to move freely between application programming interfaces and platforms. Readers are expected to have some knowledge of C++ and high school math.

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription.
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn more here.
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes! You can use the Perlego app on both iOS or Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app.
Yes, you can access Designing Audio Effect Plugins in C++ by Will Pirkle,Will C. Pirkle in PDF and/or ePUB format, as well as other popular books in Technology & Engineering & Media Studies. We have over one million books available in our catalogue for you to explore.

Chapter 1
Introduction

The first affordable digital audio devices began appearing in the mid-1980s. Digital signal processing (DSP) mathematics had been around since the 1960s. Commercial digital recordings first appeared in the early 1970s, but the technology did not become available for widespread distribution until about 15 years later when the advent of the compact disc ushered in the age of digital audio. Digital sampling refers to the acquisition of data points from a continuous analog signal. The data points are sampled on a regular interval known as the ā€œsample periodā€ or ā€œsample interval.ā€ The inverse of the sample period is the sampling frequency, which we denote as fs. A compact disc uses a sampling frequency of 44,100 Hz, producing 44,100 discrete samples per channel each second, with a sample interval of about 22.7 microseconds (μS). While digital sampling applies to many different systems, this book is focused on only one of those applications: audio. Prior to the early 1990s digital audio effects and synthesizers were implemented in hardware devices that consisted of microprocessors, microcontrollers, DSP chips, and other components. These devices almost exclusively featured analog input and output connections at first, and then later began to incorporate digital I/O. Digital audio workstations (DAWs) appeared in the late 1980s and audio software began to bloom. Microsoft released a software development kit (SDK) called DirectXĀ® aimed at what was originally termed multimedia—a phrase many used at the time, but few really understood. Within DirectX were signal processing specifications to process audio and video data streams, and in short time the first DAWs appeared that supported DirectX ā€œplugins.ā€ Around the same time, Steinberg Media Technology published a specification for its Virtual Studio Technology (VST), which became arguably the most popular plugin format ever conceived.
During the course of this book, you will learn both DSP theory and C++ software applications. You have instant access to dozens of C++ objects that implement every signal processing algorithm in the book, and Chapters 9 through 22 will specifically reveal the conversion of the algorithms into C++ code. Each of these chapters will include one to three of these C++ objects. These objects are not tied to any plugin format or operating system. You may easily combine them with other signal processing objects or frameworks, and you have license to use them as you wish for commercial or noncommercial plugins. The resulting products sound fantastic. You will get great satisfaction when you begin inventing your own unique plugins, or implementing cutting-edge audio algorithms as soon as they are published.

1.1 Using This Book

Included are individual chapters for the three major commercially available effects specifications AAX (Avid Audio eXtension), Audio Unit (AU), and VST3 (Steinberg Media Technology GmbH). Plugin specifications are also known as APIs. The most important aspect of the book design is that you may use whatever platform you wish for writing and testing your plugins on MacOS or Windows and in the DAW of your choice. The DSP algorithms encapsulated in the aforementioned C++ objects are platform and API neutral. As you study the API-specific chapters, you will learn that all three of these APIs are really very similar in their internal functionality, but the implementation details for the different APIs can be overwhelming. This has lead to the use of third party plugin development frameworks.
You may already be using one of these frameworks, such as JUCE—if so, that is fine. You can easily incorporate the C++ signal processing objects into these frameworks because the objects are not API or platform centric. Make sure you adhere to any licensing restrictions that these frameworks require and follow their rules for software release or code publication. You will need to know how to get audio in and out of the frameworks as well as how to design your graphical user interface (GUI) and handle parameter changes from the GUI or DAW automation so please refer to documentation for those frameworks for that information.
If you are like most readers you probably have not developed a plugin using one of those frameworks—or perhaps you tried, but got bogged down in the steep learning curves and the new implementation details that the frameworks were supposed to help alleviate. Or you may have downloaded one of the SDKs and were bewildered by its contents. That is also fine because we’ve spent the last three years developing a fully functional, truly professional, license-free platform for you to use called ASPiKā„¢ (which stands for ā€œAudio Specific PlugiIn Kernelā€). ASPiK consists of a set of C++ objects that are custom tailored to interface directly with AAX, AU, and VST3 plugins, along with a mechanism for easily generating new plugin projects.
The projects for the book are packaged as ASPiK plugin projects and are simple to integrate into other third party frameworks if you would rather use them instead. All of the plugin projects in the book are written in a way that will make the code simple to transport to other development systems. In addition, the code in the individual chapters does not focus on any API, or on ASPiK itself. The fundamental goal of the book is to help you understand audio signal processing algorithms and how to convert them into C++ objects; it tries to be as platform, framework, and API neutral as possible.
Included in the ASPiK framework is a complete, platform-independent GUI design system called the PluginGUI object, with a drag-and-drop interface for creating beautiful and professional looking GUIs without writing a single line of code. If you want to experiment with GUI programming, you can find out about custom GUI design in Chapter 21.
If you are new to plugin programming, or you want to develop new plugins or test algorithms in the most efficient manner possible, you might want to use the RackAFXā„¢ software, however this book is not RackAFX-centric nor requires it for use. There is absolutely no RackAFX-specific code in ASPiK or its accompanying objects. However, RackAFX simplifies plugin programming and design by allowing you to quickly define the plugin parameters and user interface, and it includes tools for testing your plugin algorithm such as an oscillator, oscilloscope, spectrum analyzer, and more. You may also use RackAFX to generate ASPiK projects based off of your designs, and these ASPiK projects do not rely upon, nor include anything RackAFX-specific. Almost all of the real-time response plots you see in this book—including frequency, impulse, step, and phase responses—were done using RackAFX’s plugin analyzer, which can make analytical measurements on your plugin’s algorithm while it is running.

1.2 Fundamentals of Audio Signal Processing

Because plugins are software variations on hardware designs, it’s worth examining how the hardware systems operate: acquisition of data, audio reconstruction, and numerical representation of the audio signal. Then we define our analytical test signals and the basic signal processing blocks.

1.2.1 Acquisition of Audio Samples

The incoming analog audio signal is sampled with an analog to digital converter (ADC or A/D). Analog to digital converters must accurately sample and convert an incoming signal, producing a valid digitally coded number that represents the analog voltage within the sampling interval. This means that for CD audio, a converter must produce an output every 22.7 μS. Figure 1.1a shows the block diagram of the input conversion system with low-pass filter, A/D, and encoder while Figure 1.1b demonstrates the Nyquist frequency’s encoding consisting of only two points.
The sampling theorem states that a continuous analog signal can be sampled into discrete data points and then reconstructed into the original analog signal without any loss of information—including inter-sample fluctuations—if and only if the input signal has been band-limited so that it contains no frequencies higher than half the sample rate, also known as the Nyquist frequency or Nyquist rate. Band-limited means low-pass filtered (LPF). Band-limiting the input signal prior to sampling is known as adhering to the Nyquist criteria.
Violating the Nyquist criteria will create audible errors in the signal in the form of an erroneously encoded signal. We will refer to the Nyquist frequency simply as ā€œNyquistā€ from now on. Frequencies higher than Nyquist will fold back into the spectrum. This effect is called aliasing since the higher-than-Nyquist frequencies are encoded ā€œin disguiseā€ or as an ā€œaliasā€ of the actual frequency. This is easiest explained with a picture of an aliased signal shown in Figure 1.1c where the encoding error is shown in the dotted waveform—it is clearly not the correct frequency.
Once the aliased signal is created it will remain as a permanent error in the signal. The LPF that band-limits the signal at the input is called the ā€œanti-aliasing filter.ā€ Another form of aliasing occurs at the movies. An analog movie camera takes 30 pictures (frames) per second. However, it must often film objects that are rotating at much higher rates than 30 per second, like helicopter blades or car wheels.
Figure 1.1: (a) An analog-to-digital encoding system. (b) The Nyquist frequency is the highest frequency that can be encoded with two samples per period. (c) Increasing the frequency above Nyquist but keeping the sampling interval the same results in an obvious coding error—the aliased signal (dotted line) is the result.
Figure 1.1: (a) An analog-to-digital encoding system. (b) The Nyquist frequency is the highest frequency that can be encoded ...

Table of contents

  1. Cover
  2. Half Title
  3. Title
  4. Copyright
  5. Dedication
  6. Contents
  7. List of Figures
  8. List of Tables
  9. Preface
  10. Chapter 1: Introduction
  11. Chapter 2: Anatomy of an Audio Plugin
  12. Chapter 3: VST3 Programming Guide
  13. Chapter 4: AU Programming Guide
  14. Chapter 5: AAX Native Programming Guide
  15. Chapter 6: ASPiK Programming Guide
  16. Chapter 7: Using RackAFX to Create ASPiK Projects
  17. Chapter 8: C++ Conventions and How to Use This Book
  18. Chapter 9: How DSP Filters Work (Without Complex Math)
  19. Chapter 10: Basic DSP Theory
  20. Chapter 11: Audio Filter Designs: IIR Filters
  21. Chapter 12: Audio Filter Designs: Wave Digital and Virtual Analog
  22. Chapter 13: Modulators: LFOs and Envelope Detectors
  23. Chapter 14: Delay Effects and Circular Buffers
  24. Chapter 15: Modulated Delay Effects
  25. Chapter 16: Audio Filter Designs: FIR Filters
  26. Chapter 17: Reverb Effects
  27. Chapter 18: Dynamics Processing
  28. Chapter 19: Nonlinear Processing: Distortion, Tube Simulation, and HF Exciters
  29. Chapter 20: FFT Processing: The Phase Vocoder
  30. Chapter 21: Displaying Custom Waveforms and FFTs
  31. Chapter 22: Sample Rate Conversion
  32. Index